Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Conversation

Ben edited this page Apr 3, 2016 · 3 revisions

A conversation is a Observable object, which keeps track of a thread. When a message is sent to the conversation, it is first sent to the thread, then to wit.ai, then to listeners as an :input event. When a message is outputted, it is sent to the thread as a bot message, then to listeners as an :output event. For example, a bot will listen for these :input events, do things, and then send an output event. You can use the WitBot::Bot::Conversation::Participant class to make listening to events easier.

To create a conversation, create an instance of WitBot::Bot::Conversation::Base:

conversation = WitBot::Bot::Conversation::Base.new

To send a message, do:

conversation.input "This is a cool test." # Marked as input (a user message)
conversation.output "This is a cool test." # Marked as output (a bot message)
conversation.send_message "This is a cool test." # Marked as input by default, unless 2nd arg is passed, responds to `#bot?`, and `#bot?` evaluates to true.

Getting Started

Here's how to get started with wit_bot in 3 steps:

  1. Learn how to use wit.ai
  2. Learn how to setup the gem
  3. Learn how to send a message

Dive Deeper

Create Bots

Integrate it

Clone this wiki locally