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

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/ai/assistants/scheduled_events.rb,
sig/telnyx/resources/ai/assistants/scheduled_events.rbs

Overview

Configure AI assistant specifications

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ScheduledEvents

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 ScheduledEvents.

Parameters:



151
152
153
# File 'lib/telnyx/resources/ai/assistants/scheduled_events.rb', line 151

def initialize(client:)
  @client = client
end

Instance Method Details

#create(assistant_id, scheduled_at_fixed_datetime:, telnyx_agent_target:, telnyx_conversation_channel:, telnyx_end_user_target:, call_settings: nil, conversation_metadata: nil, dynamic_variables: nil, max_retries_client_errors: nil, retry_interval_secs: nil, text: nil, idempotency_key: nil, request_options: {}) ⇒ Telnyx::Models::AI::Assistants::ScheduledPhoneCallEventResponse, Telnyx::Models::AI::Assistants::ScheduledSMSEventResponse

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

Create a scheduled event for an assistant

Parameters:

  • assistant_id (String)

    Path param: Unique identifier of the assistant.

  • scheduled_at_fixed_datetime (Time)

    Body param: The datetime at which the event should be scheduled. Formatted as IS

  • telnyx_agent_target (String)

    Body param: The phone number, SIP URI, to schedule the call or text from.

  • telnyx_conversation_channel (Symbol, Telnyx::Models::AI::Assistants::ConversationChannelType)

    Body param

  • telnyx_end_user_target (String)

    Body param: The phone number, SIP URI, to schedule the call or text to.

  • call_settings (Telnyx::Models::AI::Assistants::ScheduledCallSettings)

    Body param: Per-call telephony overrides applied when a scheduled phone-call eve

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

    Body param: Metadata associated with the conversation. Telnyx provides several p

  • dynamic_variables (Hash{Symbol=>String})

    Body param: A map of dynamic variable names to values. These variables can be re

  • max_retries_client_errors (Integer)

    Body param: Configure number of retries on client errors: busy, no-answer, faile

  • retry_interval_secs (Integer)

    Body param

  • text (String)

    Body param: Required for sms scheduled events. The text to be sent to the end us

  • 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:



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/telnyx/resources/ai/assistants/scheduled_events.rb', line 45

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

#delete(event_id, assistant_id:, request_options: {}) ⇒ nil

If the event is pending, this will cancel the event. Otherwise, this will simply remove the record of the event.

Parameters:

  • event_id (String)

    Unique identifier of the event.

  • assistant_id (String)

    Unique identifier of the assistant.

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

Returns:

  • (nil)

See Also:



134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/telnyx/resources/ai/assistants/scheduled_events.rb', line 134

def delete(event_id, params)
  parsed, options = Telnyx::AI::Assistants::ScheduledEventDeleteParams.dump_request(params)
  assistant_id =
    parsed.delete(:assistant_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["ai/assistants/%1$s/scheduled_events/%2$s", assistant_id, event_id],
    model: NilClass,
    options: options
  )
end

#list(assistant_id, conversation_channel: nil, from_date: nil, page_number: nil, page_size: nil, to_date: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::AI::Assistants::ScheduledPhoneCallEventResponse, Telnyx::Models::AI::Assistants::ScheduledSMSEventResponse>

Get scheduled events for an assistant with pagination and filtering

Parameters:

  • assistant_id (String)

    Unique identifier of the assistant.

  • conversation_channel (Symbol, Telnyx::Models::AI::Assistants::ConversationChannelType)

    Filter results by conversation channel.

  • from_date (Time)

    Start of the date range filter (inclusive, ISO 8601).

  • page_number (Integer)
  • page_size (Integer)
  • to_date (Time)

    End of the date range filter (inclusive, ISO 8601).

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

Returns:

See Also:



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

def list(assistant_id, params = {})
  parsed, options = Telnyx::AI::Assistants::ScheduledEventListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["ai/assistants/%1$s/scheduled_events", assistant_id],
    query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::Models::AI::Assistants::ScheduledEventListResponse,
    options: options
  )
end

#retrieve(event_id, assistant_id:, request_options: {}) ⇒ Telnyx::Models::AI::Assistants::ScheduledPhoneCallEventResponse, Telnyx::Models::AI::Assistants::ScheduledSMSEventResponse

Returns the details of a single scheduled event configured for the specified assistant.

Parameters:

  • event_id (String)

    Unique identifier of the event.

  • assistant_id (String)

    Unique identifier of the assistant.

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

Returns:

See Also:



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/telnyx/resources/ai/assistants/scheduled_events.rb', line 72

def retrieve(event_id, params)
  parsed, options = Telnyx::AI::Assistants::ScheduledEventRetrieveParams.dump_request(params)
  assistant_id =
    parsed.delete(:assistant_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["ai/assistants/%1$s/scheduled_events/%2$s", assistant_id, event_id],
    model: Telnyx::AI::Assistants::ScheduledEventResponse,
    options: options
  )
end