UNPKG

phonic

Version:

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FPhonic-Co%2Fphonic-node) [![npm shield](htt

238 lines (237 loc) 10.6 kB
/** * This file was auto-generated by Fern from our API Definition. */ import * as environments from "../../../../environments.js"; import * as core from "../../../../core/index.js"; import * as Phonic from "../../../index.js"; import { ConversationsSocket } from "./Socket.js"; export declare namespace Conversations { interface Options { environment?: core.Supplier<environments.PhonicEnvironment | environments.PhonicEnvironmentUrls>; /** Specify a custom URL to connect the client to. */ baseUrl?: core.Supplier<string>; apiKey?: core.Supplier<core.BearerToken | undefined>; /** Additional headers to include in requests. */ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>; fetcher?: core.FetchFunction; } interface RequestOptions { /** The maximum time to wait for a response in seconds. */ timeoutInSeconds?: number; /** The number of times to retry the request. Defaults to 2. */ maxRetries?: number; /** A hook to abort the request. */ abortSignal?: AbortSignal; /** Additional query string parameters to include in the request. */ queryParams?: Record<string, unknown>; /** Additional headers to include in the request. */ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>; } interface ConnectArgs { downstream_websocket_url?: string | undefined; /** 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; } } export declare class Conversations { protected readonly _options: Conversations.Options; constructor(_options?: Conversations.Options); /** * Returns conversations with optional filtering. * * @param {Phonic.ConversationsListRequest} request * @param {Conversations.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?: Conversations.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsListResponse>; private __list; /** * Returns a conversation by ID. * * @param {string} id - The ID of the conversation to get. * @param {Conversations.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, requestOptions?: Conversations.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsGetResponse>; private __get; /** * Cancels an active conversation. * * @param {string} id - The ID of the conversation to cancel. * @param {Conversations.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?: Conversations.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsCancelResponse>; private __cancel; /** * Returns an analysis of the specified conversation. * * @param {string} id - The ID of the conversation to analyze. * @param {Conversations.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?: Conversations.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 {Conversations.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?: Conversations.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 {Conversations.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?: Conversations.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 {Conversations.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?: Conversations.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 {Conversations.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?: Conversations.RequestOptions): core.HttpResponsePromise<Phonic.ConversationEvaluationResult>; private __evaluate; /** * Initiates a call to a given phone number using Phonic's Twilio account. * * @param {Phonic.OutboundCallRequest} request * @param {Conversations.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: "grant", * no_input_poke_sec: 30, * no_input_poke_text: "Are you still there?", * no_input_end_conversation_sec: 180, * languages: ["en", "es"], * boosted_keywords: ["Load ID", "dispatch"], * tools: ["keypad_input"] * } * }) */ outboundCall(request: Phonic.OutboundCallRequest, requestOptions?: Conversations.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsOutboundCallResponse>; private __outboundCall; /** * Initiates a SIP outbound call using user-supplied SIP credentials in headers. * * @param {Phonic.ConversationsSipOutboundCallRequest} request * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Phonic.BadRequestError} * @throws {@link Phonic.UnauthorizedError} * @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?: Conversations.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsSipOutboundCallResponse>; private __sipOutboundCall; connect(args?: Conversations.ConnectArgs): Promise<ConversationsSocket>; protected _getAuthorizationHeader(): Promise<string | undefined>; }