使用 Amazon Chime SDK PSTN 音频服务接收来电者输入 - Amazon Chime SDK

使用 Amazon Chime SDK PSTN 音频服务接收来电者输入

您可以使用 ReceiveDigits 操作收集入站 DTMF 数字并将其与正则表达式进行匹配。当 SIP 媒体应用程序收到与正则表达式匹配的数字时,它会通过 ACTION_SUCCESSFUL 事件调用 AWS Lambda 函数。收集的数字显示在 ActionData 对象的 ReceivedDigits 值中。

例如:

{ "SchemaVersion": "1.0", "Sequence": 4, "InvocationEventType": "ACTION_SUCCESSFUL", "ActionData": { "ReceivedDigits": "", "Type": "ReceiveDigits", "Parameters": { "CallId": "call-id-1", "InputDigitsRegex": "^\d{2}#$", "InBetweenDigitsDurationInMilliseconds": 5000, "FlushDigitsDurationInMilliseconds": 10000 } }, "CallDetails": { "TransactionId": "transaction-id", "AwsAccountId": "aws-account-id", "AwsRegion": "us-east-1", "SipRuleId": "sip-rule-id", "SipApplicationId": "sip-application-id", "Participants": [ { "CallId": "call-id-1", "ParticipantTag": "LEG-A", "To": "+12065551212", "From": "+15105550101", "Direction": "Inbound", "StartTimeInMilliseconds": "159700958834234", "Status": "Connected" } ] } }

一旦呼叫者输入与您的正则表达式模式相匹配的数字,SIP 媒体应用程序就会调用 AWS Lambda 函数,该函数返回以下类型的有效负载:

{ "SchemaVersion": "1.0", "Sequence": 5, "InvocationEventType": "DIGITS_RECEIVED", "ActionData": { "ReceivedDigits": "11#", "Type": "ReceiveDigits", "Parameters": { "CallId": "call-id-1", "InputDigitsRegex": "^\d{2}#$", "InBetweenDigitsDurationInMilliseconds": 5000, "FlushDigitsDurationInMilliseconds": 10000 } }, "CallDetails": { "TransactionId": "transaction-id", "AwsAccountId": "aws-account-id", "AwsRegion": "us-east-1", "SipRuleId": "sip-rule-id", "SipApplicationId": "sip-application-id", "Participants": [ { "CallId": "call-id-1", "ParticipantTag": "LEG-A", "To": "+12065551212", "From": "+15105550101", "Direction": "Inbound", "StartTimeInMilliseconds": "159700958834234", "Status": "Connected" } ] } }

在 GitHub 上查看工作示例:https://github.com/aws-samples/amazon-chime-sma-on-demand-recording