question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bot fails to send a message to a user

See original GitHub issue

We were testing out Company Communicator to a small group before business wide roll out, and found that one of the bot was unable to send messages to one user.

We have ensured that the user has the right App Setup policy and Permission Policy. The user was also able to see in the “Company Communicator User” app installed and this was again verified via Graph.

We had also tried to remove and readd the user into the policies but in vain. Any help is much appreciated.

Please see the error details below.

Status Reason : 403 Failed Error:

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"> <head> <meta name=ProgId content=Excel.Sheet> <meta name=Generator content="Microsoft Excel 15"> <link id=Main-File rel=Main-File href="file:///C:/Users/SREERA~1.RAM/AppData/Local/Temp/msohtmlclip1/01/clip.htm"> <link rel=File-List href="file:///C:/Users/SREERA~1.RAM/AppData/Local/Temp/msohtmlclip1/01/clip_filelist.xml"> <style> </style> </head> <body link="#0563C1" vlink="#954F72">
Microsoft.Bot.Schema.ErrorResponseException: Operation returned an invalid status code ‘Forbidden’    at Microsoft.Bot.Connector.Conversations.ReplyToActivityWithHttpMessagesAsync(String conversationId, String activityId, Activity activity, Dictionary2 customHeaders, CancellationToken cancellationToken)    at Microsoft.Bot.Connector.ConversationsExtensions.ReplyToActivityAsync(IConversations operations, String conversationId, String activityId, Activity activity, CancellationToken cancellationToken)    at Microsoft.Bot.Builder.BotFrameworkAdapter.SendActivitiesAsync(ITurnContext turnContext, Activity[] activities, CancellationToken cancellationToken)    at Microsoft.Bot.Builder.TurnContext.<>c__DisplayClass31_0.<<SendActivitiesAsync>g__SendActivitiesThroughAdapter|1>d.MoveNext() --- End of stack trace from previous location where exception was thrown ---    at Microsoft.Bot.Builder.TurnContext.SendActivityAsync(IActivity activity, CancellationToken cancellationToken)    at Microsoft.Teams.Apps.CompanyCommunicator.Common.Services.Teams.MessageService.<>c__DisplayClass3_1.<<SendMessageAsync>b__1>d.MoveNext() in C:\home\site\repository\Source\CompanyCommunicator.Common\Services\Teams\Messages\MessageService.cs:line 94 --- End of stack trace from previous location where exception was thrown ---    at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates1 shouldRetryResultPredicates, Func5 onRetryAsync, Int32 permittedRetryCount, IEnumerable1 sleepDurationsEnumerable, Func4 sleepDurationProvider, Boolean continueOnCapturedContext)    at Polly.AsyncPolicy.ExecuteAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, Boolean continueOnCapturedContext)    at Microsoft.Teams.Apps.CompanyCommunicator.Common.Services.Teams.MessageService.<>c__DisplayClass3_0.<<SendMessageAsync>b__0>d.MoveNext() in C:\home\site\repository\Source\CompanyCommunicator.Common\Services\Teams\Messages\MessageService.cs:line 94
</body> </html>

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
Sreeraj-krollcommented, Nov 21, 2022

Signing out from Teams, then clearing the cache using the attached powershell did the job,

This can be closed … cheers

Teams cache clean.txt

0reactions
gsv022commented, Nov 22, 2022

Thanks for the update. We are closing the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bot 'cannot send messages to this user' · Issue #4112
The user is in the server with my bot and when he tries to execute the command in order for the bot to...
Read more >
Discord.py bot fail to send message after certian amount
It will take a while to send the message to all users, but there's nothing you can do about that. Share.
Read more >
Failed to send error between two users after bot removal
I have two users who, after removing a chat bot from their message thread, cannot directly message each other. They receive a failed...
Read more >
New error code when sending message ...
Two of my bots just started receiving NOT_WHITELISTED_BY_USER_MESSAGE responses from reddit when trying to send a message to a user.
Read more >
Error Codes - Power Virtual Agents
When a bot encounters a problem during a conversation, it will respond with an error message. If you're a bot user, the error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found