简体   繁体   English

使用Graph API响应Microsoft Teams中的漫游器调用

[英]Respond to a bot call in Microsoft Teams with Graph API

I trying to respond to a call in Teams but actually I'm not getting a respond from the bot. 我试图响应Teams中的呼叫,但实际上我没有收到机器人的响应。

First I get access_token from Graph API. 首先,我从Graph API获得access_token。

Then I have a route that intercept bot calls. 然后我有一条拦截机器人呼叫的路由。

app.post("/api/call", function(req, res) {
  if (j === 1) {
    j = j + 1;
    res.status(204).send();
  } else {
    var answerbody = {
      callbackUri: "https://8a73b7ad.ngrok.io/api/call",
      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"
          }
        ]
      }
    };
    POST(
      "https://graph.microsoft.com/beta/" + req.body.resource + "/answer",
      answerbody
    )
      .then(
        data => console.log(data) // I get undefined
      )
      .catch(function(err) {
        console.log("err   " + err);
        res.status(200).send();
      });
  }
});

Here's POST function 这是POST功能

function POST(url, BB) {
  return new Promise(function(resolve, reject) {
    var options = {
      url: url,
      method: "POST",
      headers: {
        Accept: "application/json",
        Authorization: "Bearer " + token
      },
      body: BB,
      json: true
    };
    request(options)
      .then(function(body) {
        resolve(body);
      })
      .catch(function(err) {
        reject(err);
      });
  });
}

As mentionned in documentation , Server sould first reply 204 in order to get response in Graph API protocol. 文档中所述 ,服务器首先响应204,以便在Graph API协议中获得响应。

Actually I don't get a response. 其实我没有得到回应。 Bot still ringing until It gets voice message : " You can't talk to the bot just yet , we are working on it". Bot仍然响起,直到收到语音消息:“您还不能与Bot对话,我们正在研究它”。

As mentioned in Teams API documentation , I should get callback with the ressource id and other information to be able to answer to the call. Teams API文档中所述 ,我应该获得带有资源ID和其他信息的回调,以便能够应答呼叫。

So I use my POST function to answer. 所以我用我的POST函数来回答。 but here I don't get any 202 Accepted response as indicated in docs, instead I get more than one callback with different ressource ids, then after some seconds I get the voice message. 但是在这里我没有得到文档中指示的任何202 Accepted响应,而是获得了多个具有不同资源ID的回调,然后几秒钟后我收到了语音消息。

解决方案是将acceptedModalities: ["audio"]更改为acceptedModalities: ["Audio"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用节点 js 从 Microsoft Bot for Teams 进行 REST API 调用? - How to make a REST API call from Microsoft Bot for Teams using node js? 如何使用 Microsoft Graph 客户端作为其他用户从 Microsoft Teams Bot 发送电子邮件? - How to send email from Microsoft Teams Bot using Microsoft Graph Client as a different user? 如何让应用程序通过 Graph API 向 Microsoft Teams 发送消息? - How to have app send message to Microsoft Teams via Graph API? Microsoft Teams - 深度链接到机器人选项卡 - Microsoft Teams - Deeplink to bot tab Microsoft Graph API calendarView增量终结点未响应初始请求 - Microsoft Graph API calendarView delta endpoint does not respond on initial request Node 和 Microsoft 团队 API - Node and Microsoft Teams API Microsoft Teams bot 查找消息发件人 ID - Microsoft Teams bot finding message sender id Microsoft Graph Api / Teams-无法列出频道中的聊天消息(401/403) - Microsoft Graph Api / Teams - Unable to list chat messages in a channel (401 / 403) Microsoft Bot - 节点 SDK:如何在 Microsoft Teams 中提及用户 - Microsoft Bot - Node SDK: How to mention a user in Microsoft Teams MS Teams Bot 邀请呼叫队列作为参与者 - MS Teams Bot invite Call Queue as Participant
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM