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

Context

Ben edited this page Mar 13, 2016 · 4 revisions

With wit_bot, context is stored in threads - not messages, so you should read up on threads to understand how they work.

Usage

  1. To use context, you'll need a thread:

    thread = WitBot.thread
  2. To access the context on the tread, call its #context method. This gets the context for the thread, or creates a new context object:

    context = thread.context
  3. From here, you can set context variables, for example, state:

    context.state = 'how_cold'
  4. Create a message on the thread and send as normal:

    message = thread.create_message "32 Degrees"
    message.send

You can also do:

message = WitBot.create_message "32 Degrees"
message.thread.context.state = 'how_cold'
message.send

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