Class: Twilio::REST::Autopilot::V1::AssistantContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/autopilot/v1/assistant.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/task.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/defaults.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/dialogue.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/field_type.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/task/field.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/model_build.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/style_sheet.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/task/sample.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/task/task_actions.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/task/task_statistics.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/field_type/field_value.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: DefaultsContext, DefaultsInstance, DefaultsList, DefaultsPage, DialogueContext, DialogueInstance, DialogueList, DialoguePage, FieldTypeContext, FieldTypeInstance, FieldTypeList, FieldTypePage, ModelBuildContext, ModelBuildInstance, ModelBuildList, ModelBuildPage, QueryContext, QueryInstance, QueryList, QueryPage, StyleSheetContext, StyleSheetInstance, StyleSheetList, StyleSheetPage, TaskContext, TaskInstance, TaskList, TaskPage, WebhookContext, WebhookInstance, WebhookList, WebhookPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ AssistantContext

Initialize the AssistantContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The Twilio-provided string that uniquely identifies the Assistant resource to fetch.


189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant.rb', line 189

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
  @style_sheet = nil
  @defaults = nil
  @dialogues = nil
  @webhooks = nil
end

Instance Method Details

#defaultsDefaultsList, DefaultsContext

Access the defaults


344
345
346
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant.rb', line 344

def defaults
  DefaultsContext.new(@version, @solution[:sid], )
end

#deleteBoolean

Delete the AssistantInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


256
257
258
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant.rb', line 256

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

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

Access the dialogues

Returns:

Raises:

  • (ArgumentError)

352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant.rb', line 352

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:


210
211
212
213
214
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant.rb', line 210

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)

264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant.rb', line 264

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


393
394
395
396
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant.rb', line 393

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

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

Access the model_builds

Returns:

Raises:

  • (ArgumentError)

300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant.rb', line 300

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)

318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant.rb', line 318

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


336
337
338
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant.rb', line 336

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

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

Access the tasks

Returns:

Raises:

  • (ArgumentError)

282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant.rb', line 282

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


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

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

#update(friendly_name: :unset, log_queries: :unset, unique_name: :unset, callback_url: :unset, callback_events: :unset, style_sheet: :unset, defaults: :unset, development_stage: :unset) ⇒ AssistantInstance

Update the AssistantInstance

Parameters:

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

    A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.

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

    Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored.

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

    An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.

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

    Reserved.

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

    Reserved.

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

    The JSON string that defines the Assistant's style sheet

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

    A JSON object that defines the Assistant's default tasks for various scenarios, including initiation actions and fallback tasks.

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

    A string describing the state of the assistant.

Returns:


236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant.rb', line 236

def update(friendly_name: :unset, log_queries: :unset, unique_name: :unset, callback_url: :unset, callback_events: :unset, style_sheet: :unset, defaults: :unset, development_stage: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'LogQueries' => log_queries,
      'UniqueName' => unique_name,
      'CallbackUrl' => callback_url,
      'CallbackEvents' => callback_events,
      'StyleSheet' => Twilio.serialize_object(style_sheet),
      'Defaults' => Twilio.serialize_object(defaults),
      'DevelopmentStage' => development_stage,
  })

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

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

#webhooks(sid = :unset) ⇒ WebhookList, WebhookContext

Access the webhooks

Returns:

Raises:

  • (ArgumentError)

370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant.rb', line 370

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

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

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

  @webhooks
end