Julian I. Kamil

etechcetera

Logo
News and opinions on science, technology, and pop culture

Home
About me
Medium
GitHub
Mastodon
Twitter
WeChat
Blogspot
Credly

A Ruby chatbot for IBM Watson Assistant

/ Tags: blog - code - ruby - chatbot - ai - watson

x

Check out this Ruby gem that I created for connecting with Watson Assistant chatbots. Once installed, you can exercise the dialogs that use the intents and entities in your Watson Assistant workspace or skill with just a few lines of code.

Using the Ruby gem

First, install the Ruby gem:

gem install watson-assistant-chatbot

Next, create your chatbot instance, connect it with your Watson Assistant workspace by specifying the user_id, password, workspace_id, and optionally, api_version, and start having a conversation:

require 'watson-assistant-chatbot'
require 'json'

WatsonAssistant::Chatbot.api_version = '2018-02-16'

chatbot = WatsonAssistant::Chatbot.new('<user_id>', '<password>', '<workspace_id>')

request = { "input" => { "text" => "hello" } }

puts chatbot.message(request.to_json)

You can use this gem to quickly add a cognitive chatbot to your Rails or Sinatra web applications.

Get the Ruby source code of the gem from Github.

Learning how to use Watson Assistant

Watson Assistant is IBM’s framework for defining intents, entities, and dialogs to power cognitive chatbots. To learn how to use Watson Assistant to create your chatbot dialogs, follow this tutorial.

More articles

Share your thoughts

A Ruby chatbot for IBM Watson Assistant / April 18, 2018