Created
June 4, 2024 01:52
-
-
Save xximjasonxx/d657113d6ada3177f984e1dca4924e14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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