Hi I am trying to send proactive message to MS Teams. I already know the conversationId and serviceUrl which I got from onTeamMembersAddedEvent. When I call /api/notify from browser, I am getting an error, and message is not sent.
Here is the handler on index.js:
const adapter = new BotFrameworkAdapter({
appId: process.env.BotId,
appPassword: process.env.BotPassword
});
server.get('/api/notify', (req, res) => {
let conversationId = "29:1OdRHJr7..."; //90 character value
let serviceUrl = 'https://smba.trafficmanager.net/amer/';
let conversationReference = {
conversation: { id: conversationId },
serviceUrl: serviceUrl
}
adapter.continueConversation(conversationReference, async turnContext => {
MicrosoftAppCredentials.trustServiceUrl(serviceUrl);
await turnContext.sendActivity('Proactively saying **Hello**');
});
res.end();
});
And I am getting following error:
[onTurnError] unhandled error: Error: Authorization has been denied for this request.
(node:62313) UnhandledPromiseRejectionWarning: Error: Authorization has been denied for this request.
at new RestError (/Users/paudelb/Workspace/msteams/Reminder3/node_modules/@azure/ms-rest-js/dist/msRest.node.js:1397:28)
at /Users/paudelb/Workspace/msteams/Reminder3/node_modules/@azure/ms-rest-js/dist/msRest.node.js:1849:37
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:62313) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5)
(node:62313) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
question from:
https://stackoverflow.com/questions/66056129/error-while-sending-proactive-message-to-ms-teams 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…