class Api::Flow

Overview

The dialog flow class can be used to easily build complex dialog trees.

To create a dialog flow:

require "hermes-crystal"

# Instantiate hermes
hermes = Hermes.new broker_address: "localhost:1883"
# Initialize a flow
hermes.dialog.flow "intent_name" do |message, flow|
  # Perform actions to perform in the dialogue round.
  flow.continue "next_intent" do |message, flow|
    # ...
  end

  flow.not_recognized do |message, flow|
    # ...
  end

  # Make the text-to-speech talk.
  "Hello world."
end

Included Modules

Defined in:

api/flow.cr

Instance Method Summary

Instance methods inherited from module Bindings

call!(result)
call!(&block)
call!

Instance Method Detail

def continue(intent_name : String, slot_filler : String? = nil, &block : IntentContinuation) #

Mark an intent as a possible continuation for this round of dialog, optionally as a slot filler.


[View source]
def not_recognized(&block : IntentNotRecognizedContinuation) #

Perform a custom action when no intents are recognized for this round of dialog.


[View source]