How to handle 'Forbidden' exception in Teams bot app when trying to send meeting notifications?

68 Views Asked by At

Using the New Teams toolkit for Visual Studio, I created a .Net/C# bot app, starting with the sample of an Echobot which comes with the Teams toolkit for visual studio. Here is the link to my repo for reference to the error and for you to be able to repro the error- https://github.com/messibarbie/Csbot2

In this bot app, I tried adding the functionality of sending meeting notification to targeted users by taking help of this sample (https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/meetings-notification/csharp/InMeetingNotifications) provided by Microsoft where the expected result would have been as shown in the screenshot below- enter image description here

However, when I click the button "Send Notification", I am getting a "forbidden" error. I have attached the detail of the exception below. I added the "OnlineMeetingNotification.Send.Chat" resource specific permission in the manifest to be able to send the notification and information like app id, password were provided using builder.Configuration. Then what is causing the issue here to generate the notification and what does this "Forbidden" status code mean? Is it some authentication issue which is causing this? What is expected from my end to fix this issue? Below I have given the full description of the exception.

Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'Forbidden' at Microsoft.Bot.Connector.Teams.TeamsOperations.SendMeetingNotificationMessageAsync(String meetingId, MeetingNotificationBase notification, Dictionary2 customHeaders, CancellationToken cancellationToken) at Microsoft.Bot.Connector.Teams.TeamsOperationsExtensions.SendMeetingNotificationAsync(ITeamsOperations operations, String meetingId, MeetingNotificationBase notification, CancellationToken cancellationToken) at Microsoft.Bot.Builder.Teams.TeamsInfo.SendMeetingNotificationAsync(ITurnContext turnContext, MeetingNotificationBase notification, String meetingId, CancellationToken cancellationToken) at Csbot2.Bot.EchoBot.HandleActions(ITurnContext1 turnContext, CancellationToken cancellationToken) in C:\Users\x\y\Csbot2\Csbot2\Bot\EchoBot.cs:line 99

Screenshots of my app when trying to send the targeted notification:

enter image description here

enter image description here

0

There are 0 best solutions below