Appeler : Répondre

Espace de noms: microsoft.graph

Permettre à un bot de répondre à un appel entrant. La demande d’appel entrant peut être une invitation d’un participant à un appel de groupe ou à un appel pair à pair. Si une invitation à un appel de groupe est reçue, la notification contient les paramètres chatInfo et meetingInfo .

Le bot doit répondre, rejeter ou rediriger l’appel avant l’expiration de l’appel. La valeur de délai d’attente actuelle est de 15 secondes pour les scénarios standard et de 5 secondes pour les scénarios d’enregistrement basés sur des stratégies.

Cette API prend en charge les scénarios RTCP suivants :

  • Appel entrant au numéro PSTN du bot, puis le bot invite un autre RTCP.
  • Appel entrant au numéro PSTN du bot, puis transfert du bot vers un autre RTCP.
  • Appel entrant au numéro PSTN du bot, puis redirection du bot vers un autre RTPC.
  • Appel entrant à l’identificateur d’instance du bot, puis le bot invite un autre RTCP.
  • Appel entrant à l’identificateur d’instance du bot, puis transfert du bot vers un autre RTCP.
  • Appel entrant à l’identificateur d’instance du bot, puis redirection du bot vers un autre RTCP.
  • Appel entrant à l’identificateur d’instance du bot à partir d’une réunion planifiée, puis invitations du bot RTCP.
  • Appel sortant d’un bot (avec l’identificateur d’instance) vers un RTPC.
  • Appel P2P entre le bot et un autre homologue (utilisateur Teams, RTCP), le bot invite un autre RTCP.
  • Appel P2P entre le bot et un autre homologue (utilisateur Teams, RTCP), le bot invite un autre utilisateur Teams.
  • Le bot rejoint la réunion planifiée, puis invite RTCP.

Disponibilité de l’API

Cette API est disponible dans les déploiements cloud nationaux suivants.

Service global Gouvernement américain L4 Gouvernement américain L5 (DOD) Chine exploitée par 21Vianet
✅ ✅ ✅ ❌

Autorisations

Choisissez l’autorisation ou les autorisations marquées comme étant les moins privilégiées pour cette API. Utilisez une ou plusieurs autorisations privilégiées uniquement si votre application en a besoin. Pour plus d’informations sur les autorisations déléguées et d’application, voir Types d’autorisations. Pour en savoir plus sur ces autorisations, consultez la référence des autorisations.

Type d’autorisation Autorisations les moins privilégiées Autorisations à privilèges plus élevés
Déléguée (compte professionnel ou scolaire) Non prise en charge. Non prise en charge.
Déléguée (compte Microsoft personnel) Non prise en charge. Non prise en charge.
Application Calls.JoinGroupCall.All Calls.JoinGroupCallasGuest.All

Remarque : Pour un appel qui utilise un média hébergé par l’application, vous avez également besoin de l’autorisation Calls.AccessMedia.All. Vous devez disposer d’au moins une des autorisations suivantes pour vous assurer que la notification d’appel source entrant est déchiffrée : Calls.AccessMedia.All, Calls.Initiate.All, Calls.InitiateGroupCall.All, Calls.JoinGroupCall.All, Calls.JoinGroupCallAsGuest.All. Il source s’agit des informations sur l’appelant dans la notification d’appel entrant. Sans au moins une de ces autorisations, elles source restent chiffrées.

Requête HTTP

POST /communications/calls/{id}/answer

En-têtes de demande

Nom Description
Autorisation Porteur {token}. Obligatoire. En savoir plus sur l’authentification et les autorisations.
Content-type application/json. Obligatoire.

Corps de la demande

Dans le corps de la demande, indiquez un objet JSON avec les paramètres suivants.

Paramètre Type Description
callbackUri String Permet aux bots de fournir un URI de rappel spécifique pour l’appel simultané afin de recevoir des notifications ultérieures. Si cette propriété n’est pas définie, l’URI de rappel global du bot est utilisé à la place. Je dois être https.
acceptedModalities String collection Liste des modalités acceptées. Les valeurs possibles sont audio, video, videoBasedScreenSharing. Requis pour répondre à un appel.
callOptions incomingCallOptions Options d’appel.
mediaConfig appHostedMediaConfig ou serviceHostedMediaConfig Configuration du média. Obligatoire.
participantCapacity Int32 Nombre de participants que l’application peut gérer pour l’appel, pour le scénario d’enregistrement basé sur une stratégie Teams .

Réponse

Cette méthode renvoie un 202 Accepted code de réponse.

Exemples

L’exemple ci-après montre comment appeler cette API.

Demande

L’exemple suivant illustre la demande.

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,
    "isDeltaRosterEnabled": true,
    "isInteractiveRosterEnabled": true
  },
  "participantCapacity": 200
}

Réponse

L’exemple suivant illustre la réponse.

HTTP/1.1 202 Accepted

Exemple 1 : Répondre à un appel VoIP pair-à-pair avec un média hébergé par le service

Notification - Entrant

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" ]
      }
    }
  ]
}

Demande

POST https://graph.microsoft.com/v1.0/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"
      }
    ]
  }
}

Réponse

HTTP/1.1 202 Accepted

Notification - établissement

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"
      }
    }
  ]
}

Remarque : Les notifications d’établissement d’appel peuvent arriver dans le désordre.

Notification - établie

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"
      }
    }
  ]
}

Remarque : Les notifications d’établissement d’appel peuvent arriver dans le désordre.

Exemple 2 : Répondre à un appel VOIP avec un média hébergé par l’application

Notification - Entrant

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" ]
      }
    }
  ]
}

Demande

POST https://graph.microsoft.com/v1.0/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>"
  }
}

Réponse

HTTP/1.1 202 Accepted

Notification - établissement

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"
      }
    }
  ]
}

Remarque : Les notifications d’établissement d’appel peuvent arriver dans le désordre.

Notification - établie

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"
      }
    }
  ]
}

Remarque : Les notifications d’établissement d’appel peuvent arriver dans le désordre.

Notification - Partage de contenu démarré

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 - Partage de contenu terminé

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"
    }
  ]
}

Exemple 3 : répondre à un appel d’enregistrement basé sur une stratégie

Dans le scénario d’enregistrement basé sur une stratégie, avant qu’un participant sous stratégie ne rejoigne un appel, une notification d’appel entrant est envoyée au bot associé à la stratégie. Les informations de jointure se trouvent sous la propriété botData . Le bot peut alors choisir de répondre à l’appel et de mettre à jour le statut d’enregistrement en conséquence.

Lorsque participantCapacity est spécifié dans la demande de notification d’enregistrement basée sur une Answer stratégie, les événements de participation suivants appartenant au même groupe de stratégies sont envoyés en tant que participantJoiningNotification au lieu d’une nouvelle notification d’appel entrant, jusqu’à ce qu’un nombre de participants géré par l’instance d’appel actuelle ait atteint le nombre spécifié dans participantCapacity.

Voici un exemple de notification d’appel entrant qu’un bot recevrait dans ce cas.

{
   "@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"
                     }
                  ]
               }
            }
         }
      }
   ]
}