Class: NluAdapter::Adapters::Lex::IntentCollection

Inherits:
Object
  • Object
show all
Includes:
NluAdapterIntentCollection
Defined in:
lib/nlu_adapter/lex.rb

Overview

Class represents a collection of Intents

Instance Attribute Summary collapse

Attributes included from NluAdapterIntentCollection

#intents, #name

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ IntentCollection

Constructor



176
177
178
179
180
# File 'lib/nlu_adapter/lex.rb', line 176

def initialize(options = {})
	@name = options[:name]
	@checksum = options[:checksum]
	@intents = options[:intents]
end

Instance Attribute Details

#extraObject

Returns the value of attribute extra.



173
174
175
# File 'lib/nlu_adapter/lex.rb', line 173

def extra
  @extra
end

Instance Method Details

#to_hHash

Convert self to Hash

Returns:

  • (Hash)

    ruby hash



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/nlu_adapter/lex.rb', line 185

def to_h
	intents = []
	@intents.each do |i|
		intents << {
			intent_name: i.name,
			intent_version: '$LATEST'
		}
	end

	{
		name: @name,
		intents: intents,
		locale: "en-US",
		child_directed: false,
		voice_id: "0",
		clarification_prompt: {
			max_attempts: 1,
			messages: [
				{
					content: "I'm sorry, Can you please repeat that?",
					content_type: "PlainText"
				},
				{
					content: "Can you say that again?",
					content_type: "PlainText"
				}
			]
		},
		abort_statement: {
			messages: [
				{
					content: "I don't understand. Can you try again?",
					content_type: "PlainText"
				},
				{
					content: "I'm sorry, I don't understand.",
					content_type: "PlainText"
				}
			]
		},
		checksum: @checksum
	}
end

#to_jsonJson

Convert self to Json

Returns:

  • (Json)

    json



232
233
234
# File 'lib/nlu_adapter/lex.rb', line 232

def to_json
	to_h.to_json
end