Skip to content

Instantly share code, notes, and snippets.

@xximjasonxx
Created June 4, 2024 01:52
Show Gist options
  • Save xximjasonxx/d657113d6ada3177f984e1dca4924e14 to your computer and use it in GitHub Desktop.
Save xximjasonxx/d657113d6ada3177f984e1dca4924e14 to your computer and use it in GitHub Desktop.
public class MakeCallTest
{
private readonly ILogger _logger;
private readonly IConfiguration _configuration;
public MakeCallTest(ILoggerFactory loggerFactory, IConfiguration configuration)
{
_logger = loggerFactory.CreateLogger<MakeCallTest>();
_configuration = configuration;
}
[Function("MakeCallTest")]
public async Task<HttpResponseData> MakeCall(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "make/call")] HttpRequestData request)
{
var callAutomationClient = new CallAutomationClient(_configuration["AcsConnectionString"]);
var callInvite = new CallInvite(
new PhoneNumberIdentifier(_configuration["DestinationPhoneNumber"]),
new PhoneNumberIdentifier(_configuration["SourcePhoneNumber"])
);
var createCallOptions = new CreateCallOptions(callInvite, new Uri($"{_configuration["CallbackBaseUrl"]}/api/handle/event"))
{
CallIntelligenceOptions = new CallIntelligenceOptions
{
CognitiveServicesEndpoint = new Uri(_configuration["CognitiveServicesEndpoint"])
}
};
await callAutomationClient.CreateCallAsync(createCallOptions);
return request.CreateResponse(HttpStatusCode.OK);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment