I'm trying to send a proactive message using botframework in Nodejs (Teams channel), but a received 401 error.
I make some searches and I found that the error can be possible with the trust service URL, but I have already done that part.
My adpter config
const {
BotFrameworkAdapter,
} = require('botbuilder');
const { MicrosoftAppCredentials } = require('botframework-connector');
const adapter = new BotFrameworkAdapter({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
})
Send proactive message code
adapter.continueConversation(address, async (t) => {
MicrosoftAppCredentials.trustServiceUrl(process.env.MICROSOFT_BOT_SERVICE_URL);
await t.sendActivity(model.render());
}).then((r) => {
console.log("continue")
console.log(r)
res.status(200).send({
status: "OK"
})
}).catch((e) => {
console.log(e);
res.send("ERRO " + e)
});
Request and response, with my AppId and conversation ID.
statusCode: 401,
> request: WebResource {
> streamResponseBody: false,
> url: 'https://smba.trafficmanager.net/amer/v3/conversations/a%3A1MUpsVB7CH-6BTiSUHxOkMhv05saxu9O7qe0zRNPR04PCvXp-6QzsoYKpT-oykqyJpu8SgbawTkbUDauiBGF9bIeG9qg56Ts6lpEGgY6SSrMMj5YL_K-yxOJ5jjoqIrJQ/activities',
> method: 'POST',
> headers: HttpHeaders { _headersMap: [Object] },
> body: '{"type":"message","serviceUrl":"https://smba.trafficmanager.net/amer/","channelId":"msteams","from":{"id":"c96afa27-addb-4bc8-80fb-c0317380bf1a","name":"Luna"},"conversation":{"id":"a:1MUpsVB7CH-6BTiSUHxOkMhv05saxu9O7qe0zRNPR04PCvXp-6QzsoYKpT-oykqyJpu8SgbawTkbUDauiBGF9bIeG9qg56Ts6lpEGgY6SSrMMj5YL_K-yxOJ5jjoqIrJQ"},"text":"Achei aqui! A OV de número 0001302956","inputHint":"acceptingInput"}',
> query: undefined,
> formData: undefined,
> withCredentials: false,
> abortSignal: undefined,
> timeout: 0,
> onUploadProgress: undefined,
> onDownloadProgress: undefined,
> operationSpec: {
> httpMethod: 'POST',
> path: 'v3/conversations/{conversationId}/activities',
> urlParameters: [Array],
> requestBody: [Object],
> responses: [Object],
> serializer: [Serializer]
> }
> },
> response: {
> body: '{"message":"Authorization has been denied for this request."}',
> headers: HttpHeaders { _headersMap: [Object] },
> status: 401
> },
> body: { message: 'Authorization has been denied for this request.' }
> }