microsoft / BotBuilder-RealTimeMediaCalling

BotBuilder-RealTimeMediaCalling extends the BotBuilder to enable bots to engage in Skype audio-video calling. It provides real-time, programmable access to the voice, video, and screen sharing streams of a Skype call. The bot is a direct participant in a Skype 1:1 call.
MIT License
76 stars 36 forks source link

Can't respond to bot call #44

Closed Githamza closed 5 years ago

Githamza commented 5 years ago

I trying to respond to a call in Teams but actually I'm not getting a respond from the bot.

First I get access_token from Graph API.

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

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.

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".

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.

So I use my POST function to answer. 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.

vinaychandra commented 5 years ago

@Githamza, we are removing the requirement of the initial 204 No Content response for Graph API. Your bot already uses that. Please remove the corresponding logic and retry.

The documentation will shortly be updated to reflect this. For future issues of the graph API, please take a look here.