How to Build Facebook Chatbots With IBM Watson
A simple bot built on Facebook Messenger that leverages the language capabilities of Watson.
Join the DZone community and get the full member experience.
Join For Freei’ve open sourced a simple sample of a chatbot for facebook that leverages ibm watson dialog and ibm watson natural language classifier for conversations with users.
the github project contains a sample of a facebook bot built on the facebook messenger platform which is currently available as beta. the sample bot is pretty simple but might give people some ideas about how to use cognitive watson services and host the bot on bluemix .
the sample bot shows recent tweets with a positive or negative sentiment about a specific topic via the insights for twitter service. check out the screenshots folder for more information.
the left screenshot shows the usage of the dialog service. the right column shows additionally the natural language classifier. in this example, users can type in ‘awesome’ which is a word that is not hardcoded anywhere.
i’ve implemented the bot via node.js. in order to invoke the action that reads the tweets, i’ve extended the dialog definition with the javascript code which is supposed to be invoked.
<item>alright. here are the {sentiment} tweets about {topic}:$execcode$showtweets(sender, "{topic}", "{sentiment}")</item>
in order to use buttons in the chat, i’ve extended the
dialog
definition with the button data.
rather than clicking on buttons users can also type in text like ‘awesome.’ rather than hardcoding all alternatives, the watson classifier is used to determine whether users are interested in positive or negative tweets. the id of the classifier is defined as part of the dialog definition.
<item>are you interested in positive or negative tweets?$showbuttons$[{"type":"postback","title":"positive","payload":"positive"},{"type":"postback","title":"negative","payload":"negative"}]#3a84cfx63-nlc-5285</item>
Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
How to Submit a Post to DZone
-
Avoiding Pitfalls With Java Optional: Common Mistakes and How To Fix Them [Video]
-
Extending Java APIs: Add Missing Features Without the Hassle
-
Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
Comments