Project

dialogue

0.0
No commit activity in last 3 years
No release in over 3 years
Define and start conversations in Ruby for Slack bots.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

Dialogue

Gem Version

Codeship Status for tatsuio/dialogue

DESCRIPTION

A DSL for defining conversations and workflows in Ruby. The conversations follow those workflows based on incoming messages and their intents.

This currently supports only Slack.

Defining conversations

A conversation can be defined inline or within a ConversationRouter.

A conversation wraps the message and is comprised of several handlers. Each ConversationHandler defines the intent as well as a callback that get's called when that intent is reached.

Defining conversations inline

Dialogue::ConversationTemplate.build(:order_shirt) do |conversation|
  conversation.ask("What size do you wear?") do |response, conversation|
    conversation.reply("Gotcha. Size #{response}. Noted.")
    conversation.ask("What color would you like?") do |response, conversation|
      conversation.reply("Great. I have you down for a #{response}.")
      conversation.end("Thank you for your order.")
    end
  end
end.register

You can reply to the conversation or ask the participant a question.

You can move onto a different conversation thread with a diverge followed by the name of the conversation.

conversation.diverge :end_order

You start a conversation which will store a user, a channel, and the conversation id. This is the placeholder for the conversation.

You can end a conversation which will clear the conversation from the storage mechanism.

A conversation can timeout.

Defining conversations within a router

Starting a conversation

A message comes in from somewhere and you can handle that message in a conversation. A message has a user_id and a channel_id along with some text. If the message matches one of the stored conversations (meaning the user id and channel id match), then the conversation is continued where it left off. If the conversation is not found, then a new conversation is started.

Dialogue.find_template(:select_size).start message
Dialogue.handle(message) # Will find a template based on intent of the message

This will register the conversation for the user and channel with the factory and activate the conversation.

TODO:

  • Add DSL to Dialogue that allows you to specify templates with a name, a list of intents, and a template
  • Implement ConversationHandler that handles a message based on an intent
  • Add pluggable intent handlers (Api.ai, Wit.ai, etc)
  • Implement ConversationRouter
  • Add timeouts for conversations
  • Add support for Facebook
  • Add support for persistent conversations (serializable proc)

RELEASING A NEW GEM

  1. Bump the VERSION in lib/dialogue/version.rb
  2. Commit changes and push to GitHub
  3. run bundle exec rake release

LICENSE

Copyright (c) 2016, Tatsu, Inc..

This project is licensed under the MIT License.