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

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

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:



134
135
136
# File 'lib/telnyx/resources/ai/conversations/insights.rb', line 134

def initialize(client:)
  @client = client
end

Instance Method Details

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

Create a new insight

Parameters:

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

    If specified, the output will follow the JSON schema.

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

Returns:

See Also:



26
27
28
29
30
31
32
33
34
35
# File 'lib/telnyx/resources/ai/conversations/insights.rb', line 26

def create(params)
  parsed, options = Telnyx::AI::Conversations::InsightCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "ai/conversations/insights",
    body: parsed,
    model: Telnyx::AI::Conversations::InsightTemplateDetail,
    options: options
  )
end

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

Delete insight by ID

Parameters:

  • insight_id (String)

    The ID of the insight

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

Returns:

  • (nil)

See Also:



122
123
124
125
126
127
128
129
# File 'lib/telnyx/resources/ai/conversations/insights.rb', line 122

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>

Get all insights

Parameters:

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

Returns:

See Also:



98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/telnyx/resources/ai/conversations/insights.rb', line 98

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

Get insight by ID

Parameters:

  • insight_id (String)

    The ID of the insight

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

Returns:

See Also:



48
49
50
51
52
53
54
55
# File 'lib/telnyx/resources/ai/conversations/insights.rb', line 48

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

Update an insight 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:



76
77
78
79
80
81
82
83
84
85
# File 'lib/telnyx/resources/ai/conversations/insights.rb', line 76

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