How does Facebook Messenger connect with Wit.ai Bot Engine?

时间秒杀一切 提交于 2019-12-03 07:50:27

问题


In Facebook's documentation they refer to wit.ai Bot Engine, but I can't find anywhere online where its explained how to connect the Story that you build in Wit with your Facebook Messenger App?


回答1:


Wit.ai needs an input - user input. Sentence, phrase, word - to give you back the analysed results.

So first when you say "your Facebook Messenger app" - you need to make sure you are handling the messenger part by itself: have a code in your language of preference running on the server\your laptop which can receive the text which is sent to the messenger account on Facebook.

When you get that working, you will have to use one of Wit.ai libraries for the code language you are using to pass that phrase you receive from the user chatting through the messenger to Wit.ai "library" which will communicate it "to the wit.ai stories" you have and get the result from them.

For example for Python:

  • Library to handle FB Messenger chatting
  • Wit.ai library to pass the user input "to stories and get result"



回答2:


You can integrate Wit to any messaging API. Using the Messenger Send/Receive API for example, you will be able to get and receive messages from/to Messenger users. Wit.ai can then parse the messages and predict the next response.

Here is an example in Node js: https://github.com/wit-ai/node-wit/blob/master/examples/messenger.js




回答3:


I reviewed the latest updates on wit.ai. It seems that Wit.ai does not have an in-built integration with Facebook Messenger. That is, you can't plug it into Facebook Messenger directly by using the page access tokens etc.

What you'll need to do instead is set up a webhook where Messenger will send callbacks with the details of the user's message. If you want you can enable Facebook's in-built NLP too.

Then inside your webhook, send a call to Wit.ai, and get its output in JSON. Then you must process the JSON and send a reply back to the customer using a Sendmessage API call.

It's a bit long-winded, but if you have this setup, you can potentially use any AI engine in the backend. Including wit.ai or dialogflow.



来源:https://stackoverflow.com/questions/37220796/how-does-facebook-messenger-connect-with-wit-ai-bot-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!