call: answer
Article
07/06/2023
13 contributors
Feedback
In this article
Namespace: microsoft.graph
Enable a bot to answer an incoming call . The incoming call request can be an invite from a participant in a group call or a peer-to-peer call. If an invite to a group call is received, the notification will contain the chatInfo and meetingInfo parameters.
The bot is expected to answer, reject , or redirect the call before the call times out. The current timeout value is 15 seconds for regular scenarios, and 5 seconds for policy-based recording scenarios.
This API is supported in the following national cloud deployments .
Global service
US Government L4
US Government L5 (DOD)
China operated by 21Vianet
✅
✅
✅
❌
Permissions
You do not need any permissions to answer a peer-to-peer call. You need one of the following permissions to join a group call. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Not supported.
Delegated (personal Microsoft account)
Not supported.
Application
Calls.JoinGroupCall.All, Calls.JoinGroupCallAsGuest.All
Note: For a call that uses application-hosted media, you also need the Calls.AccessMedia.All permission. You must have at least one of the following permissions to ensure that the source
in the incoming call notification is decrypted: Calls.AccessMedia.All, Calls.Initiate.All, Calls.InitiateGroupCall.All, Calls.JoinGroupCall.All, Calls.JoinGroupCallAsGuest.All. The source
is the caller info in the incoming call notification. Without at least one of these permissions, the source
will remain encrypted.
HTTP request
POST /communications/calls/{id}/answer
Name
Description
Authorization
Bearer {token}. Required.
Content-type
application/json. Required.
Request body
In the request body, provide a JSON object with the following parameters.
Parameter
Type
Description
callbackUri
String
Allows bots to provide a specific callback URI for the concurrent call to receive later notifications. If this property has not been set, the bot's global callback URI will be used instead. This must be https
.
acceptedModalities
String collection
The list of accept modalities. Possible values are: audio
, video
, videoBasedScreenSharing
. Required for answering a call.
callOptions
incomingCallOptions
The call options.
mediaConfig
appHostedMediaConfig or serviceHostedMediaConfig
The media configuration. (Required)
participantCapacity
Int32
The number of participant that the application can handle for the call, for Teams policy-based recording scenario.
Response
This method returns a 202 Accepted
response code.
Examples
The following example shows how to call this API.
Request
The following example shows the request.
POST https://graph.microsoft.com/v1.0/communications/calls/{id}/answer
Content-Type: application/json
Content-Length: 211
{
"callbackUri": "callbackUri-value",
"mediaConfig": {
"@odata.type": "#microsoft.graph.appHostedMediaConfig",
"blob": "<Media Session Configuration Blob>"
},
"acceptedModalities": [
"audio"
],
"callOptions": {
"@odata.type": "#microsoft.graph.incomingCallOptions",
"isContentSharingNotificationEnabled": true
},
"participantCapacity": 200
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Microsoft.Graph.Communications.Calls.Item.Answer.AnswerPostRequestBody
{
CallbackUri = "callbackUri-value",
MediaConfig = new AppHostedMediaConfig
{
OdataType = "#microsoft.graph.appHostedMediaConfig",
Blob = "<Media Session Configuration Blob>",
},
AcceptedModalities = new List<Modality?>
{
Modality.Audio,
},
CallOptions = new IncomingCallOptions
{
OdataType = "#microsoft.graph.incomingCallOptions",
IsContentSharingNotificationEnabled = true,
},
ParticipantCapacity = 200,
};
await graphClient.Communications.Calls["{call-id}"].Answer.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc communications calls answer post --call-id {call-id} --body '{\
"callbackUri": "callbackUri-value",\
"mediaConfig": {\
"@odata.type": "#microsoft.graph.appHostedMediaConfig",\
"blob": "<Media Session Configuration Blob>"\
},\
"acceptedModalities": [\
"audio"\
],\
"callOptions": {\
"@odata.type": "#microsoft.graph.incomingCallOptions",\
"isContentSharingNotificationEnabled": true\
},\
"participantCapacity": 200\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
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
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphcommunications.NewAnswerPostRequestBody()
callbackUri := "callbackUri-value"
requestBody.SetCallbackUri(&callbackUri)
mediaConfig := graphmodels.NewAppHostedMediaConfig()
blob := "<Media Session Configuration Blob>"
mediaConfig.SetBlob(&blob)
requestBody.SetMediaConfig(mediaConfig)
acceptedModalities := []graphmodels.Modalityable {
modality := graphmodels.AUDIO_MODALITY
requestBody.SetModality(&modality)
}
requestBody.SetAcceptedModalities(acceptedModalities)
callOptions := graphmodels.NewIncomingCallOptions()
isContentSharingNotificationEnabled := true
callOptions.SetIsContentSharingNotificationEnabled(&isContentSharingNotificationEnabled)
requestBody.SetCallOptions(callOptions)
participantCapacity := int32(200)
requestBody.SetParticipantCapacity(&participantCapacity)
graphClient.Communications().Calls().ByCallId("call-id").Answer().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
String callbackUri = "callbackUri-value";
AppHostedMediaConfig mediaConfig = new AppHostedMediaConfig();
mediaConfig.blob = "<Media Session Configuration Blob>";
LinkedList<Modality> acceptedModalitiesList = new LinkedList<Modality>();
acceptedModalitiesList.add(Modality.AUDIO);
IncomingCallOptions callOptions = new IncomingCallOptions();
callOptions.isContentSharingNotificationEnabled = true;
int participantCapacity = 200;
graphClient.communications().calls("{id}")
.answer(CallAnswerParameterSet
.newBuilder()
.withCallbackUri(callbackUri)
.withMediaConfig(mediaConfig)
.withAcceptedModalities(acceptedModalitiesList)
.withParticipantCapacity(participantCapacity)
.withCallOptions(callOptions)
.build())
.buildRequest()
.post();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
const answer = {
callbackUri: 'callbackUri-value',
mediaConfig: {
'@odata.type': '#microsoft.graph.appHostedMediaConfig',
blob: '<Media Session Configuration Blob>'
},
acceptedModalities: [
'audio'
],
callOptions: {
'@odata.type': '#microsoft.graph.incomingCallOptions',
isContentSharingNotificationEnabled: true
},
participantCapacity: 200
};
await client.api('/communications/calls/{id}/answer')
.post(answer);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AnswerPostRequestBody();
$requestBody->setCallbackUri('callbackUri-value');
$mediaConfig = new AppHostedMediaConfig();
$mediaConfig->setOdataType('#microsoft.graph.appHostedMediaConfig');
$mediaConfig->setBlob('<Media Session Configuration Blob>');
$requestBody->setMediaConfig($mediaConfig);
$requestBody->setAcceptedModalities([new Modality('audio'), ]);
$callOptions = new IncomingCallOptions();
$callOptions->setOdataType('#microsoft.graph.incomingCallOptions');
$callOptions->setIsContentSharingNotificationEnabled(true);
$requestBody->setCallOptions($callOptions);
$requestBody->setParticipantCapacity(200);
$graphServiceClient->communications()->calls()->byCallId('call-id')->answer()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Import-Module Microsoft.Graph.CloudCommunications
$params = @{
callbackUri = "callbackUri-value"
mediaConfig = @{
"@odata.type" = "#microsoft.graph.appHostedMediaConfig"
blob = "<Media Session Configuration Blob>"
}
acceptedModalities = @(
"audio"
)
callOptions = @{
"@odata.type" = "#microsoft.graph.incomingCallOptions"
isContentSharingNotificationEnabled = $true
}
participantCapacity = 200
}
Invoke-MgAnswerCommunicationCall -CallId $callId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(request_adapter)
request_body = AnswerPostRequestBody(
callback_uri = "callbackUri-value",
media_config = AppHostedMediaConfig(
odata_type = "#microsoft.graph.appHostedMediaConfig",
blob = "<Media Session Configuration Blob>",
),
accepted_modalities = [
Modality.Audio,
]
call_options = IncomingCallOptions(
odata_type = "#microsoft.graph.incomingCallOptions",
is_content_sharing_notification_enabled = True,
),
participant_capacity = 200,
)
await graph_client.communications.calls.by_call_id('call-id').answer.post(body = request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
The following is an example of the response.
HTTP/1.1 202 Accepted
Notification - incoming
POST https://bot.contoso.com/api/calls
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.commsNotifications",
"value": [
{
"@odata.type": "#microsoft.graph.commsNotification",
"changeType": "created",
"resourceUrl": "/communications/calls/57DAB8B1894C409AB240BD8BEAE78896",
"resourceData": {
"@odata.type": "#microsoft.graph.call",
"@odata.id": "/communications/calls/57DAB8B1894C409AB240BD8BEAE78896",
"@odata.etag": "W/\"5445\"",
"state": "incoming",
"direction": "incoming",
"source": {
"identity": {
"user": {
"displayName": "Test User",
"id": "8A34A46B-3D17-4ADC-8DCE-DC4E7D572698"
}
},
"region": "westus",
"languageId": "en-US"
},
"targets": [
{
"identity": {
"application": {
"displayName": "Test BOT",
"id": "8A34A46B-3D17-4ADC-8DCE-DC4E7D572698"
}
}
}
],
"requestedModalities": [ "audio" ]
}
}
]
}
Request
POST /communications/calls/57DAB8B1894C409AB240BD8BEAE78896/answer
Content-Type: application/json
{
"callbackUri": "https://bot.contoso.com/api/calls",
"acceptedModalities": [ "audio" ],
"mediaConfig": {
"@odata.type": "#microsoft.graph.serviceHostedMediaConfig",
"preFetchMedia": [
{
"uri": "https://cdn.contoso.com/beep.wav",
"resourceId": "1D6DE2D4-CD51-4309-8DAA-70768651088E"
},
{
"uri": "https://cdn.contoso.com/cool.wav",
"resourceId": "1D6DE2D4-CD51-4309-8DAA-70768651088F"
}
]
}
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Microsoft.Graph.Communications.Calls.Item.Answer.AnswerPostRequestBody
{
CallbackUri = "https://bot.contoso.com/api/calls",
AcceptedModalities = new List<Modality?>
{
Modality.Audio,
},
MediaConfig = new ServiceHostedMediaConfig
{
OdataType = "#microsoft.graph.serviceHostedMediaConfig",
PreFetchMedia = new List<MediaInfo>
{
new MediaInfo
{
Uri = "https://cdn.contoso.com/beep.wav",
ResourceId = "1D6DE2D4-CD51-4309-8DAA-70768651088E",
},
new MediaInfo
{
Uri = "https://cdn.contoso.com/cool.wav",
ResourceId = "1D6DE2D4-CD51-4309-8DAA-70768651088F",
},
},
},
};
await graphClient.Communications.Calls["{call-id}"].Answer.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc communications calls answer post --call-id {call-id} --body '{\
"callbackUri": "https://bot.contoso.com/api/calls",\
"acceptedModalities": [ "audio" ],\
"mediaConfig": {\
"@odata.type": "#microsoft.graph.serviceHostedMediaConfig",\
"preFetchMedia": [\
{\
"uri": "https://cdn.contoso.com/beep.wav",\
"resourceId": "1D6DE2D4-CD51-4309-8DAA-70768651088E"\
},\
{\
"uri": "https://cdn.contoso.com/cool.wav",\
"resourceId": "1D6DE2D4-CD51-4309-8DAA-70768651088F"\
}\
]\
}\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
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
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphcommunications.NewAnswerPostRequestBody()
callbackUri := "https://bot.contoso.com/api/calls"
requestBody.SetCallbackUri(&callbackUri)
acceptedModalities := []graphmodels.Modalityable {
modality := graphmodels.AUDIO_MODALITY
requestBody.SetModality(&modality)
}
requestBody.SetAcceptedModalities(acceptedModalities)
mediaConfig := graphmodels.NewServiceHostedMediaConfig()
mediaInfo := graphmodels.NewMediaInfo()
uri := "https://cdn.contoso.com/beep.wav"
mediaInfo.SetUri(&uri)
resourceId := "1D6DE2D4-CD51-4309-8DAA-70768651088E"
mediaInfo.SetResourceId(&resourceId)
mediaInfo1 := graphmodels.NewMediaInfo()
uri := "https://cdn.contoso.com/cool.wav"
mediaInfo1.SetUri(&uri)
resourceId := "1D6DE2D4-CD51-4309-8DAA-70768651088F"
mediaInfo1.SetResourceId(&resourceId)
preFetchMedia := []graphmodels.MediaInfoable {
mediaInfo,
mediaInfo1,
}
mediaConfig.SetPreFetchMedia(preFetchMedia)
requestBody.SetMediaConfig(mediaConfig)
graphClient.Communications().Calls().ByCallId("call-id").Answer().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
String callbackUri = "https://bot.contoso.com/api/calls";
LinkedList<Modality> acceptedModalitiesList = new LinkedList<Modality>();
acceptedModalitiesList.add(Modality.AUDIO);
ServiceHostedMediaConfig mediaConfig = new ServiceHostedMediaConfig();
LinkedList<MediaInfo> preFetchMediaList = new LinkedList<MediaInfo>();
MediaInfo preFetchMedia = new MediaInfo();
preFetchMedia.uri = "https://cdn.contoso.com/beep.wav";
preFetchMedia.resourceId = "1D6DE2D4-CD51-4309-8DAA-70768651088E";
preFetchMediaList.add(preFetchMedia);
MediaInfo preFetchMedia1 = new MediaInfo();
preFetchMedia1.uri = "https://cdn.contoso.com/cool.wav";
preFetchMedia1.resourceId = "1D6DE2D4-CD51-4309-8DAA-70768651088F";
preFetchMediaList.add(preFetchMedia1);
mediaConfig.preFetchMedia = preFetchMediaList;
graphClient.communications().calls("57DAB8B1894C409AB240BD8BEAE78896")
.answer(CallAnswerParameterSet
.newBuilder()
.withCallbackUri(callbackUri)
.withMediaConfig(mediaConfig)
.withAcceptedModalities(acceptedModalitiesList)
.withParticipantCapacity(null)
.withCallOptions(null)
.build())
.buildRequest()
.post();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
const answer = {
callbackUri: 'https://bot.contoso.com/api/calls',
acceptedModalities: [ 'audio' ],
mediaConfig: {
'@odata.type': '#microsoft.graph.serviceHostedMediaConfig',
preFetchMedia: [
{
uri: 'https://cdn.contoso.com/beep.wav',
resourceId: '1D6DE2D4-CD51-4309-8DAA-70768651088E'
},
{
uri: 'https://cdn.contoso.com/cool.wav',
resourceId: '1D6DE2D4-CD51-4309-8DAA-70768651088F'
}
]
}
};
await client.api('/communications/calls/57DAB8B1894C409AB240BD8BEAE78896/answer')
.post(answer);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AnswerPostRequestBody();
$requestBody->setCallbackUri('https://bot.contoso.com/api/calls');
$requestBody->setAcceptedModalities([new Modality('audio'), ]);
$mediaConfig = new ServiceHostedMediaConfig();
$mediaConfig->setOdataType('#microsoft.graph.serviceHostedMediaConfig');
$preFetchMediaMediaInfo1 = new MediaInfo();
$preFetchMediaMediaInfo1->setUri('https://cdn.contoso.com/beep.wav');
$preFetchMediaMediaInfo1->setResourceId('1D6DE2D4-CD51-4309-8DAA-70768651088E');
$preFetchMediaArray []= $preFetchMediaMediaInfo1;
$preFetchMediaMediaInfo2 = new MediaInfo();
$preFetchMediaMediaInfo2->setUri('https://cdn.contoso.com/cool.wav');
$preFetchMediaMediaInfo2->setResourceId('1D6DE2D4-CD51-4309-8DAA-70768651088F');
$preFetchMediaArray []= $preFetchMediaMediaInfo2;
$mediaConfig->setPreFetchMedia($preFetchMediaArray);
$requestBody->setMediaConfig($mediaConfig);
$graphServiceClient->communications()->calls()->byCallId('call-id')->answer()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Import-Module Microsoft.Graph.CloudCommunications
$params = @{
callbackUri = "https://bot.contoso.com/api/calls"
acceptedModalities = @(
"audio"
)
mediaConfig = @{
"@odata.type" = "#microsoft.graph.serviceHostedMediaConfig"
preFetchMedia = @(
)
}
}
Invoke-MgAnswerCommunicationCall -CallId $callId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(request_adapter)
request_body = AnswerPostRequestBody(
callback_uri = "https://bot.contoso.com/api/calls",
accepted_modalities = [
Modality.Audio,
]
media_config = ServiceHostedMediaConfig(
odata_type = "#microsoft.graph.serviceHostedMediaConfig",
pre_fetch_media = [
MediaInfo(
uri = "https://cdn.contoso.com/beep.wav",
resource_id = "1D6DE2D4-CD51-4309-8DAA-70768651088E",
),
MediaInfo(
uri = "https://cdn.contoso.com/cool.wav",
resource_id = "1D6DE2D4-CD51-4309-8DAA-70768651088F",
),
]
),
)
await graph_client.communications.calls.by_call_id('call-id').answer.post(body = request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
HTTP/1.1 202 Accepted
Notification - establishing
POST https://bot.contoso.com/api/calls
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.commsNotifications",
"value": [
{
"@odata.type": "#microsoft.graph.commsNotification",
"changeType": "updated",
"resourceUrl": "/communications/calls/57DAB8B1894C409AB240BD8BEAE78896",
"resourceData": {
"@odata.type": "#microsoft.graph.call",
"@odata.id": "/communications/calls/57DAB8B1894C409AB240BD8BEAE78896",
"@odata.etag": "W/\"5445\"",
"state": "establishing"
}
}
]
}
Note: Call establishing/established notifications may arrive out of order.
Notification - established
POST https://bot.contoso.com/api/calls
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.commsNotifications",
"value": [
{
"@odata.type": "#microsoft.graph.commsNotification",
"changeType": "updated",
"resourceUrl": "/communications/calls/57DAB8B1894C409AB240BD8BEAE78896",
"resourceData": {
"@odata.type": "#microsoft.graph.call",
"@odata.id": "/communications/calls/57DAB8B1894C409AB240BD8BEAE78896",
"@odata.etag": "W/\"5445\"",
"state": "established"
}
}
]
}
Note: Call establishing/established notifications may arrive out of order.
Notification - incoming
POST https://bot.contoso.com/api/calls
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.commsNotifications",
"value": [
{
"@odata.type": "#microsoft.graph.commsNotification",
"changeType": "created",
"resourceUrl": "/communications/calls/57DAB8B1894C409AB240BD8BEAE78896",
"resourceData": {
"@odata.type": "#microsoft.graph.call",
"@odata.id": "/communications/calls/57DAB8B1894C409AB240BD8BEAE78896",
"@odata.etag": "W/\"5445\"",
"state": "incoming",
"direction": "incoming",
"source": {
"@odata.type": "#microsoft.graph.participantInfo",
"identity": {
"user": {
"displayName": "Test User",
"id": "8A34A46B-3D17-4ADC-8DCE-DC4E7D572698"
}
},
"region": "westus",
"languageId": "en-US"
},
"targets": [
{
"@odata.type": "#microsoft.graph.invitationParticipantInfo",
"identity": {
"application": {
"displayName": "Test BOT",
"id": "8A34A46B-3D17-4ADC-8DCE-DC4E7D572698"
}
}
}
],
"requestedModalities": [ "audio" ]
}
}
]
}
Request
POST /communications/calls/57DAB8B1894C409AB240BD8BEAE78896/answer
Content-Type: application/json
{
"callbackUri": "https://bot.contoso.com/api/calls",
"acceptedModalities": [ "audio" ],
"mediaConfig": {
"@odata.type": "#microsoft.graph.appHostedMediaConfig",
"blob": "<Media Session Configuration Blob>"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Microsoft.Graph.Communications.Calls.Item.Answer.AnswerPostRequestBody
{
CallbackUri = "https://bot.contoso.com/api/calls",
AcceptedModalities = new List<Modality?>
{
Modality.Audio,
},
MediaConfig = new AppHostedMediaConfig
{
OdataType = "#microsoft.graph.appHostedMediaConfig",
Blob = "<Media Session Configuration Blob>",
},
};
await graphClient.Communications.Calls["{call-id}"].Answer.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc communications calls answer post --call-id {call-id} --body '{\
"callbackUri": "https://bot.contoso.com/api/calls",\
"acceptedModalities": [ "audio" ],\
"mediaConfig": {\
"@odata.type": "#microsoft.graph.appHostedMediaConfig",\
"blob": "<Media Session Configuration Blob>"\
}\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
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
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphcommunications.NewAnswerPostRequestBody()
callbackUri := "https://bot.contoso.com/api/calls"
requestBody.SetCallbackUri(&callbackUri)
acceptedModalities := []graphmodels.Modalityable {
modality := graphmodels.AUDIO_MODALITY
requestBody.SetModality(&modality)
}
requestBody.SetAcceptedModalities(acceptedModalities)
mediaConfig := graphmodels.NewAppHostedMediaConfig()
blob := "<Media Session Configuration Blob>"
mediaConfig.SetBlob(&blob)
requestBody.SetMediaConfig(mediaConfig)
graphClient.Communications().Calls().ByCallId("call-id").Answer().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
String callbackUri = "https://bot.contoso.com/api/calls";
LinkedList<Modality> acceptedModalitiesList = new LinkedList<Modality>();
acceptedModalitiesList.add(Modality.AUDIO);
AppHostedMediaConfig mediaConfig = new AppHostedMediaConfig();
mediaConfig.blob = "<Media Session Configuration Blob>";
graphClient.communications().calls("57DAB8B1894C409AB240BD8BEAE78896")
.answer(CallAnswerParameterSet
.newBuilder()
.withCallbackUri(callbackUri)
.withMediaConfig(mediaConfig)
.withAcceptedModalities(acceptedModalitiesList)
.withParticipantCapacity(null)
.withCallOptions(null)
.build())
.buildRequest()
.post();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
const answer = {
callbackUri: 'https://bot.contoso.com/api/calls',
acceptedModalities: [ 'audio' ],
mediaConfig: {
'@odata.type': '#microsoft.graph.appHostedMediaConfig',
blob: '<Media Session Configuration Blob>'
}
};
await client.api('/communications/calls/57DAB8B1894C409AB240BD8BEAE78896/answer')
.post(answer);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AnswerPostRequestBody();
$requestBody->setCallbackUri('https://bot.contoso.com/api/calls');
$requestBody->setAcceptedModalities([new Modality('audio'), ]);
$mediaConfig = new AppHostedMediaConfig();
$mediaConfig->setOdataType('#microsoft.graph.appHostedMediaConfig');
$mediaConfig->setBlob('<Media Session Configuration Blob>');
$requestBody->setMediaConfig($mediaConfig);
$graphServiceClient->communications()->calls()->byCallId('call-id')->answer()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Import-Module Microsoft.Graph.CloudCommunications
$params = @{
callbackUri = "https://bot.contoso.com/api/calls"
acceptedModalities = @(
"audio"
)
mediaConfig = @{
"@odata.type" = "#microsoft.graph.appHostedMediaConfig"
blob = "<Media Session Configuration Blob>"
}
}
Invoke-MgAnswerCommunicationCall -CallId $callId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(request_adapter)
request_body = AnswerPostRequestBody(
callback_uri = "https://bot.contoso.com/api/calls",
accepted_modalities = [
Modality.Audio,
]
media_config = AppHostedMediaConfig(
odata_type = "#microsoft.graph.appHostedMediaConfig",
blob = "<Media Session Configuration Blob>",
),
)
await graph_client.communications.calls.by_call_id('call-id').answer.post(body = request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
HTTP/1.1 202 Accepted
Notification - establishing
POST https://bot.contoso.com/api/calls
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.commsNotifications",
"value": [
{
"@odata.type": "#microsoft.graph.commsNotification",
"changeType": "updated",
"resourceUrl": "/communications/calls/57DAB8B1894C409AB240BD8BEAE78896",
"resourceData": {
"@odata.type": "#microsoft.graph.call",
"@odata.id": "/communications/calls/57DAB8B1894C409AB240BD8BEAE78896",
"@odata.etag": "W/\"5445\"",
"state": "establishing"
}
}
]
}
Note: Call establishing/established notifications may arrive out of order.
Notification - established
POST https://bot.contoso.com/api/calls
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.commsNotifications",
"value": [
{
"@odata.type": "#microsoft.graph.commsNotification",
"changeType": "updated",
"resourceUrl": "/communications/calls/57DAB8B1894C409AB240BD8BEAE78896",
"resourceData": {
"@odata.type": "#microsoft.graph.call",
"@odata.id": "/communications/calls/57DAB8B1894C409AB240BD8BEAE78896",
"@odata.etag": "W/\"5445\"",
"state": "established"
}
}
]
}
Note: Call establishing/established notifications may arrive out of order.
Notification - content sharing started
POST https://bot.contoso.com/api/calls
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.commsNotifications",
"value": [
{
"@odata.type": "#microsoft.graph.commsNotification",
"changeType": "created",
"resourceUrl": "/communications/calls/421f4c00-4436-4c3a-9d9a-c4924cf98e67/contentsharingsessions/2765eb15-01f8-47c6-b12b-c32111a4a86f"
}
]
}
Notification - content sharing ended
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/421f4c00-4436-4c3a-9d9a-c4924cf98e67/contentsharingsessions/2765eb15-01f8-47c6-b12b-c32111a4a86f"
}
]
}
Example 3: Answer a policy-based recording call
Under the Policy-based recording scenario , before a participant under policy joins a call, an incoming call notification will be sent to the bot associated with the policy.
The join information can be found under the botData property. The bot can then choose to answer the call and update the recording status accordingly.
When participantCapacity
is specified in the Answer
request for a policy-based recording notification, subsequent participant joining event belonging to the same policy group will be sent out as participantJoiningNotification instead of
new incoming call notification, until number of participants that current call instance is handling has reached the number specified in participantCapacity
.
The following is an example of the incoming call notification that a bot would receive in this case.
{
"@odata.type":"#microsoft.graph.commsNotifications",
"value":[
{
"@odata.type":"#microsoft.graph.commsNotification",
"changeType":"created",
"resource":"/app/calls/e71f0300-9c1f-4d99-b5f4-2722e877d497",
"resourceUrl":"/communications/calls/e71f0300-9c1f-4d99-b5f4-2722e877d497",
"resourceData":{
"@odata.type":"#microsoft.graph.call",
"state":"incoming",
"direction":"incoming",
"source":{
"@odata.type":"#microsoft.graph.participantInfo",
"id":"90fad2ce-8989-41a1-8a66-f6636e629a2a",
"identity":{
"@odata.type":"#microsoft.graph.identitySet",
"user":{
"@odata.type":"#microsoft.graph.identity",
"id":"8A34A46B-3D17-4ADC-8DCE-DC4E7D572698",
"identityProvider":"AAD"
}
},
"endpointType":"default",
"region":"amer"
},
"targets":[
{
"@odata.type":"#microsoft.graph.invitationParticipantInfo",
"identity":{
"@odata.type":"#microsoft.graph.identitySet",
"applicationInstance":{
"@odata.type":"#microsoft.graph.identity",
"id":"832899f8-2ea1-4604-8413-27bd2892079f",
"identityProvider":"AAD"
}
},
"endpointType":"default",
"id":"4520a1a5-5394-5a41-aa12-9ee6fa18cfc8",
"region":null,
"languageId":null
}
],
"meetingInfo":{
"@odata.type":"#microsoft.graph.tokenMeetingInfo",
"token":"join token"
},
"tenantId":"932899f8-2ea1-4604-8413-27bd2892079f",
"myParticipantId":"1520a1a5-5394-4a41-aa72-9ee6fa18cfc8",
"callChainId":"05f2f70f-3a9c-47c1-80a9-cc79e91d8cec",
"incomingContext":{
"@odata.type":"#microsoft.graph.incomingContext",
"sourceParticipantId":"30fad2ce-8989-41a1-8a66-f6636e629a2a",
"observedParticipantId":"30fad2ce-8989-41a1-8a66-f6636e629a2a"
},
"id":"e71f0300-9c1f-4d99-b5f4-2722e877d497",
"applicationMetadata":{
"botData":{
"mediaHostedRegion":"USEA",
"user":{
"participationMethod":"callee",
"clientLocation":"US"
},
"otherSideUser":{
"id":"971f0300-9c1f-4d99-b5f4-2722e877d490",
"participantId":"3520a1a5-5394-4a41-aa72-9ee6fa18cfc8",
"tenantId":"1540a1a5-2394-4a41-aa72-9ee6fa18cfc8",
"onBehalfOf":{
"id":"871f0300-9c1f-4d99-b5f4-2722e877d490"
},
"participationMethod":"caller",
"clientLocation":"EUNO"
},
"inviteReasons":[
"PolicyBasedRecording"
],
"policyIdentifier":"Test Policy",
"pairedRecorders":[
{
"id":"471f0300-5c1f-4d99-b5f4-2722e877d490",
"participantId":"371f0300-2c1f-4d99-b5f4-2722e877d490"
}
],
"otherRecorders":[
{
"id":"671f0300-9c1f-4d99-b5f4-2722e877d490",
"participantId":"a71f0300-ec1f-4d99-b5f4-2722e877d490"
}
]
}
}
}
}
]
}