Class: Telnyx::Resources::AI::Assistants

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/ai/assistants.rb,
lib/telnyx/resources/ai/assistants/tags.rb,
lib/telnyx/resources/ai/assistants/tests.rb,
lib/telnyx/resources/ai/assistants/tools.rb,
lib/telnyx/resources/ai/assistants/versions.rb,
lib/telnyx/resources/ai/assistants/tests/runs.rb,
lib/telnyx/resources/ai/assistants/instructions.rb,
lib/telnyx/resources/ai/assistants/canary_deploys.rb,
lib/telnyx/resources/ai/assistants/scheduled_events.rb,
lib/telnyx/resources/ai/assistants/tests/test_suites.rb,
lib/telnyx/resources/ai/assistants/tests/test_suites/runs.rb,
sig/telnyx/resources/ai/assistants.rbs,
sig/telnyx/resources/ai/assistants/tags.rbs,
sig/telnyx/resources/ai/assistants/tests.rbs,
sig/telnyx/resources/ai/assistants/tools.rbs,
sig/telnyx/resources/ai/assistants/versions.rbs,
sig/telnyx/resources/ai/assistants/tests/runs.rbs,
sig/telnyx/resources/ai/assistants/instructions.rbs,
sig/telnyx/resources/ai/assistants/canary_deploys.rbs,
sig/telnyx/resources/ai/assistants/scheduled_events.rbs,
sig/telnyx/resources/ai/assistants/tests/test_suites.rbs,
sig/telnyx/resources/ai/assistants/tests/test_suites/runs.rbs

Overview

Configure AI assistant specifications

Defined Under Namespace

Classes: CanaryDeploys, Instructions, ScheduledEvents, Tags, Tests, Tools, Versions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Assistants

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Assistants.

Parameters:



450
451
452
453
454
455
456
457
458
459
# File 'lib/telnyx/resources/ai/assistants.rb', line 450

def initialize(client:)
  @client = client
  @tests = Telnyx::Resources::AI::Assistants::Tests.new(client: client)
  @canary_deploys = Telnyx::Resources::AI::Assistants::CanaryDeploys.new(client: client)
  @scheduled_events = Telnyx::Resources::AI::Assistants::ScheduledEvents.new(client: client)
  @tools = Telnyx::Resources::AI::Assistants::Tools.new(client: client)
  @versions = Telnyx::Resources::AI::Assistants::Versions.new(client: client)
  @tags = Telnyx::Resources::AI::Assistants::Tags.new(client: client)
  @instructions = Telnyx::Resources::AI::Assistants::Instructions.new(client: client)
end

Instance Attribute Details

#canary_deploysTelnyx::Resources::AI::Assistants::CanaryDeploys (readonly)

Configure AI assistant specifications



14
15
16
# File 'lib/telnyx/resources/ai/assistants.rb', line 14

def canary_deploys
  @canary_deploys
end

#instructionsTelnyx::Resources::AI::Assistants::Instructions (readonly)

Configure AI assistant specifications



34
35
36
# File 'lib/telnyx/resources/ai/assistants.rb', line 34

def instructions
  @instructions
end

#scheduled_eventsTelnyx::Resources::AI::Assistants::ScheduledEvents (readonly)

Configure AI assistant specifications



18
19
20
# File 'lib/telnyx/resources/ai/assistants.rb', line 18

def scheduled_events
  @scheduled_events
end

#tagsTelnyx::Resources::AI::Assistants::Tags (readonly)

Configure AI assistant specifications



30
31
32
# File 'lib/telnyx/resources/ai/assistants.rb', line 30

def tags
  @tags
end

#testsTelnyx::Resources::AI::Assistants::Tests (readonly)

Configure AI assistant specifications



10
11
12
# File 'lib/telnyx/resources/ai/assistants.rb', line 10

def tests
  @tests
end

#toolsTelnyx::Resources::AI::Assistants::Tools (readonly)

Configure AI assistant specifications



22
23
24
# File 'lib/telnyx/resources/ai/assistants.rb', line 22

def tools
  @tools
end

#versionsTelnyx::Resources::AI::Assistants::Versions (readonly)

Configure AI assistant specifications



26
27
28
# File 'lib/telnyx/resources/ai/assistants.rb', line 26

def versions
  @versions
end

Instance Method Details

#chat(assistant_id, content:, conversation_id:, name: nil, stream: nil, request_options: {}) ⇒ Telnyx::Models::AI::AssistantChatResponse

Some parameter documentations has been truncated, see Models::AI::AssistantChatParams for more details.

This endpoint allows a client to send a chat message to a specific AI Assistant. The assistant processes the message and returns a relevant reply based on the current conversation context. Refer to the Conversation API to create a conversation, filter existing conversations, fetch messages for a conversation, and manually add messages to a conversation.

Parameters:

  • assistant_id (String)

    Unique identifier of the assistant.

  • content (String)

    The message content sent by the client to the assistant

  • conversation_id (String)

    A unique identifier for the conversation thread, used to maintain context

  • name (String)

    The optional display name of the user sending the message

  • stream (Boolean)

    When true, the response is streamed as Server-Sent Events (text/event-stream):

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



305
306
307
308
309
310
311
312
313
314
# File 'lib/telnyx/resources/ai/assistants.rb', line 305

def chat(assistant_id, params)
  parsed, options = Telnyx::AI::AssistantChatParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["ai/assistants/%1$s/chat", assistant_id],
    body: parsed,
    model: Telnyx::Models::AI::AssistantChatResponse,
    options: options
  )
end

#clone_(assistant_id, idempotency_key: nil, request_options: {}) ⇒ Telnyx::Models::AI::InferenceEmbedding

Some parameter documentations has been truncated, see Models::AI::AssistantCloneParams for more details.

Clone an existing assistant, excluding telephony and messaging settings.

Parameters:

  • assistant_id (String)

    Unique identifier of the assistant.

  • idempotency_key (String)

    Optional opaque, unquoted key for safely retrying the same logical request. Keys

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



332
333
334
335
336
337
338
339
340
341
# File 'lib/telnyx/resources/ai/assistants.rb', line 332

def clone_(assistant_id, params = {})
  parsed, options = Telnyx::AI::AssistantCloneParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["ai/assistants/%1$s/clone", assistant_id],
    headers: parsed.transform_keys(idempotency_key: "idempotency-key"),
    model: Telnyx::AI::InferenceEmbedding,
    options: options
  )
end

#create(instructions:, name:, conversation_flow: nil, description: nil, dynamic_variables: nil, dynamic_variables_webhook_timeout_ms: nil, dynamic_variables_webhook_url: nil, enabled_features: nil, external_llm: nil, fallback_config: nil, greeting: nil, insight_settings: nil, integrations: nil, interruption_settings: nil, llm_api_key_ref: nil, mcp_servers: nil, messaging_settings: nil, model: nil, observability_settings: nil, post_conversation_settings: nil, privacy_settings: nil, tags: nil, telephony_settings: nil, tool_ids: nil, tools: nil, transcription: nil, voice_settings: nil, widget_settings: nil, idempotency_key: nil, request_options: {}) ⇒ Telnyx::Models::AI::InferenceEmbedding

Some parameter documentations has been truncated, see Models::AI::AssistantCreateParams for more details.

Creates a new AI assistant from the provided configuration, including its model, instructions, and attached tools, and returns the created assistant.

Parameters:

Returns:

See Also:



107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/telnyx/resources/ai/assistants.rb', line 107

def create(params)
  parsed, options = Telnyx::AI::AssistantCreateParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :post,
    path: "ai/assistants",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Telnyx::AI::InferenceEmbedding,
    options: options
  )
end

#delete(assistant_id, request_options: {}) ⇒ Telnyx::Models::AI::AssistantDeleteResponse

Delete an AI Assistant by assistant_id.

Parameters:

  • assistant_id (String)

    Unique identifier of the assistant.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



267
268
269
270
271
272
273
274
# File 'lib/telnyx/resources/ai/assistants.rb', line 267

def delete(assistant_id, params = {})
  @client.request(
    method: :delete,
    path: ["ai/assistants/%1$s", assistant_id],
    model: Telnyx::Models::AI::AssistantDeleteResponse,
    options: params[:request_options]
  )
end

#get_texml(assistant_id, request_options: {}) ⇒ String

Get an assistant texml by assistant_id.

Parameters:

  • assistant_id (String)

    Unique identifier of the assistant.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (String)

See Also:



354
355
356
357
358
359
360
361
# File 'lib/telnyx/resources/ai/assistants.rb', line 354

def get_texml(assistant_id, params = {})
  @client.request(
    method: :get,
    path: ["ai/assistants/%1$s/texml", assistant_id],
    model: String,
    options: params[:request_options]
  )
end

#imports(api_key_ref:, provider:, import_ids: nil, idempotency_key: nil, request_options: {}) ⇒ Telnyx::Models::AI::AssistantsList

Some parameter documentations has been truncated, see Models::AI::AssistantImportsParams for more details.

Import assistants from external providers. Any assistant that has already been imported will be overwritten with its latest version from the importing provider.

Parameters:

  • api_key_ref (String)

    Body param: Integration secret pointer that refers to the API key for the extern

  • provider (Symbol, Telnyx::Models::AI::AssistantImportsParams::Provider)

    Body param: The external provider to import assistants from.

  • import_ids (Array<String>)

    Body param: Optional list of assistant IDs to import from the external provider.

  • idempotency_key (String)

    Header param: Optional opaque, unquoted key for safely retrying the same logical

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



385
386
387
388
389
390
391
392
393
394
395
396
# File 'lib/telnyx/resources/ai/assistants.rb', line 385

def imports(params)
  parsed, options = Telnyx::AI::AssistantImportsParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :post,
    path: "ai/assistants/import",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Telnyx::AI::AssistantsList,
    options: options
  )
end

#list(request_options: {}) ⇒ Telnyx::Models::AI::AssistantsList

Retrieve a list of all AI Assistants configured by the user.

Parameters:

Returns:

See Also:



247
248
249
250
251
252
253
254
# File 'lib/telnyx/resources/ai/assistants.rb', line 247

def list(params = {})
  @client.request(
    method: :get,
    path: "ai/assistants",
    model: Telnyx::AI::AssistantsList,
    options: params[:request_options]
  )
end

#retrieve(assistant_id, call_control_id: nil, fetch_dynamic_variables_from_webhook: nil, from: nil, to: nil, request_options: {}) ⇒ Telnyx::Models::AI::InferenceEmbedding

Retrieve an AI Assistant configuration by assistant_id.

Parameters:

  • assistant_id (String)

    Unique identifier of the assistant.

  • call_control_id (String)

    Filter results by call control id.

  • fetch_dynamic_variables_from_webhook (Boolean)

    Whether to fetch dynamic variables from the configured webhook.

  • from (String)

    Start of the filter range.

  • to (String)

    End of the filter range.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



139
140
141
142
143
144
145
146
147
148
149
# File 'lib/telnyx/resources/ai/assistants.rb', line 139

def retrieve(assistant_id, params = {})
  parsed, options = Telnyx::AI::AssistantRetrieveParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["ai/assistants/%1$s", assistant_id],
    query: query,
    model: Telnyx::AI::InferenceEmbedding,
    options: options
  )
end

#send_sms(assistant_id, from:, to:, conversation_metadata: nil, should_create_conversation: nil, text: nil, idempotency_key: nil, request_options: {}) ⇒ Telnyx::Models::AI::AssistantSendSMSResponse

Some parameter documentations has been truncated, see Models::AI::AssistantSendSMSParams for more details.

Send an SMS message for an assistant. This endpoint:

  1. Validates the assistant exists and has messaging profile configured
  2. If should_create_conversation is true, creates a new conversation with metadata
  3. Sends the SMS message (If text is set, this will be sent. Otherwise, if this is the first message in the conversation and the assistant has a greeting configured, this will be sent. Otherwise the assistant will generate the text to send.)
  4. Updates conversation metadata if provided
  5. Returns the conversation ID

Parameters:

  • assistant_id (String)

    Path param: Unique identifier of the assistant.

  • from (String)

    Body param

  • to (String)

    Body param

  • conversation_metadata (Hash{Symbol=>String, Integer, Boolean})

    Body param

  • should_create_conversation (Boolean)

    Body param

  • text (String)

    Body param

  • idempotency_key (String)

    Header param: Optional opaque, unquoted key for safely retrying the same logical

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/telnyx/resources/ai/assistants.rb', line 434

def send_sms(assistant_id, params)
  parsed, options = Telnyx::AI::AssistantSendSMSParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :post,
    path: ["ai/assistants/%1$s/chat/sms", assistant_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Telnyx::Models::AI::AssistantSendSMSResponse,
    options: options
  )
end

#update(assistant_id, conversation_flow: nil, description: nil, dynamic_variables: nil, dynamic_variables_webhook_timeout_ms: nil, dynamic_variables_webhook_url: nil, enabled_features: nil, external_llm: nil, fallback_config: nil, greeting: nil, insight_settings: nil, instructions: nil, integrations: nil, interruption_settings: nil, llm_api_key_ref: nil, mcp_servers: nil, messaging_settings: nil, model: nil, name: nil, observability_settings: nil, post_conversation_settings: nil, privacy_settings: nil, promote_to_main: nil, tags: nil, telephony_settings: nil, tool_ids: nil, tools: nil, transcription: nil, version_name: nil, voice_settings: nil, widget_settings: nil, request_options: {}) ⇒ Telnyx::Models::AI::InferenceEmbedding

Some parameter documentations has been truncated, see Models::AI::AssistantUpdateParams for more details.

Updates the specified AI assistant's attributes and returns the updated assistant. The request can also control how the change is promoted across assistant versions.

Parameters:

Returns:

See Also:



227
228
229
230
231
232
233
234
235
236
# File 'lib/telnyx/resources/ai/assistants.rb', line 227

def update(assistant_id, params = {})
  parsed, options = Telnyx::AI::AssistantUpdateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["ai/assistants/%1$s", assistant_id],
    body: parsed,
    model: Telnyx::AI::InferenceEmbedding,
    options: options
  )
end