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/query.rb,
lib/twilio-ruby/rest/preview/understand/assistant/intent.rb,
lib/twilio-ruby/rest/preview/understand/assistant/field_type.rb,
lib/twilio-ruby/rest/preview/understand/assistant/model_build.rb,
lib/twilio-ruby/rest/preview/understand/assistant/intent/field.rb,
lib/twilio-ruby/rest/preview/understand/assistant/intent/sample.rb,
lib/twilio-ruby/rest/preview/understand/assistant/field_type/field_value.rb,
lib/twilio-ruby/rest/preview/understand/assistant/intent/intent_statistics.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: FieldTypeContext, FieldTypeInstance, FieldTypeList, FieldTypePage, IntentContext, IntentInstance, IntentList, IntentPage, ModelBuildContext, ModelBuildInstance, ModelBuildList, ModelBuildPage, QueryContext, QueryInstance, QueryList, QueryPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ AssistantContext

Initialize the AssistantContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The sid



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

def initialize(version, sid)
  super(version)

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

  # Dependents
  @field_types = nil
  @intents = nil
  @model_builds = nil
  @queries = nil
end

Instance Method Details

#deleteBoolean

Deletes the AssistantInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



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

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

#fetchAssistantInstance

Fetch a AssistantInstance

Returns:



208
209
210
211
212
213
214
215
216
217
218
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 208

def fetch
  params = Twilio::Values.of({})

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

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

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

Access the field_types

Returns:

Raises:

  • (ArgumentError)


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

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

#intents(sid = :unset) ⇒ IntentList, IntentContext

Access the intents

Returns:

Raises:

  • (ArgumentError)


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

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

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

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

  @intents
end

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

Access the model_builds

Returns:

Raises:

  • (ArgumentError)


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

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)


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

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

#to_sObject

Provide a user friendly representation



335
336
337
338
# File 'lib/twilio-ruby/rest/preview/understand/assistant.rb', line 335

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, response_url: :unset, callback_url: :unset, callback_events: :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.

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

    The webhook URL called to fetch the response to an incoming communication expressed in Assistant TwiML.

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

    The callback_url

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

    The callback_events

Returns:



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

def update(friendly_name: :unset, log_queries: :unset, unique_name: :unset, response_url: :unset, callback_url: :unset, callback_events: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'LogQueries' => log_queries,
      'UniqueName' => unique_name,
      'ResponseUrl' => response_url,
      'CallbackUrl' => callback_url,
      'CallbackEvents' => callback_events,
  })

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

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