命名空间:microsoft.graph
在呼叫中发送 DTMF 音调。
有关如何处理操作的详细信息,请参阅 commsOperation
此 API 可用于以下国家级云部署。
全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
✅ |
❌ |
❌ |
❌ |
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
权限类型 |
最低特权权限 |
更高特权权限 |
委派(工作或学校帐户) |
不支持。 |
不支持。 |
委派(个人 Microsoft 帐户) |
不支持。 |
不支持。 |
应用程序 |
Calls.Initiate.All |
Calls.AccessMedia.All |
注意:创建呼叫时会检查权限;调用此 API 时,不会创建其他权限检查。 Calls.AccessMedia.All 仅对使用应用托管媒体的调用是必需的。
HTTP 请求
POST /app/calls/{id}/sendDtmfTones
POST /communications/calls/{id}/sendDtmfTones
注意:/app
路径已弃用。 今后将使用 /communications
路径。
名称 |
说明 |
Authorization |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
请求正文
在请求正文中,提供具有以下参数的 JSON 对象。
参数 |
类型 |
说明 |
色调 |
ToneInfo 集合 |
要发送的音调。 |
delayBetweenTonesMs |
Int32 |
音调之间的毫秒延迟。 |
clientContext |
String |
唯一的客户端上下文字符串。 最多可以包含 256 个字符。 |
响应
如果成功,此方法在 200 OK
响应正文中返回响应代码和 sendDtmfTonesOperation 对象。
示例
以下示例演示如何在呼叫中发送 DTMF 音调。
请求
以下示例显示了一个请求。
POST https://graph.microsoft.com/v1.0/communications/calls/481f3600-983e-4276-9b59-c1b30ec8d125/microsoft.graph.sendDtmfTones
Content-Type: application/json
Content-Length: 166
{
"tones": [
"tone1",
"tone2",
"tone3",
"tone4",
"tone5",
"tone6",
"tone7",
"tone8",
"tone9",
"tone0",
"star",
"pound"
],
"delayBetweenTonesMs": 1000,
"clientContext": "e0be71f1-a14f-4cec-b65a-e7aba5db7c53"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Communications.Calls.Item.SendDtmfTones;
using Microsoft.Graph.Models;
var requestBody = new SendDtmfTonesPostRequestBody
{
Tones = new List<Tone?>
{
Tone.Tone1,
Tone.Tone2,
Tone.Tone3,
Tone.Tone4,
Tone.Tone5,
Tone.Tone6,
Tone.Tone7,
Tone.Tone8,
Tone.Tone9,
Tone.Tone0,
Tone.Star,
Tone.Pound,
},
DelayBetweenTonesMs = 1000,
ClientContext = "e0be71f1-a14f-4cec-b65a-e7aba5db7c53",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Communications.Calls["{call-id}"].SendDtmfTones.PostAsync(requestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
mgc communications calls send-dtmf-tones post --call-id {call-id} --body '{\
"tones": [\
"tone1",\
"tone2",\
"tone3",\
"tone4",\
"tone5",\
"tone6",\
"tone7",\
"tone8",\
"tone9",\
"tone0",\
"star",\
"pound"\
],\
"delayBetweenTonesMs": 1000,\
"clientContext": "e0be71f1-a14f-4cec-b65a-e7aba5db7c53"\
}\
'
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphcommunications "github.com/microsoftgraph/msgraph-sdk-go/communications"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphcommunications.NewSendDtmfTonesPostRequestBody()
tones := []graphmodels.Toneable {
tone := graphmodels.TONE1_TONE
requestBody.SetTone(&tone)
tone := graphmodels.TONE2_TONE
requestBody.SetTone(&tone)
tone := graphmodels.TONE3_TONE
requestBody.SetTone(&tone)
tone := graphmodels.TONE4_TONE
requestBody.SetTone(&tone)
tone := graphmodels.TONE5_TONE
requestBody.SetTone(&tone)
tone := graphmodels.TONE6_TONE
requestBody.SetTone(&tone)
tone := graphmodels.TONE7_TONE
requestBody.SetTone(&tone)
tone := graphmodels.TONE8_TONE
requestBody.SetTone(&tone)
tone := graphmodels.TONE9_TONE
requestBody.SetTone(&tone)
tone := graphmodels.TONE0_TONE
requestBody.SetTone(&tone)
tone := graphmodels.STAR_TONE
requestBody.SetTone(&tone)
tone := graphmodels.POUND_TONE
requestBody.SetTone(&tone)
}
requestBody.SetTones(tones)
delayBetweenTonesMs := int32(1000)
requestBody.SetDelayBetweenTonesMs(&delayBetweenTonesMs)
clientContext := "e0be71f1-a14f-4cec-b65a-e7aba5db7c53"
requestBody.SetClientContext(&clientContext)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
sendDtmfTones, err := graphClient.Communications().Calls().ByCallId("call-id").SendDtmfTones().Post(context.Background(), requestBody, nil)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.communications.calls.item.senddtmftones.SendDtmfTonesPostRequestBody sendDtmfTonesPostRequestBody = new com.microsoft.graph.communications.calls.item.senddtmftones.SendDtmfTonesPostRequestBody();
LinkedList<Tone> tones = new LinkedList<Tone>();
tones.add(Tone.Tone1);
tones.add(Tone.Tone2);
tones.add(Tone.Tone3);
tones.add(Tone.Tone4);
tones.add(Tone.Tone5);
tones.add(Tone.Tone6);
tones.add(Tone.Tone7);
tones.add(Tone.Tone8);
tones.add(Tone.Tone9);
tones.add(Tone.Tone0);
tones.add(Tone.Star);
tones.add(Tone.Pound);
sendDtmfTonesPostRequestBody.setTones(tones);
sendDtmfTonesPostRequestBody.setDelayBetweenTonesMs(1000);
sendDtmfTonesPostRequestBody.setClientContext("e0be71f1-a14f-4cec-b65a-e7aba5db7c53");
var result = graphClient.communications().calls().byCallId("{call-id}").sendDtmfTones().post(sendDtmfTonesPostRequestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const sendDtmfTonesOperation = {
tones: [
'tone1',
'tone2',
'tone3',
'tone4',
'tone5',
'tone6',
'tone7',
'tone8',
'tone9',
'tone0',
'star',
'pound'
],
delayBetweenTonesMs: 1000,
clientContext: 'e0be71f1-a14f-4cec-b65a-e7aba5db7c53'
};
await client.api('/communications/calls/481f3600-983e-4276-9b59-c1b30ec8d125/microsoft.graph.sendDtmfTones')
.post(sendDtmfTonesOperation);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Communications\Calls\Item\SendDtmfTones\SendDtmfTonesPostRequestBody;
use Microsoft\Graph\Generated\Models\Tone;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SendDtmfTonesPostRequestBody();
$requestBody->setTones([new Tone('tone1'),new Tone('tone2'),new Tone('tone3'),new Tone('tone4'),new Tone('tone5'),new Tone('tone6'),new Tone('tone7'),new Tone('tone8'),new Tone('tone9'),new Tone('tone0'),new Tone('star'),new Tone('pound'), ]);
$requestBody->setDelayBetweenTonesMs(1000);
$requestBody->setClientContext('e0be71f1-a14f-4cec-b65a-e7aba5db7c53');
$result = $graphServiceClient->communications()->calls()->byCallId('call-id')->sendDtmfTones()->post($requestBody)->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.CloudCommunications
$params = @{
tones = @(
"tone1"
"tone2"
"tone3"
"tone4"
"tone5"
"tone6"
"tone7"
"tone8"
"tone9"
"tone0"
"star"
"pound"
)
delayBetweenTonesMs = 1000
clientContext = "e0be71f1-a14f-4cec-b65a-e7aba5db7c53"
}
Send-MgCommunicationCallDtmfTone -CallId $callId -BodyParameter $params
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.communications.calls.item.send_dtmf_tones.send_dtmf_tones_post_request_body import SendDtmfTonesPostRequestBody
from msgraph.generated.models.tone import Tone
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SendDtmfTonesPostRequestBody(
tones = [
Tone.Tone1,
Tone.Tone2,
Tone.Tone3,
Tone.Tone4,
Tone.Tone5,
Tone.Tone6,
Tone.Tone7,
Tone.Tone8,
Tone.Tone9,
Tone.Tone0,
Tone.Star,
Tone.Pound,
],
delay_between_tones_ms = 1000,
client_context = "e0be71f1-a14f-4cec-b65a-e7aba5db7c53",
)
result = await graph_client.communications.calls.by_call_id('call-id').send_dtmf_tones.post(request_body)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Location: https://graph.microsoft.com/v1.0/communications/calls/57dab8b1-894c-409a-b240-bd8beae78896/operations/d36fe651-9f50-484d-bd4b-1e6415eae448
{
"@odata.type": "#microsoft.graph.sendDtmfTonesOperation",
"status": "running",
"clientContext": "e0be71f1-a14f-4cec-b65a-e7aba5db7c53",
"id": "d36fe651-9f50-484d-bd4b-1e6415eae448"
}
通知 - 操作已完成
成功案例
POST https://bot.contoso.com/api/calls
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.commsNotifications",
"value": [
{
"@odata.type": "#microsoft.graph.commsNotification",
"changeType": "deleted",
"resourceUrl": "/communications/calls/481f3600-983e-4276-9b59-c1b30ec8d125/operations/d36fe651-9f50-484d-bd4b-1e6415eae448",
"resourceData": {
"@odata.type": "#microsoft.graph.sendDtmfTonesOperation",
"status": "completed",
"completionReason": "completedSuccessfully",
"clientContext": "e0be71f1-a14f-4cec-b65a-e7aba5db7c53",
"id": "d36fe651-9f50-484d-bd4b-1e6415eae448"
}
}
]
}
错误案例 1
POST https://bot.contoso.com/api/calls
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.commsNotifications",
"value": [
{
"@odata.type": "#microsoft.graph.commsNotification",
"changeType": "deleted",
"resourceUrl": "/communications/calls/481f3600-983e-4276-9b59-c1b30ec8d125/operations/d36fe651-9f50-484d-bd4b-1e6415eae448",
"resourceData": {
"@odata.type": "#microsoft.graph.sendDtmfTonesOperation",
"status": "completed",
"completionReason": "mediaOperationCanceled",
"clientContext": "e0be71f1-a14f-4cec-b65a-e7aba5db7c53",
"id": "d36fe651-9f50-484d-bd4b-1e6415eae448"
}
}
]
}
错误案例 2
POST https://bot.contoso.com/api/calls
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.commsNotifications",
"value": [
{
"@odata.type": "#microsoft.graph.commsNotification",
"changeType": "deleted",
"resourceUrl": "/communications/calls/481f3600-983e-4276-9b59-c1b30ec8d125/operations/d36fe651-9f50-484d-bd4b-1e6415eae448",
"resourceData": {
"@odata.type": "#microsoft.graph.sendDtmfTonesOperation",
"status": "completed",
"completionReason": "unknown",
"clientContext": "e0be71f1-a14f-4cec-b65a-e7aba5db7c53",
"id": "d36fe651-9f50-484d-bd4b-1e6415eae448"
}
}
]
}