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

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?

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"

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

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.

Related

How to notice that a message sent to dialogflow is longer than 256 characters?

I made a facebook chatbot with dialogflow. My problem is that some users write messages to my bot that are longer than 256 characters.
Dialogflow just throws an error that the character size exceeded. As the result, the user has no answer.
I don't expect dialogflow to process the input. I just want to get this information in my backend, so I can send the user to the live chat.
Please, say me it is possible (and how ;) ).
By following this you will be able to set the custom webhook => Webhook setup
Make this server live with Ngrok with temporary later on you can migrate to your server
Now you will get event in which you will find your message sent from facebook messenger.
you can write simple JS function to send only 256 character to Dialogflow Functions
str.substring(0,255)
and send it to detectIntent in dialogflow function.

Dialogflow- chatbot related queries

I've created a basic app with a chatbot that can respond to what I type using DialogFlow and Angular. It is hosted locally. Now I want to have that chatbot respond to what I type with cards, lists and such. Like how Messenger has templates. I want to have a custom payload sent to me in response to what I send. Can anyone please help me? (NOTE: iam using the v2api)
Dialogflow supports rich message response to only certain platforms that it has listed on its website for ex. Facebook, google assistance etc. To display rich message you need to code it out.

Change Dialogflow chatbot language in Facebook Messenger

How to test the multilingual chatbot integrated to Facebook messenger, Dialogflow always uses English(Default language) when integrated to FB messenger.
I tried to changed the facebook profile settings also, but still it is not recognizing the other languages other than the English.
So, How to test/work with multilingual chatbot in Facebook messenger?
Thanks in Advance.
~ Praz Solver
I´m actually after the same thing, I reached DialogFlow support, and they told me this:
Thanks for reaching out to Dialogflow Support.
At the moment, Dialogflow does not yet support multiple languages for any of its built-in integrations - so requests from Facebook Messenger will automatically only be sent to the Default Language of the agent.
However, you can try to make your own implementation for this. You may consider creating a middleware that would serve as a bridge between your Dialogflow agent and your Facebook Messenger bot.
When a user sends a query from Facebook Messenger, your middleware should detect which language was used and then it should send a detectIntent request (https://cloud.google.com/dialogflow/docs/reference/rest/v2/projects.agent.sessions/detectIntent ) to Dialogflow containing both the query and a "languageCode" parameter field with the language tag (https://cloud.google.com/dialogflow/docs/reference/language ) of the end-user's language.
You can use Dialogflow's REST API (https://cloud.google.com/dialogflow/docs/reference/rest/v2-overview ) or client libraries (https://cloud.google.com/dialogflow/docs/reference/libraries/overview ) to integrate your middleware to Dialogflow.
More information about Multilingual Agents can be found at https://cloud.google.com/dialogflow/docs/agents-multilingual .

How to create a chatbot with facebook messenger like templates

I'm trying to create a chatbot for use in a chat app I've created. I basically need the chatbot to send me replies that have message templates like in facebook messenger. For example, If I type in "what's the weather like", I want my chatbot's reply to look like facebook's media template, linked here: Media Template
Does anyone have any tutorials or links I can follow?
Thank you in advance.
Cheers!
Usavaully work flow of chat application as follows,
Message providers(Facebook, twitter,slack etc..) receives messages from user
Message is sent to the configured endpoint(your webserver) according to the settings provided in the face book developer page reference
In the webserver you classify the intent prepares the response according to the request and sends the responses back.
So in the 3rd point web server you give responses based on the platform you are responding to reference, since in your case it's your own platform you need to design your own UI based on the response format or you can use some predefined html templates.
I hope answer gave some direction to work on.

Developing Chat Bot using Wit.aI

I am planning to develop a chatbot using Wit.ai for Android and iOS. I want to have a server where I have the Bot engine. The Bot Engine has several components like Exported application from Wit.ai, calls to weather API, date API etc. When the user sends a message, it is sent to the Wit and it returns back a response. For example, when the user says, "What's the weather in New York, the message is forwarded to Wit which further calls weather API to fetch weather and returns it back to the bot. Bot in turn forwards to app which acts as the presentation layer."
I am planning to use the following to achieve the above:
Heroku to act as the server.
Wit.ai as the NLP
Planning to integrate app with messenger
Since I am new to this kind of programming and architecting, my questions are very basic. Please bear with that. I have the following questions:
Can I have a program uploaded on Heroku which talks to Wit.ai and other APIs? If yes, can someone show a detailed tutorial to call Heroku from app, how to make a call from Heroku to other APIs?
I was advised by some to use Firebase which is Baas. Can I achieve more using that?
With regards,
Suresh
We use the heroku to getting the https url,and if we got that ,we can set up webhook url in developer.facebook.com .
To understand more,follow this tutorial.
Remember when you try to test after you set up all,u need to test ur own account(means cant test every facebook account yet.)
To be public ur messenger bot,u need to wait 5 business days at least.

Resources