Jun 19 2023 08:52 AM
I am trying to create(createConversationAsync) a conversation (dm) in microsoft teams bot framework, but I am getting this error err: RestError: Authorization has been denied for this request
I have created the bot with vscode's extension teams toolkit and I am trying to send a dm to the user when submits a task module, below is the code I am using
import { MessageFactory, TeamsInfo, TurnContext } from "botbuilder"
const BOT_APP_ID = process.env["BOT_ID"]
export async function send_dm(context: TurnContext) {
const user = await TeamsInfo.getMember(context, context.activity.from.id)
const tenantId = context.activity.conversation.tenantId
const channelId = context.activity.channelId
const serviceUrl = context.activity.serviceUrl
const message = MessageFactory.text(`Hello I'm a Teams conversation bot.`)
await context.adapter.createConversationAsync(
BOT_APP_ID,
channelId,
serviceUrl,
BOT_APP_ID,
{
members: [user],
bot: context.activity.recipient,
isGroup: false,
tenantId,
activity: context.activity,
channelData: undefined,
},
async (newContext) => {
await newContext.sendActivity(message)
}
)
}
I have created a test tenant with developer program and I am running my bot in the local with the help of team toolkit vscode extension.
I am attaching my package.json, manifest.json for reference let me know if you need something else
thanks in advance.
Jun 19 2023 09:58 PM
Jun 20 2023 04:32 AM
@Sayali-MSFT also getting the similar error.
Jun 22 2023 03:55 AM - edited Jun 22 2023 03:59 AM
@themashcodee- We have tried the above scenario with the below sample to repro the issue, but it working fine from our end.
Microsoft Teams Version 1.6.00.16971 (64-bit)
Sample Link- Microsoft-Teams-Samples/samples/bot-conversation/nodejs/bots/teamsConversationBot.js at 5e74a4af1739...
Jun 22 2023 04:02 AM
Jun 23 2023 05:55 AM
Jun 26 2023 06:43 AM
Jun 28 2023 12:39 AM - edited Jun 28 2023 12:40 AM
@mrpsycox -Could you please directly add App Id(Instead of
Jun 29 2023 03:45 AM