Botframework-sdk: Microsoft.Rest.HttpOperationException: The bot referenced by the 'from' field is unrecognized [Facebook channel]

Created on 24 Jul 2018  路  3Comments  路  Source: microsoft/botframework-sdk

Problem with Facebook channel.
Worked fine since yesterday.

Bot Info

  • SDK Platform: .net 4.6
  • project.json:
    {
    "frameworks": {
    "net46":{
    "dependencies": {
    "Autofac": "4.7.0",
    "Newtonsoft.Json": "11.0.2",
    "microsoft.adaptivecards": "0.5.1",
    "Microsoft.Azure.WebJobs": "2.2.0",
    "microsoft.bot.builder.azure": "3.2.5",
    "Microsoft.Cognitive.LUIS": "2.0.2",
    "WindowsAzure.Storage": "9.3.0",
    "System.Net.Http": "4.0.0"
    }
    }
    }
    }

  • Active Channels: Facebook

  • Deployment Environment: Azure Bot Service, Function Bot in consumption plan

Issue Description

Microsoft.Rest.HttpOperationException: The bot referenced by the 'from' field is unrecognized
at Microsoft.Bot.Connector.ErrorHandling.d__2`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.ConversationsExtensions.d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Submission#0.d__29.MoveNext() in D:\home\site\wwwroot\messages\run.csx:line 50

Code Example

var connector = new ConnectorClient(new Uri(activity.ServiceUrl));
Activity typingReply = activity.CreateReply();
typingReply.Type = ActivityTypes.Typing;

//exception will be thrown here
await connector.Conversations.ReplyToActivityAsync(typingReply);

Actual Results

WebChat is working fine
Facebook connection works fine and the bot code will be triggered.
part of the input message:
....
"serviceUrl":"https://facebook.botframework.com","channelId":"facebook","from":{"id":"14148xxxxxxxxxx","name":"Martin xxxxx"},"conversation":
.....

Strange thing is that all works fine for the last months.
But today I got this issue.

Did facebook changed anything?

Any solutions or ideas?

Most helpful comment

Same has just happened to my bot in Telegram, and your answer was helpful.

I went to @BotFather in Telegram and invoked the /revoke command to change the token to access HTTP API.
Then I went to my Functions bot in the Azure Portal, and on Channels blade clicked on "Edit" on my Telegram bot. I pasted the new Access token, saved, and it works again!

Looks like the token somehow expired. I created my bot 355 days ago (Dec 14, 2017), and haven't changed the token since then.

All 3 comments

quick update:

I updated microsoft.bot.builder.azure from "3.2.5" to "3.15.2.2".
Still WebChat and DirectLine are working fine.

From Facebook I got the error message:

Microsoft.Bot.Connector.ErrorResponseException: Operation returned an invalid status code 'BadRequest'
at Microsoft.Bot.Connector.Conversations.d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.ConversationsExtensions.d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Submission#0.d__29.MoveNext() in D:\home\site\wwwroot\messages\run.csx:line 50

My fault:
Somehow my page access token was wrong. The error message was jsut confusing. After going into the step-by-step doc i was able to fix it.

https://docs.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-facebook?view=azure-bot-service-3.0

Same has just happened to my bot in Telegram, and your answer was helpful.

I went to @BotFather in Telegram and invoked the /revoke command to change the token to access HTTP API.
Then I went to my Functions bot in the Azure Portal, and on Channels blade clicked on "Edit" on my Telegram bot. I pasted the new Access token, saved, and it works again!

Looks like the token somehow expired. I created my bot 355 days ago (Dec 14, 2017), and haven't changed the token since then.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RaoVenka picture RaoVenka  路  3Comments

clearab picture clearab  路  3Comments

stijnherreman picture stijnherreman  路  3Comments

Arimov picture Arimov  路  3Comments

Vigneshramkumar picture Vigneshramkumar  路  3Comments