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

Message Threads

Ben edited this page Mar 13, 2016 · 6 revisions

Threads let you group messages together. Think of them like an array of messages.

To create a thread, create a new MessageThread, optionally with a unique id:

thread = WitBot::MessageThread.new #=> WitBot::MessageThread
thread = WitBot::MessageThread.new("12345") #=> WitBot::MessageThread

Or, for convenience:

thread = WitBot.thread #=> WitBot::MessageThread

Now, when creating a message, pass the thread as the first parameter:

message = WitBot::Message.new thread, "This is a cool test."

Or, for convenience:

message = thread.create_message "This is a cool test."

Threads are extremely useful for storing a conversation, and are messages even grouped together in wit.ai logs. With wit_bot, threads also store context information, like state.

Here's an example script taking advantage of threads and context.

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