Class: Zavudev::Resources::Calls

Inherits:
Object
  • Object
show all
Defined in:
lib/zavudev/resources/calls.rb,
sig/zavudev/resources/calls.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Calls

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

Parameters:



142
143
144
# File 'lib/zavudev/resources/calls.rb', line 142

def initialize(client:)
  @client = client
end

Instance Method Details

#create(to:, greeting: nil, language: nil, max_duration_minutes: nil, metadata: nil, sender_id: nil, request_options: {}) ⇒ Zavudev::Models::CallCreateResponse

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

Place an outbound voice call answered by the voice agent configured on the sender. Zavu dials the recipient and runs the conversation through its managed voice pipeline (speech recognition, the agent's LLM, and speech synthesis, with real-time interruption handling).

Requirements:

  • The Voice Agents feature must be enabled for your team (otherwise 403).
  • An account that has verified nothing may only call the phone numbers the project has verified (403 with code destination_not_verified, and details.verifiedNumbers lists them), and at most 5 calls a day (429 with code daily_limit_exceeded). A number is verified from the dashboard's Sandbox screen by sending the pre-filled WhatsApp message from that phone; the same verification covers SMS and calls. Verify your identity, add a payment method, settle a deposit or subscribe to call any destination. That raises the ceiling to 50 calls a day on Free; paid plans have no daily call ceiling. Full reference: https://docs.zavu.dev/concepts/sending-limits
  • The sender's agent must have voice.enabled set to true.
  • Not available with test-mode API keys.

Billing: Voice calls are billed per minute of connected time plus telephony, deducted from your prepaid balance. A short-duration estimate is reserved when the call is placed; you are charged for the actual duration when the call ends.

Parameters:

  • to (String) —

    Recipient phone number in E.164 format.

  • greeting (String) —

    Overrides the agent's configured greeting for this call only.

  • language (String) —

    Language the agent speaks on this call only, as a BCP-47 tag (en, es, `es-ES

  • max_duration_minutes (Integer) —

    Overrides the agent's maximum call duration for this call only.

  • metadata (Hash{Symbol=>String}) —

    Arbitrary metadata to associate with the call. Returned on the call object and i

  • sender_id (String) —

    Sender profile that places the call. Uses the project's default sender if omitte

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

Returns:

See Also:



52
53
54
55
56
57
58
59
60
61
# File 'lib/zavudev/resources/calls.rb', line 52

def create(params)
  parsed, options = Zavudev::CallCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/calls",
    body: parsed,
    model: Zavudev::Models::CallCreateResponse,
    options: options
  )
end

#hangup(call_id, request_options: {}) ⇒ Zavudev::Models::CallHangupResponse

End an active voice call. The call must still be ringing or in progress. Not available with test-mode API keys.

Parameters:

Returns:

See Also:



130
131
132
133
134
135
136
137
# File 'lib/zavudev/resources/calls.rb', line 130

def hangup(call_id, params = {})
  @client.request(
    method: :post,
    path: ["v1/calls/%1$s/hangup", call_id],
    model: Zavudev::Models::CallHangupResponse,
    options: params[:request_options]
  )
end

#list(cursor: nil, direction: nil, limit: nil, status: nil, request_options: {}) ⇒ Zavudev::Internal::Cursor<Zavudev::Models::CallListResponse>

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

List voice calls for this project, most recent first. Transcripts are omitted from the list; fetch a single call to get its transcript.

Parameters:

Returns:

See Also:



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/zavudev/resources/calls.rb', line 105

def list(params = {})
  parsed, options = Zavudev::CallListParams.dump_request(params)
  query = Zavudev::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/calls",
    query: query,
    page: Zavudev::Internal::Cursor,
    model: Zavudev::Models::CallListResponse,
    options: options
  )
end

#retrieve(call_id, request_options: {}) ⇒ Zavudev::Models::CallRetrieveResponse

Retrieve a single voice call, including its full transcript once the conversation has produced turns.

Parameters:

Returns:

See Also:



75
76
77
78
79
80
81
82
# File 'lib/zavudev/resources/calls.rb', line 75

def retrieve(call_id, params = {})
  @client.request(
    method: :get,
    path: ["v1/calls/%1$s", call_id],
    model: Zavudev::Models::CallRetrieveResponse,
    options: params[:request_options]
  )
end