This repository has been archived by the owner on May 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
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.
-
To use context, you'll need a thread:
thread = WitBot.thread
-
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
-
From here, you can set context variables, for example, state:
context.state = 'how_cold'
-
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.
Down here?
Cool.
I should add something somewhat interesting for you to read...
Here's how to get started with wit_bot in 3 steps:
- Learn how to use wit.ai
- Learn how to setup the gem
- Learn how to send a message
- Learn how to use message threads
- Learn how to use context
- Learn how to use conversations
- Learn to use the REPL
- Learn how to use conversations
- Learn how to use participants
- Learn how to use bots