A Cinch plugin to use Wit's natural language processing in your IRC bot
This plugin lets you use Wit’s natural language processing in your Cinch IRC bot.
You will need an access key from Wit in order for this to work.
Add this line to your application’s Gemfile:
gem 'cinch-wit'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cinch-wit
Note: This guide expects you to already have basic familiarity of Cinch and Wit.
After installing the gem, register the plugin in your Cinch bot, like so:
require 'cinch'
require 'cinch/wit'
bot = Cinch::Bot.new do
configure do |c|
c.plugins.plugins << Cinch::Plugins::Wit
c.plugins.options[Cinch::Plugins::Wit][:access_token] = 'YOUR_WIT_ACCESS_TOKEN'
end
# ...
end
You will have to train Wit before doing anything interesting. Here is an example
which handles Wit’s default “Hello” and “Goodbye” intents:
bot = Cinch::Bot.new do
# ...
on :intent do |msg, outcome|
response = case outcome['intent']
when 'hello' then "Hello, #{msg.user}!"
when 'good_bye' then "See you later, #{msg.user}."
end
msg.reply(response) unless response.nil?
end
end
You can also enumerate outcome['entities']
to get the entities, or check the confidence value
with outcome['confidence']
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Copyright © 2013 Justin Workman
MIT License, see LICENSE.txt