Skip to content

juliankamil/watson-assistant-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

class
notes-sea-rocks

@import "/styles/notes.less"

watson-assistant-chatbot

A Ruby Chatbot for IBM Watson Assistant

Gem Version

The watson-assistant-chatbot is a Ruby gem that provides a chatbot client wrapper for IBM Watson Assistant.

Installation

To install watson-assistant-chatbot, run:

gem install watson-assistant-chatbot

If not present, the above command will also install rest-client and json gems.

Usage

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

# get a chatbot instance
chatbot = WatsonAssistant::Chatbot.new_with_api_key('workspace_id', 'api_key')

# set a request with an utterance
request = { "input" => { "text" => "hello" } }

# send the request and get the json results
results = chatbot.message(request.to_json)

# display the chatbot response text
puts chatbot.response_text(results)

In the above example, results is a JSON object containing the "output" and "context" returned by IBM Watson Assistant.

{
    "output": { "intents": [], "entities": [], ... },
    "context": { ... }
}

See IBM Watson Assistant v2 API documentation for more details on this response object.

Prerequisites

  • IBM Watson Assistant instance configured with a skill

References

Credits

Copyright (c) 2018 - 2020 Julian I. Kamil / @juliankamil

License

The watson-assistant-chatbot is released under the MIT license, see LICENSE for details.