0

I have a situation where a conversation will initially take place through a web interface I've built in .NET. This will call API.AI chatbot and return the next question for the user to answer. We save all answers in a SQL Server database, and each conversation where these questions are run through, are saved to the database with a unique transaction ID so we can get back to it later.

At any point, the user can continue their conversation in Facebook Messenger. We will not copy the previous conversation to Messenger, but the rest of the conversation will be in messenger, which posts via a Webhook to us, to be passed onto API.AI and saved into our database.

I've read the Facebook documentation, but I cannot see any way of passing my own conversation ID between Facebook and my database.

Is it possible to specify custom metadata through Facebook JSON for the Webhooks API, thus keeping the link between the ID generated on our side and a chat going on in Messenger?

I was hoping to be able to maybe receive something like the below JSON from Facebook (note the custom field 'ConversationID'.

{
    "object":"page",
    "entry":[
        {
            "id":"PAGE_ID",
            "time":1458692752478,
            "ConversationID": "89032478923423",
            "messaging":[
                {
                    "sender":{
                    "id":"USER_ID"
                },
                "recipient":{
                    "id":"PAGE_ID"
                },
            }
        ]
    }
]

}

Mike Upjohn
  • 1,251
  • 2
  • 16
  • 38

1 Answers1

1

Have a look at the metadata field, and the echo callback.

When you send a message to your user, you can fill the metadata field inside the message field with custom metadata. When your webhook is subscribed to message-echo it will receive a message containing the metadata.

MrEbbinghaus
  • 963
  • 7
  • 15