Facebook Messenger如何与Wit.ai Bot Engine连接?

时间:2016-05-13 23:31:27

标签: bots facebook-messenger wit.ai

在Facebook的文档中,他们引用了wit.ai Bot Engine,但我无法在网上找到解释如何将你在Wit中构建的故事与Facebook Messenger App连接起来的地方?

3 个答案:

答案 0 :(得分:11)

Wit.ai需要输入 - 用户输入。句子,短语,单词 - 给你回分析结果。

首先,当你说"你的Facebook Messenger应用程序" - 您需要确保自己处理信使部分:在服务器上运行您喜欢的语言的代码\您的笔记本电脑可以接收发送到Facebook上的信使帐户的文本。

当你开始工作时,你将不得不使用Wit.ai libraries中的一个代码语言将你从通过信使聊天的用户收到的短语传递给Wit.ai" library& #34;它将把它传达给wit.ai故事"你有并从中获得结果。

例如对于Python:

答案 1 :(得分:4)

您可以将Wit集成到任何消息传递API。例如,使用Messenger Send / Receive API,您将能够从/向Messenger用户接收和接收消息。然后,Wit.ai可以解析消息并预测下一个响应。

以下是Node js中的示例:https://github.com/wit-ai/node-wit/blob/master/examples/messenger.js

答案 2 :(得分:0)

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.