Reputation: 1251
I want to send a simple message from a c# application to my Facebook bot created with the Microsoft Bot Framework.
With Skype this works perfeclty, but when I try the Messenger bot I get the following request error:
{
"message": "The 'form' field is unrecognized"
}
I am using the following activity to send the message:
{
"type": "message",
"id": "...",
"timestamp": "2016-09-24T02:47:03.8956722Z",
"serviceUrl": "https://facebook.botframework.com",
"channelId": "facebook",
"from": {
"id": "...",
"name": "..."
},
"conversation": {
"id": "..."
},
"recipient": {
"id": "...",
"name": "..."
},
"text": "Hy, from remote!",
"channelData": {
"sender": {
"id": "..."
},
"recipient": {
"id": "..."
},
"timestamp": 1474685223681,
"message": {
"mid": "...",
"seq": 35,
"text": "Testtest"
}
} }
So the 'from' field is actually here.
When I delete the 'from' field, The request message says that it is required, so it somehow recognizes the field. Maybe it is just formatted the wrong way.
So how can I get this to work?
Upvotes: 1
Views: 189
Reputation: 5234
Try to build the message with fewer arguments.
For Facebook you need the from field for some reason but you do not have to supply all the other parameters.
Try the following request:
{
"type": "message",
"textFormat": "plain",
"text": "Hello messenger!",
"from":
{
"id": "your-id-from-recipient-id-in-the-message-received",
"name": "your-name-from-recipient-name-in-the-message-received"
}
}
It is important to use exactly the id and the name you received when the user sent a message.
The data can be extracted from a message like this that was sent to the bot:
{
"type": "message",
"id": "<snip>",
"timestamp": "2017-01-06T14:09:36.8882093Z",
"serviceUrl": "https://facebook.botframework.com",
"channelId": "facebook",
"from": {
"id": "<snip>",
"name": "<snip>"
},
"conversation": {
"isGroup": false,
"id": "<snip>"
},
"recipient": {
"id": "your-id-from-recipient-id-in-the-message-received",
"name": "your-name-from-recipient-name-in-the-message-received"
},
<snip>
}
Upvotes: 2