phonic
Version:
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FPhonic-Co%2Fphonic-node) [ • 12.9 kB
text/typescript
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
import * as core from "../../../../core/index.mjs";
import * as Phonic from "../../../index.mjs";
import { ConversationsSocket } from "./Socket.mjs";
export declare namespace ConversationsClient {
type Options = BaseClientOptions & {
/**
* When `true`, `connect()` uses session-aware reconnection on abnormal
* disconnect (1006). Set via `PhonicClient` options as
* `reconnectConversationOnAbnormalDisconnect`.
*/
reconnectConversationOnAbnormalDisconnect?: boolean;
};
interface RequestOptions extends BaseRequestOptions {
}
interface ConnectArgs {
downstream_websocket_url?: string;
/** WebSocket subprotocols to use for the connection. */
protocols?: string | string[];
/** Additional query parameters to send with the websocket connect request. */
queryParams?: Record<string, unknown>;
/** Arbitrary headers to send with the websocket connect request. */
headers?: Record<string, string>;
/** Enable debug mode on the websocket. Defaults to false. */
debug?: boolean;
/** Number of reconnect attempts. Defaults to 30. */
reconnectAttempts?: number;
/** The timeout for establishing the WebSocket connection in seconds. */
connectionTimeoutInSeconds?: number;
/** A signal to abort the WebSocket connection. */
abortSignal?: AbortSignal;
}
}
export declare class ConversationsClient {
protected readonly _options: NormalizedClientOptionsWithAuth<ConversationsClient.Options>;
constructor(options?: ConversationsClient.Options);
/**
* Returns conversations with optional filtering.
*
* @param {Phonic.ConversationsListRequest} request
* @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.BadRequestError}
* @throws {@link Phonic.UnauthorizedError}
* @throws {@link Phonic.ForbiddenError}
* @throws {@link Phonic.NotFoundError}
* @throws {@link Phonic.InternalServerError}
*
* @example
* await client.conversations.list()
*/
list(request?: Phonic.ConversationsListRequest, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsListResponse>;
private __list;
/**
* Returns a conversation by ID.
*
* @param {string} id - The ID of the conversation to get.
* @param {Phonic.ConversationsGetRequest} request
* @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.UnauthorizedError}
* @throws {@link Phonic.ForbiddenError}
* @throws {@link Phonic.NotFoundError}
* @throws {@link Phonic.InternalServerError}
*
* @example
* await client.conversations.get("id")
*/
get(id: string, request?: Phonic.ConversationsGetRequest, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsGetResponse>;
private __get;
/**
* Cancels an active conversation.
*
* @param {string} id - The ID of the conversation to cancel.
* @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.UnauthorizedError}
* @throws {@link Phonic.ForbiddenError}
* @throws {@link Phonic.NotFoundError}
* @throws {@link Phonic.ConflictError}
* @throws {@link Phonic.InternalServerError}
* @throws {@link Phonic.GatewayTimeoutError}
*
* @example
* await client.conversations.cancel("id")
*/
cancel(id: string, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsCancelResponse>;
private __cancel;
/**
* Deletes a conversation, scheduling its transcripts and audio recordings for deletion. The conversation must have ended.
*
* @param {string} id - The ID of the conversation to delete.
* @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.UnauthorizedError}
* @throws {@link Phonic.ForbiddenError}
* @throws {@link Phonic.NotFoundError}
* @throws {@link Phonic.ConflictError}
* @throws {@link Phonic.InternalServerError}
*
* @example
* await client.conversations.delete("id")
*/
delete(id: string, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsDeleteResponse>;
private __delete;
/**
* Returns an analysis of the specified conversation.
*
* @param {string} id - The ID of the conversation to analyze.
* @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.UnauthorizedError}
* @throws {@link Phonic.ForbiddenError}
* @throws {@link Phonic.NotFoundError}
* @throws {@link Phonic.InternalServerError}
*
* @example
* await client.conversations.getAnalysis("id")
*/
getAnalysis(id: string, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsGetAnalysisResponse>;
private __getAnalysis;
/**
* Returns all extractions for a conversation.
*
* @param {string} id - The ID of the conversation to get extractions for.
* @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.UnauthorizedError}
* @throws {@link Phonic.ForbiddenError}
* @throws {@link Phonic.NotFoundError}
* @throws {@link Phonic.InternalServerError}
*
* @example
* await client.conversations.listExtractions("id")
*/
listExtractions(id: string, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsListExtractionsResponse>;
private __listExtractions;
/**
* Extracts data from a conversation using a schema.
*
* @param {string} id - The ID of the conversation to extract data from.
* @param {Phonic.ExtractDataRequest} request
* @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.BadRequestError}
* @throws {@link Phonic.UnauthorizedError}
* @throws {@link Phonic.ForbiddenError}
* @throws {@link Phonic.NotFoundError}
* @throws {@link Phonic.InternalServerError}
*
* @example
* await client.conversations.extractData("id", {
* schema_id: "conv_extract_schema_6458e4ac-533c-4bdf-8e6d-c2f06f87fd5c"
* })
*/
extractData(id: string, request: Phonic.ExtractDataRequest, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsExtractDataResponse>;
private __extractData;
/**
* Returns all evaluations for a conversation.
*
* @param {string} id - The ID of the conversation to get evaluations for.
* @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.UnauthorizedError}
* @throws {@link Phonic.ForbiddenError}
* @throws {@link Phonic.NotFoundError}
* @throws {@link Phonic.InternalServerError}
*
* @example
* await client.conversations.listEvaluations("id")
*/
listEvaluations(id: string, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsListEvaluationsResponse>;
private __listEvaluations;
/**
* Evaluates a conversation using an evaluation prompt.
*
* @param {string} id - The ID of the conversation to evaluate.
* @param {Phonic.EvaluateConversationRequest} request
* @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.BadRequestError}
* @throws {@link Phonic.UnauthorizedError}
* @throws {@link Phonic.ForbiddenError}
* @throws {@link Phonic.NotFoundError}
* @throws {@link Phonic.InternalServerError}
*
* @example
* await client.conversations.evaluate("id", {
* prompt_id: "conv_eval_prompt_d7cfe45d-35db-4ef6-a254-81ab1da76ce0"
* })
*/
evaluate(id: string, request: Phonic.EvaluateConversationRequest, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsEvaluateResponse>;
private __evaluate;
/**
* Replays an ended conversation by re-running its recorded audio through an agent. Requires API key or access
* token authentication. The conversation must have audio recordings available and an associated agent (or one
* specified in the request body).
*
* @param {string} id - The ID of the conversation to replay.
* @param {Phonic.ReplayConversationRequest} request
* @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.BadRequestError}
* @throws {@link Phonic.UnauthorizedError}
* @throws {@link Phonic.ForbiddenError}
* @throws {@link Phonic.NotFoundError}
* @throws {@link Phonic.ConflictError}
* @throws {@link Phonic.UnprocessableEntityError}
* @throws {@link Phonic.TooManyRequestsError}
* @throws {@link Phonic.InternalServerError}
* @throws {@link Phonic.ServiceUnavailableError}
*
* @example
* await client.conversations.replay("id", {
* agent: "support-agent"
* })
*/
replay(id: string, request?: Phonic.ReplayConversationRequest, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsReplayResponse>;
private __replay;
/**
* Initiates a call to a given phone number using Phonic's Twilio account.
*
* @param {Phonic.OutboundCallRequest} request
* @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.BadRequestError}
* @throws {@link Phonic.UnauthorizedError}
* @throws {@link Phonic.NotFoundError}
* @throws {@link Phonic.InternalServerError}
*
* @example
* await client.conversations.outboundCall({
* to_phone_number: "+19189397081",
* config: {
* agent: "support-agent",
* welcome_message: "Hi {{customer_name}}. How can I help you today?",
* system_prompt: "You are an expert in {{subject}}. Be friendly, helpful and concise.",
* template_variables: {
* "customer_name": "David",
* "subject": "Chess"
* },
* voice_id: "sabrina",
* generate_no_input_poke_text: false,
* no_input_poke_sec: 30,
* no_input_poke_text: "Are you still there?",
* no_input_end_conversation_sec: 180,
* default_language: "en",
* additional_languages: ["es"],
* multilingual_mode: "request",
* boosted_keywords: ["Load ID", "dispatch"],
* tools: ["keypad_input"]
* }
* })
*/
outboundCall(request: Phonic.OutboundCallRequest, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsOutboundCallResponse>;
private __outboundCall;
/**
* Initiates a SIP outbound call using user-supplied SIP credentials in headers.
*
* @param {Phonic.ConversationsSipOutboundCallRequest} request
* @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.BadRequestError}
* @throws {@link Phonic.UnauthorizedError}
* @throws {@link Phonic.ConflictError}
* @throws {@link Phonic.InternalServerError}
*
* @example
* await client.conversations.sipOutboundCall({
* "X-Sip-Address": "X-Sip-Address",
* from_phone_number: "from_phone_number",
* to_phone_number: "to_phone_number"
* })
*/
sipOutboundCall(request: Phonic.ConversationsSipOutboundCallRequest, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsSipOutboundCallResponse>;
private __sipOutboundCall;
connect(args?: ConversationsClient.ConnectArgs): Promise<ConversationsSocket>;
}