Class: Telnyx::Resources::AI::Conversations::Insights

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

Overview

Manage historical AI assistant conversations

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Insights

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

Parameters:



144
145
146
# File 'lib/telnyx/resources/ai/conversations/insights.rb', line 144

def initialize(client:)
  @client = client
end

Instance Method Details

#create(instructions:, name:, json_schema: nil, webhook: nil, idempotency_key: nil, request_options: {}) ⇒ Telnyx::Models::AI::Conversations::InsightTemplateDetail

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

Creates a new insight template defining an analysis to run over conversations, and returns the created template.

Parameters:

  • instructions (String)

    Body param

  • name (String)

    Body param

  • json_schema (String, Hash{Symbol=>Object})

    Body param: If specified, the output will follow the JSON schema.

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



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/telnyx/resources/ai/conversations/insights.rb', line 32

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

#delete(insight_id, request_options: {}) ⇒ nil

Permanently deletes the specified insight template by its ID.

Parameters:

  • insight_id (String)

    The ID of the insight

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

Returns:

  • (nil)

See Also:



132
133
134
135
136
137
138
139
# File 'lib/telnyx/resources/ai/conversations/insights.rb', line 132

def delete(insight_id, params = {})
  @client.request(
    method: :delete,
    path: ["ai/conversations/insights/%1$s", insight_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(page_number: nil, page_size: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::AI::Conversations::InsightTemplate>

Returns a paginated list of your insight templates. Insight templates define analyses that run over AI conversations to extract structured findings.

Parameters:

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

Returns:

See Also:



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

def list(params = {})
  parsed, options = Telnyx::AI::Conversations::InsightListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "ai/conversations/insights",
    query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::AI::Conversations::InsightTemplate,
    options: options
  )
end

#retrieve(insight_id, request_options: {}) ⇒ Telnyx::Models::AI::Conversations::InsightTemplateDetail

Returns the details of a single insight template by its ID, including its configuration.

Parameters:

  • insight_id (String)

    The ID of the insight

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

Returns:

See Also:



57
58
59
60
61
62
63
64
# File 'lib/telnyx/resources/ai/conversations/insights.rb', line 57

def retrieve(insight_id, params = {})
  @client.request(
    method: :get,
    path: ["ai/conversations/insights/%1$s", insight_id],
    model: Telnyx::AI::Conversations::InsightTemplateDetail,
    options: params[:request_options]
  )
end

#update(insight_id, instructions: nil, json_schema: nil, name: nil, webhook: nil, request_options: {}) ⇒ Telnyx::Models::AI::Conversations::InsightTemplateDetail

Updates the specified insight template and returns the updated template.

Parameters:

  • insight_id (String)

    The ID of the insight

  • instructions (String)
  • json_schema (String, Hash{Symbol=>Object})
  • name (String)
  • webhook (String)
  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



85
86
87
88
89
90
91
92
93
94
# File 'lib/telnyx/resources/ai/conversations/insights.rb', line 85

def update(insight_id, params = {})
  parsed, options = Telnyx::AI::Conversations::InsightUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["ai/conversations/insights/%1$s", insight_id],
    body: parsed,
    model: Telnyx::AI::Conversations::InsightTemplateDetail,
    options: options
  )
end