Closed seanbetts closed 5 years ago
Hi @seanbetts, are you able to post what the activity looks like that is being received by the bot? Also, has your bot been working fine under Facebook and only recently produced this error? Or, did you recently build it out for FB?
Hi @stevkan. My bot has been working fine under Facebook until recently. Here's an example of the activity that is bing received by the bot:
var welcomeCardFB = {
channelData: {
attachment: {
type: 'template',
payload: {
template_type: 'generic',
sharable: true,
image_aspect_ratio: 'square',
elements: [
{
title: '👋 Hello ' + userName + '!',
image_url: 'https://mihndbotblob.blob.core.windows.net/resources/MiHNDbot-logo.jpg',
subtitle: "I'm designed to help people learn about Mental Health and NeuroDiversity",
default_action: {
type: 'web_url',
url: 'https://www.mihnd.co.uk',
webview_height_ratio: 'tall'
},
buttons: [
{
type: 'postback',
title: 'Mental Health',
payload: 'WHAT_IS_MENTAL_HEALTH'
}, {
type: 'postback',
title: 'NeuroDiversity',
payload: 'WHAT_IS_NEURODIVERSITY'
}, {
type: 'postback',
title: 'Get Help',
payload: 'GET_HELP'
}] }] } } } };
return welcomeCardFB;
};`
Apologies for the delay. I'm assuming you are sending that card from the bot? Can you capture and post an actual activity object? Also, do you have a date and time when this error occurred?
I should add that a 500 error usually denotes a problem with the bot's code.
So, I recreated the card and received it back as an activity which I have included below. The conversation id is normally recorded under conversation
and the role under recipient
. For one reason or another, I suspect your bot lost the context and, subsequently, didn't have an id which meant it couldn't apply a value to role. This resulted in the the error detailing your missing conversation id and undefined role.
If you can provide the date/time of the error, I can try and see if there was a service hiccup at that time that might have resulted in your bot failing. But, again, 500 errors are usually internal related.
{
"direction": "incoming",
"activity": {
"channelData": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"sharable": true,
"image_aspect_ratio": "square",
"elements": [
{
"title": "👋 Hello Steve!",
"image_url": "https://mihndbotblob.blob.core.windows.net/resources/MiHNDbot-logo.jpg",
"subtitle": "I'm designed to help people learn about Mental Health and NeuroDiversity",
"default_action": {
"type": "web_url",
"url": "https://www.mihnd.co.uk",
"webview_height_ratio": "tall"
},
"buttons": [
{
"type": "postback",
"title": "Mental Health",
"payload": "WHAT_IS_MENTAL_HEALTH"
},
{
"type": "postback",
"title": "NeuroDiversity",
"payload": "WHAT_IS_NEURODIVERSITY"
},
{
"type": "postback",
"title": "Get Help",
"payload": "GET_HELP"
}
]
}
]
}
}
},
"channelId": "facebook",
"serviceUrl": "https://facebook.botframework.com/",
"conversation": {
"isGroup": false,
"id": "15196xxxxxxxxx37873"
},
"from": {
"id": "2050867055237873",
"name": "v-xxxxxxxxx-bot"
},
"recipient": {
"id": "1519649474831492",
"name": "Steve",
"role": "user"
},
"replyToId": xxxxxxxxx",
"type": "message",
"timestamp": "2019-08-09T00:08:03.517Z"
}
}
Hi @stevkan, thanks for getting back to me. The error was being caused by an issue with my Facebook credentials and it’s all fixed now! Sorry, I should have closed the ticket earlier.
BotFramework Version: 4.4 in JavaScript
Bug Description
When connecting to my chatbot using Facebook Messenger, it's generating an internal server HTTP 500 error. This happens whenever a message is sent from Facebook Messenger (i.e. received by the chatbot).
Steps to Reproduce
Actual Experience
The chatbot works as expected but the error message is appearing in the log files and shows up as an issue in the Facebook channel in the Azure portal.
Additional Context
Here are the error details:
[onTurnError]: TypeError: Cannot read property 'role' of undefined BotFrameworkAdapter.processActivity(): 500 ERROR - Error: BotFrameworkAdapter.sendActivity(): missing conversation id.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
HTTP Error 500.0 - Internal Server Error
The page cannot be displayed because an internal server error has occurred.