class |
---|
notes-sea-rocks |
@import "/styles/notes.less"
The watson-assistant-chatbot
is a Ruby gem that provides a chatbot client wrapper for IBM Watson Assistant.
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.
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.
- IBM Watson Assistant instance configured with a skill
-
Getting started with IBM Watson Assistant https://cloud.ibm.com/docs/assistant?topic=assistant-getting-started#getting-started
-
IBM Watson Assistant v2 API documentation https://cloud.ibm.com/apidocs/assistant-v2#send-user-input-to-assistant-stateless
Copyright (c) 2018 - 2020 Julian I. Kamil / @juliankamil
The watson-assistant-chatbot is released under the MIT license, see LICENSE for details.