Reputation: 5235
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.
Upvotes: 0
Views: 801
Reputation: 5235
The solution is to change acceptedModalities: ["audio"]
to acceptedModalities: ["Audio"]
Upvotes: 1