Class: Twilio::REST::Preview::Understand::AssistantContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/understand/assistant.rb,
lib/twilio-ruby/rest/preview/understand/assistant/task.rb,
lib/twilio-ruby/rest/preview/understand/assistant/query.rb,
lib/twilio-ruby/rest/preview/understand/assistant/dialogue.rb,
lib/twilio-ruby/rest/preview/understand/assistant/field_type.rb,
lib/twilio-ruby/rest/preview/understand/assistant/task/field.rb,
lib/twilio-ruby/rest/preview/understand/assistant/model_build.rb,
lib/twilio-ruby/rest/preview/understand/assistant/style_sheet.rb,
lib/twilio-ruby/rest/preview/understand/assistant/task/sample.rb,
lib/twilio-ruby/rest/preview/understand/assistant/task/task_actions.rb,
lib/twilio-ruby/rest/preview/understand/assistant/task/task_statistics.rb,
lib/twilio-ruby/rest/preview/understand/assistant/field_type/field_value.rb,
lib/twilio-ruby/rest/preview/understand/assistant/assistant_fallback_actions.rb,
lib/twilio-ruby/rest/preview/understand/assistant/assistant_initiation_actions.rb

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected]

Defined Under Namespace

Classes: AssistantFallbackActionsContext, AssistantFallbackActionsInstance, AssistantFallbackActionsList, AssistantFallbackActionsPage, AssistantInitiationActionsContext, AssistantInitiationActionsInstance, AssistantInitiationActionsList, AssistantInitiationActionsPage, DialogueContext, DialogueInstance, DialogueList, DialoguePage, FieldTypeContext, FieldTypeInstance, FieldTypeList, FieldTypePage, ModelBuildContext, ModelBuildInstance, ModelBuildList, ModelBuildPage, QueryContext, QueryInstance, QueryList, QueryPage, StyleSheetContext, StyleSheetInstance, StyleSheetList, StyleSheetPage, TaskContext, TaskInstance, TaskList, TaskPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ AssistantContext

Initialize the AssistantContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    A 34 character string that uniquely identifies this resource.


192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 192

def initialize(version, sid)
  super(version)

  # Path Solution
  @solution = {sid: sid, }
  @uri = "/Assistants/#{@solution[:sid]}"

  # Dependents
  @field_types = nil
  @tasks = nil
  @model_builds = nil
  @queries = nil
  @assistant_fallback_actions = nil
  @assistant_initiation_actions = nil
  @dialogues = nil
  @style_sheet = nil
end

Instance Method Details

#assistant_fallback_actionsAssistantFallbackActionsList, AssistantFallbackActionsContext

Access the assistant_fallback_actions


339
340
341
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 339

def assistant_fallback_actions
  AssistantFallbackActionsContext.new(@version, @solution[:sid], )
end

#assistant_initiation_actionsAssistantInitiationActionsList, AssistantInitiationActionsContext

Access the assistant_initiation_actions


347
348
349
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 347

def assistant_initiation_actions
  AssistantInitiationActionsContext.new(@version, @solution[:sid], )
end

#deleteBoolean

Delete the AssistantInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


259
260
261
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 259

def delete
   @version.delete('DELETE', @uri)
end

#dialogues(sid = :unset) ⇒ DialogueList, DialogueContext

Access the dialogues

Returns:

Raises:

  • (ArgumentError)

355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 355

def dialogues(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return DialogueContext.new(@version, @solution[:sid], sid, )
  end

  unless @dialogues
    @dialogues = DialogueList.new(@version, assistant_sid: @solution[:sid], )
  end

  @dialogues
end

#fetchAssistantInstance

Fetch the AssistantInstance

Returns:


213
214
215
216
217
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 213

def fetch
  payload = @version.fetch('GET', @uri)

  AssistantInstance.new(@version, payload, sid: @solution[:sid], )
end

#field_types(sid = :unset) ⇒ FieldTypeList, FieldTypeContext

Access the field_types

Returns:

Raises:

  • (ArgumentError)

267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 267

def field_types(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return FieldTypeContext.new(@version, @solution[:sid], sid, )
  end

  unless @field_types
    @field_types = FieldTypeList.new(@version, assistant_sid: @solution[:sid], )
  end

  @field_types
end

#inspectObject

Provide a detailed, user friendly representation


386
387
388
389
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 386

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Preview.Understand.AssistantContext #{context}>"
end

#model_builds(sid = :unset) ⇒ ModelBuildList, ModelBuildContext

Access the model_builds

Returns:

Raises:

  • (ArgumentError)

303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 303

def model_builds(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return ModelBuildContext.new(@version, @solution[:sid], sid, )
  end

  unless @model_builds
    @model_builds = ModelBuildList.new(@version, assistant_sid: @solution[:sid], )
  end

  @model_builds
end

#queries(sid = :unset) ⇒ QueryList, QueryContext

Access the queries

Returns:

Raises:

  • (ArgumentError)

321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 321

def queries(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return QueryContext.new(@version, @solution[:sid], sid, )
  end

  unless @queries
    @queries = QueryList.new(@version, assistant_sid: @solution[:sid], )
  end

  @queries
end

#style_sheetStyleSheetList, StyleSheetContext

Access the style_sheet


373
374
375
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 373

def style_sheet
  StyleSheetContext.new(@version, @solution[:sid], )
end

#tasks(sid = :unset) ⇒ TaskList, TaskContext

Access the tasks

Returns:

Raises:

  • (ArgumentError)

285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 285

def tasks(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return TaskContext.new(@version, @solution[:sid], sid, )
  end

  unless @tasks
    @tasks = TaskList.new(@version, assistant_sid: @solution[:sid], )
  end

  @tasks
end

#to_sObject

Provide a user friendly representation


379
380
381
382
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 379

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Preview.Understand.AssistantContext #{context}>"
end

#update(friendly_name: :unset, log_queries: :unset, unique_name: :unset, callback_url: :unset, callback_events: :unset, fallback_actions: :unset, initiation_actions: :unset, style_sheet: :unset) ⇒ AssistantInstance

Update the AssistantInstance

Parameters:

  • friendly_name (String) (defaults to: :unset)

    A text description for the Assistant. It is non-unique and can up to 255 characters long.

  • log_queries (Boolean) (defaults to: :unset)

    A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided.

  • unique_name (String) (defaults to: :unset)

    A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.

  • callback_url (String) (defaults to: :unset)

    A user-provided URL to send event callbacks to.

  • callback_events (String) (defaults to: :unset)

    Space-separated list of callback events that will trigger callbacks.

  • fallback_actions (Hash) (defaults to: :unset)

    The JSON actions to be executed when the user's input is not recognized as matching any Task.

  • initiation_actions (Hash) (defaults to: :unset)

    The JSON actions to be executed on inbound phone calls when the Assistant has to say something first.

  • style_sheet (Hash) (defaults to: :unset)

    The JSON object that holds the style sheet for the assistant

Returns:


239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 239

def update(friendly_name: :unset, log_queries: :unset, unique_name: :unset, callback_url: :unset, callback_events: :unset, fallback_actions: :unset, initiation_actions: :unset, style_sheet: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'LogQueries' => log_queries,
      'UniqueName' => unique_name,
      'CallbackUrl' => callback_url,
      'CallbackEvents' => callback_events,
      'FallbackActions' => Twilio.serialize_object(fallback_actions),
      'InitiationActions' => Twilio.serialize_object(initiation_actions),
      'StyleSheet' => Twilio.serialize_object(style_sheet),
  })

  payload = @version.update('POST', @uri, data: data)

  AssistantInstance.new(@version, payload, sid: @solution[:sid], )
end