Skip to content

Commit

Permalink
feat(api): update via SDK Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Mar 23, 2024
1 parent 7738ebc commit 2aec9f1
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 261 deletions.
12 changes: 2 additions & 10 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
# RegisterCalls

Types:

- <code><a href="./src/resources/register-calls.ts">RegisterCallCreateResponse</a></code>

Methods:

- <code title="post /register-call">client.registerCalls.<a href="./src/resources/register-calls.ts">create</a>({ ...params }) -> RegisterCallCreateResponse</code>

# Calls

Types:

- <code><a href="./src/resources/calls.ts">CallRetrieveResponse</a></code>
- <code><a href="./src/resources/calls.ts">CallListResponse</a></code>
- <code><a href="./src/resources/calls.ts">CallRegisterResponse</a></code>

Methods:

- <code title="get /get-call/{call_id}">client.calls.<a href="./src/resources/calls.ts">retrieve</a>(callId) -> CallRetrieveResponse</code>
- <code title="get /list-calls">client.calls.<a href="./src/resources/calls.ts">list</a>({ ...params }) -> CallListResponse</code>
- <code title="post /register-call">client.calls.<a href="./src/resources/calls.ts">register</a>({ ...params }) -> CallRegisterResponse</code>

# Agents

Expand Down
7 changes: 2 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export class RetellAI extends Core.APIClient {
this.apiKey = apiKey;
}

registerCalls: API.RegisterCalls = new API.RegisterCalls(this);
calls: API.Calls = new API.Calls(this);
agents: API.Agents = new API.Agents(this);
retellLlms: API.RetellLlms = new API.RetellLlms(this);
Expand Down Expand Up @@ -184,14 +183,12 @@ export namespace RetellAI {

export import RequestOptions = Core.RequestOptions;

export import RegisterCalls = API.RegisterCalls;
export import RegisterCallCreateResponse = API.RegisterCallCreateResponse;
export import RegisterCallCreateParams = API.RegisterCallCreateParams;

export import Calls = API.Calls;
export import CallRetrieveResponse = API.CallRetrieveResponse;
export import CallListResponse = API.CallListResponse;
export import CallRegisterResponse = API.CallRegisterResponse;
export import CallListParams = API.CallListParams;
export import CallRegisterParams = API.CallRegisterParams;

export import Agents = API.Agents;
export import AgentCreateResponse = API.AgentCreateResponse;
Expand Down
191 changes: 191 additions & 0 deletions src/resources/calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ export class Calls extends APIResource {
}
return this._client.get('/list-calls', { query, ...options });
}

/**
* Register Call To Get CallId To Establish Connection
*/
register(body: CallRegisterParams, options?: Core.RequestOptions): Core.APIPromise<CallRegisterResponse> {
return this._client.post('/register-call', { body, ...options });
}
}

export interface CallRetrieveResponse {
Expand Down Expand Up @@ -239,6 +246,109 @@ export namespace CallListResponse {
}
}

export interface CallRegisterResponse {
/**
* Corresponding agent id of this call.
*/
agent_id: string;

/**
* The audio encoding of the call. The following formats are supported:
*
* - `s16le` 16 bit linear PCM audio, the native format for web audio capture and
* playback.
*
* - `mulaw` non-linear audio encoding technique used in telephony. Commonly used
* by Twilio.
*/
audio_encoding: 's16le' | 'mulaw';

/**
* Where the audio websocket would connect from would determine the format /
* protocol of websocket messages, and would determine how our server read audio
* bytes and send audio bytes.:
*
* - `web`: The protocol defined by Retell, commonly used for connecting from web
* frontend. Also useful for those who want to manipulate audio bytes directly.
*
* - `twilio`: The
* [websocket protocol](https://www.twilio.com/docs/voice/twiml/stream#message-media)
* defined by Twilio, used when your system uses Twilio, and supplies Retell
* audio websocket url to Twilio.
*/
audio_websocket_protocol: 'web' | 'twilio';

/**
* Unique id of the call. Used to identify in LLM websocket and used to
* authenticate in audio websocket.
*/
call_id: string;

/**
* Status of call.
*
* - `registered`: Call id issued, ready to make a call using this id.
*
* - `ongoing`: Call connected and ongoing.
*
* - `ended`: The underlying websocket has ended for the call. Either user or agent
* hanged up, or call transferred.
*
* - `error`: Call encountered error.
*/
call_status: 'registered' | 'ongoing' | 'ended' | 'error';

/**
* Sample rate of the conversation, the input and output audio bytes will all
* conform to this rate. Check the audio source, audio format, and voice used for
* the agent to select one that works. supports value ranging from [8000, 48000].
* Note for Twilio `mulaw` encoding, the sample rate has to be 8000.
*
* - `s16le` sample rate recommendation (natively supported, lowest latency):
*
* - elevenlabs voices: 16000, 22050, 24000, 44100.
* - openai voices: 24000.
*
* - deepgram voices: 8000, 16000, 24000, 32000, 48000.
*/
sample_rate: number;

/**
* Begin timestamp (milliseconds since epoch) of the call.
*/
start_timestamp: number;

/**
* If users stay silent for a period, end the call. By default, it is set to
* 600,000 ms (10 min). The minimum value allowed is 10,000 ms (10 s).
*/
end_call_after_silence_ms?: number;

/**
* The caller number. This field is storage purpose only, set this if you want the
* call object to contain it so that it's easier to reference it. Not used for
* processing, when we connect to your LLM websocket server, you can then get it
* from the call object.
*/
from_number?: string;

/**
* An abtriary object for storage purpose only. You can put anything here like your
* own id for the call, twilio SID, internal customer id. Not used for processing,
* when we connect to your LLM websocket server, you can then get it from the call
* object.
*/
metadata?: unknown;

/**
* The callee number. This field is storage purpose only, set this if you want the
* call object to contain it so that it's easier to reference it. Not used for
* processing, when we connect to your LLM websocket server, you can then get it
* from the call object.
*/
to_number?: string;
}

export interface CallListParams {
filter_criteria?: CallListParams.FilterCriteria;

Expand Down Expand Up @@ -283,8 +393,89 @@ export namespace CallListParams {
}
}

export interface CallRegisterParams {
/**
* Unique id of agent used for the call. Your agent would contain the LLM Websocket
* url used for this call.
*/
agent_id: string;

/**
* The audio encoding of the call. The following formats are supported:
*
* - `s16le` 16 bit linear PCM audio, the native format for web audio capture and
* playback.
*
* - `mulaw` non-linear audio encoding technique used in telephony. Commonly used
* by Twilio.
*/
audio_encoding: 's16le' | 'mulaw';

/**
* Where the audio websocket would connect from would determine the format /
* protocol of websocket messages, and would determine how our server read audio
* bytes and send audio bytes.:
*
* - `web`: The protocol defined by Retell, commonly used for connecting from web
* frontend. Also useful for those who want to manipulate audio bytes directly.
*
* - `twilio`: The
* [websocket protocol](https://www.twilio.com/docs/voice/twiml/stream#message-media)
* defined by Twilio, used when your system uses Twilio, and supplies Retell
* audio websocket url to Twilio.
*/
audio_websocket_protocol: 'web' | 'twilio';

/**
* Sample rate of the conversation, the input and output audio bytes will all
* conform to this rate. Check the audio source, audio format, and voice used for
* the agent to select one that works. supports value ranging from [8000, 48000].
* Note for Twilio `mulaw` encoding, the sample rate has to be 8000.
*
* - `s16le` sample rate recommendation (natively supported, lowest latency):
*
* - elevenlabs voices: 16000, 22050, 24000, 44100.
* - openai voices: 24000.
*
* - deepgram voices: 8000, 16000, 24000, 32000, 48000.
*/
sample_rate: number;

/**
* If users stay silent for a period, end the call. By default, it is set to
* 600,000 ms (10 min). The minimum value allowed is 10,000 ms (10 s).
*/
end_call_after_silence_ms?: number;

/**
* The caller number. This field is storage purpose only, set this if you want the
* call object to contain it so that it's easier to reference it. Not used for
* processing, when we connect to your LLM websocket server, you can then get it
* from the call object.
*/
from_number?: string;

/**
* An abtriary object for storage purpose only. You can put anything here like your
* own id for the call, twilio SID, internal customer id. Not used for processing,
* when we connect to your LLM websocket server, you can then get it from the call
* object.
*/
metadata?: unknown;

/**
* The callee number. This field is storage purpose only, set this if you want the
* call object to contain it so that it's easier to reference it. Not used for
* processing, when we connect to your LLM websocket server, you can then get it
* from the call object.
*/
to_number?: string;
}

export namespace Calls {
export import CallRetrieveResponse = CallsAPI.CallRetrieveResponse;
export import CallListResponse = CallsAPI.CallListResponse;
export import CallRegisterResponse = CallsAPI.CallRegisterResponse;
export import CallListParams = CallsAPI.CallListParams;
export import CallRegisterParams = CallsAPI.CallRegisterParams;
}
10 changes: 8 additions & 2 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ export {
AgentUpdateParams,
Agents,
} from './agents';
export { CallRetrieveResponse, CallListResponse, CallListParams, Calls } from './calls';
export { RegisterCallCreateResponse, RegisterCallCreateParams, RegisterCalls } from './register-calls';
export {
CallRetrieveResponse,
CallListResponse,
CallRegisterResponse,
CallListParams,
CallRegisterParams,
Calls,
} from './calls';
export {
RetellLlmCreateResponse,
RetellLlmRetrieveResponse,
Expand Down
Loading

0 comments on commit 2aec9f1

Please sign in to comment.