class NluAdapter::Adapters::Dialogflow::Intent

Class represents Intent in an IntentCollection

Attributes

id[RW]

Public Class Methods

new(options = {}) click to toggle source

Constructor

# File lib/nlu_adapter/dialogflow.rb, line 116
def initialize(options = {})
        @name = options[:name] #DF.intent.display_name
        @id = options[:id] #DF.intent.name
        @utterences = options[:utterences]
end

Public Instance Methods

to_h() click to toggle source

Convert self to Hash @return [Hash] ruby hash

# File lib/nlu_adapter/dialogflow.rb, line 125
def to_h
        training_phrases = []
        @utterences.each do |u|
                training_phrases << {"type" => "EXAMPLE", "parts" =>[{"text" => u }]}
        end

        {
                name: @id,
                display_name: @name,
                training_phrases: training_phrases
        }
end
to_json() click to toggle source

convert self to json @return [json] json

# File lib/nlu_adapter/dialogflow.rb, line 141
def to_json
        to_h.to_json
end