Class: ElevenlabsClient::Endpoints::AgentsPlatform::Conversations

Inherits:
Object
  • Object
show all
Defined in:
lib/elevenlabs_client/endpoints/agents_platform/conversations.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Conversations

Returns a new instance of Conversations.



7
8
9
# File 'lib/elevenlabs_client/endpoints/agents_platform/conversations.rb', line 7

def initialize(client)
  @client = client
end

Instance Method Details

#delete(conversation_id) ⇒ Hash

DELETE /v1/convai/conversations/conversation_id Delete a particular conversation Documentation: https://elevenlabs.io/docs/api-reference/convai/conversations/delete

Parameters:

  • conversation_id (String)

    The id of the conversation

Returns:

  • (Hash)

    Empty response on success



54
55
56
57
# File 'lib/elevenlabs_client/endpoints/agents_platform/conversations.rb', line 54

def delete(conversation_id)
  endpoint = "/v1/convai/conversations/#{conversation_id}"
  @client.delete(endpoint)
end

#get(conversation_id) ⇒ Hash

GET /v1/convai/conversations/conversation_id Get the details of a particular conversation Documentation: https://elevenlabs.io/docs/api-reference/convai/conversations/get

Parameters:

  • conversation_id (String)

    The id of the conversation

Returns:

  • (Hash)

    Conversation details including transcript and metadata



43
44
45
46
# File 'lib/elevenlabs_client/endpoints/agents_platform/conversations.rb', line 43

def get(conversation_id)
  endpoint = "/v1/convai/conversations/#{conversation_id}"
  @client.get(endpoint)
end

#get_audio(conversation_id) ⇒ String

GET /v1/convai/conversations/conversation_id/audio Get the audio recording of a particular conversation Documentation: https://elevenlabs.io/docs/api-reference/convai/conversations/audio

Parameters:

  • conversation_id (String)

    The id of the conversation

Returns:

  • (String)

    Binary audio data



65
66
67
68
# File 'lib/elevenlabs_client/endpoints/agents_platform/conversations.rb', line 65

def get_audio(conversation_id)
  endpoint = "/v1/convai/conversations/#{conversation_id}/audio"
  @client.get_binary(endpoint)
end

#get_signed_url(agent_id, **options) ⇒ Hash

GET /v1/convai/conversation/get-signed-url Get a signed url to start a conversation with an agent that requires authorization Documentation: https://elevenlabs.io/docs/api-reference/convai/conversations/get-signed-url

Parameters:

  • agent_id (String)

    The id of the agent

  • options (Hash)

    Optional parameters

Options Hash (**options):

  • :include_conversation_id (Boolean)

    Whether to include a conversation_id with the response (default: false)

Returns:

  • (Hash)

    Response containing signed_url



78
79
80
81
82
83
84
85
86
# File 'lib/elevenlabs_client/endpoints/agents_platform/conversations.rb', line 78

def get_signed_url(agent_id, **options)
  endpoint = "/v1/convai/conversation/get-signed-url"
  query_params = { agent_id: agent_id }.merge(options.compact)
  
  query_string = URI.encode_www_form(query_params)
  endpoint_with_query = "#{endpoint}?#{query_string}"
  
  @client.get(endpoint_with_query)
end

#get_token(agent_id, **options) ⇒ Hash

GET /v1/convai/conversation/token Get a WebRTC session token for real-time communication Documentation: https://elevenlabs.io/docs/api-reference/convai/conversations/token

Parameters:

  • agent_id (String)

    The id of the agent

  • options (Hash)

    Optional parameters

Options Hash (**options):

  • :participant_name (String)

    Optional custom participant name

Returns:

  • (Hash)

    Response containing WebRTC token



96
97
98
99
100
101
102
103
104
# File 'lib/elevenlabs_client/endpoints/agents_platform/conversations.rb', line 96

def get_token(agent_id, **options)
  endpoint = "/v1/convai/conversation/token"
  query_params = { agent_id: agent_id }.merge(options.compact)
  
  query_string = URI.encode_www_form(query_params)
  endpoint_with_query = "#{endpoint}?#{query_string}"
  
  @client.get(endpoint_with_query)
end

#list(**options) ⇒ Hash

GET /v1/convai/conversations Get all conversations of agents that user owns Documentation: https://elevenlabs.io/docs/api-reference/convai/conversations/list

Parameters:

  • options (Hash)

    Query parameters

Options Hash (**options):

  • :cursor (String)

    Used for fetching next page

  • :agent_id (String)

    The id of the agent to filter by

  • :call_successful (String)

    The result of the success evaluation ("success", "failure", "unknown")

  • :call_start_before_unix (Integer)

    Unix timestamp to filter conversations up to this start date

  • :call_start_after_unix (Integer)

    Unix timestamp to filter conversations after this start date

  • :user_id (String)

    Filter conversations by the user ID who initiated them

  • :page_size (Integer)

    How many conversations to return at maximum (1-100, default: 30)

  • :summary_mode (String)

    Whether to include transcript summaries ("exclude", "include", default: "exclude")

Returns:

  • (Hash)

    List of conversations with pagination info



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/elevenlabs_client/endpoints/agents_platform/conversations.rb', line 25

def list(**options)
  endpoint = "/v1/convai/conversations"
  query_params = options.compact
  
  if query_params.any?
    query_string = URI.encode_www_form(query_params)
    endpoint = "#{endpoint}?#{query_string}"
  end
  
  @client.get(endpoint)
end

#send_feedback(conversation_id, feedback) ⇒ Hash

POST /v1/convai/conversations/conversation_id/feedback Send the feedback for the given conversation Documentation: https://elevenlabs.io/docs/api-reference/convai/conversations/feedback

Parameters:

  • conversation_id (String)

    The id of the conversation

  • feedback (String)

    Either 'like' or 'dislike' to indicate the feedback

Returns:

  • (Hash)

    Empty response on success



113
114
115
116
117
# File 'lib/elevenlabs_client/endpoints/agents_platform/conversations.rb', line 113

def send_feedback(conversation_id, feedback)
  endpoint = "/v1/convai/conversations/#{conversation_id}/feedback"
  request_body = { feedback: feedback }
  @client.post(endpoint, request_body)
end