Is it possible to receive a PSTN telephone call with Azure Communication Services?
是否可以使用Azure通信服务接收PSTN电话呼叫?
All the docs and the demos talk about initiating a call to a known number.
所有的文档和演示都谈到了向已知号码发起呼叫。
My use case is that somebody rings a phone number from their mobile phone (PSTN) and I want to be able to handle the call.
我的用例是有人从他们的移动电话(PSTN)拨打电话号码,我希望能够处理呼叫。
I cant find any documentation that discusses this or how to do routing! For example, which route the call to a particular agent.
我找不到任何讨论这一点或如何进行布线的文档!例如,它将呼叫路由到特定的代理。
Have I missed something? Any thoughts?
我错过了什么吗?有什么想法吗?
更多回答
优秀答案推荐
For anybody looking.... you cant as of 18/03/2022
对于任何想看的人来说...自2022年3月18日起不能
This came directly from a conversation with Microsoft.
这直接来自于与微软的一次对话。
You can initiate a call via the API, but you cannot receive a call made from a telephone on a PSTN or manage routing etc.
您可以通过API发起呼叫,但不能接收来自PSTN上的电话或管理路由等。
This is now possible - I have implemented in my own application and it works well.
这现在是可能的-我已经在我自己的应用程序中实现了它,它工作得很好。
To allow incoming calls you have to purchase a Toll Free number in ACS - it is not supported with Local numbers. You then configure an Azure Event Grid service to subscribe to Incoming Call events on your ACS instance, and configure a webhook URL for it that points to your own API. Azure Event Grid then posts some data to your API when an incoming call is received which contains the "Incoming Call Context". A member of the ACS team called Jason Shave has created some useful Nugets to help with parsing the Azure Event Grid event data, see here.
要允许来电,您必须在ACS中购买免费号码-本地号码不支持。然后,您可以配置Azure Event Grid服务以订阅您的ACS实例上的传入呼叫事件,并为其配置指向您自己的API的WebHook URL。当接收到包含“传入调用上下文”的传入调用时,Azure事件网格会将一些数据发布到您的API中。ACS团队的一位名叫Jason Save的成员创建了一些有用的Nuget来帮助解析Azure Event Grid事件数据,请参见此处。
Your API can then perform some logic, e.g. check your database to fetch the ACS unique identifier for connected user you want to forward the specific incoming call to, e.g. based on lookup of incoming call telephone number to check for assigned agent, you can then use the CallAutomation client SDK for .Net to redirect the Incoming Call Context to this identifier, and return an empty 200 response to Azure Event Grid so it knows the response has been handled and not to resend.
然后,您的API可以执行一些逻辑,例如,检查您的数据库以获取您要将特定来电转发到的已连接用户的ACS唯一标识符,例如,基于来电电话号码的查找以检查分配的代理,然后您可以使用.Net的CallAutomation客户端SDK将来电上下文重定向到此标识符,并向Azure事件网格返回空的200响应,以便它知道该响应已被处理,而不是重新发送。
See full documentation on concepts involved here.
有关此处涉及的概念的完整文档,请参阅。
I would also add your endpoint for Azure Event Grid will need to pass validation from Azure - I've added support for that like so:
我还会添加您的Azure事件网格终结点需要通过Azure的验证-我添加了对此的支持,如下所示:
using Azure.Messaging.EventGrid;
using Azure.Messaging.EventGrid.SystemEvents;
...
[AllowAnonymous]
[HttpPost("~/api/call-automation/event")]
public async Task<IActionResult> Event([FromBody] EventGridEvent[] events)
{
int eventCount = 0;
foreach (var eventGridEvent in events)
{
try
{
logger.LogWarning($"EventGridData[{eventCount++}] data is: {JsonConvert.SerializeObject(eventGridEvent)}");
// Validate whether EventType is of "Microsoft.EventGrid.SubscriptionValidationEvent"
switch (eventGridEvent.EventType)
{
case SystemEventNames.EventGridSubscriptionValidation:
{
var eventData = eventGridEvent.Data.ToObjectFromJson<SubscriptionValidationEventData>();
var responseData = new SubscriptionValidationResponse
{
ValidationResponse = eventData.ValidationCode
};
if (responseData.ValidationResponse != null)
{
return Ok(responseData);
}
}
break;
// Now you can handle incoming call
更多回答
我是一名优秀的程序员,十分优秀!