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) [ • 8.7 kB
TypeScript
/**
* 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";
export declare namespace Tools {
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>;
}
}
export declare class Tools {
protected readonly _options: Tools.Options;
constructor(_options?: Tools.Options);
/**
* Returns all custom tools for the organization.
*
* @param {Phonic.ToolsListRequest} request
* @param {Tools.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.NotFoundError}
*
* @example
* await client.tools.list({
* project: "main"
* })
*/
list(request?: Phonic.ToolsListRequest, requestOptions?: Tools.RequestOptions): core.HttpResponsePromise<Phonic.ToolsListResponse>;
private __list;
/**
* Creates a new tool in a project.
*
* @param {Phonic.CreateToolRequest} request
* @param {Tools.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.BadRequestError}
* @throws {@link Phonic.ForbiddenError}
* @throws {@link Phonic.ConflictError}
*
* @example
* await client.tools.create({
* project: "main",
* name: "context_printer",
* description: "Gets the specific context for fixing our printer",
* type: "custom_context",
* execution_mode: "sync",
* parameters: [{
* type: "string",
* name: "name",
* description: "description",
* is_required: true
* }],
* require_speech_before_tool_call: false,
* forbid_speech_after_tool_call: false,
* allow_tool_chaining: true
* })
*
* @example
* await client.tools.create({
* project: "main",
* name: "book_appointment",
* description: "Books an appointment in the calendar system",
* type: "custom_webhook",
* execution_mode: "sync",
* parameters: [{
* type: "string",
* name: "date",
* description: "The date for the appointment in YYYY-MM-DD format",
* is_required: true,
* location: "request_body"
* }, {
* type: "string",
* name: "time",
* description: "The time for the appointment in HH:MM format",
* is_required: true,
* location: "request_body"
* }],
* endpoint_method: "POST",
* endpoint_url: "https://api.example.com/book-appointment",
* endpoint_headers: {
* "Authorization": "Bearer token123",
* "Content-Type": "application/json"
* },
* endpoint_timeout_ms: 5000,
* require_speech_before_tool_call: false,
* wait_for_speech_before_tool_call: false,
* forbid_speech_after_tool_call: false,
* allow_tool_chaining: true
* })
*
* @example
* await client.tools.create({
* project: "main",
* name: "check_inventory",
* description: "Checks product inventory levels",
* type: "custom_websocket",
* execution_mode: "async",
* parameters: [{
* type: "string",
* name: "product_id",
* description: "The product ID to check",
* is_required: true
* }],
* tool_call_output_timeout_ms: 5000,
* require_speech_before_tool_call: false,
* wait_for_speech_before_tool_call: false,
* forbid_speech_after_tool_call: false,
* allow_tool_chaining: true
* })
*
* @example
* await client.tools.create({
* project: "main",
* name: "transfer_to_support",
* description: "Transfers the caller to the support team",
* type: "built_in_transfer_to_phone_number",
* execution_mode: "sync",
* phone_number: "+15551234567",
* dtmf: "1234",
* use_agent_phone_number: true,
* detect_voicemail: false,
* require_speech_before_tool_call: false
* })
*
* @example
* await client.tools.create({
* project: "main",
* name: "transfer_to_specialist",
* description: "Transfers the caller to a specialist agent",
* type: "built_in_transfer_to_agent",
* execution_mode: "sync",
* agents_to_transfer_to: ["sales-agent", "support-agent", "technical-agent"],
* require_speech_before_tool_call: false
* })
*/
create(request: Phonic.CreateToolRequest, requestOptions?: Tools.RequestOptions): core.HttpResponsePromise<Phonic.ToolsCreateResponse>;
private __create;
/**
* Returns a tool by name or ID.
*
* @param {string} nameOrId - The name or the ID of the tool to get.
* @param {Phonic.ToolsGetRequest} request
* @param {Tools.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.ForbiddenError}
* @throws {@link Phonic.NotFoundError}
*
* @example
* await client.tools.get("nameOrId", {
* project: "main"
* })
*/
get(nameOrId: string, request?: Phonic.ToolsGetRequest, requestOptions?: Tools.RequestOptions): core.HttpResponsePromise<Phonic.ToolsGetResponse>;
private __get;
/**
* Deletes a tool by name or ID.
*
* @param {string} nameOrId - The name or the ID of the tool to delete.
* @param {Phonic.ToolsDeleteRequest} request
* @param {Tools.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.NotFoundError}
*
* @example
* await client.tools.delete("nameOrId", {
* project: "main"
* })
*/
delete(nameOrId: string, request?: Phonic.ToolsDeleteRequest, requestOptions?: Tools.RequestOptions): core.HttpResponsePromise<Phonic.ToolsDeleteResponse>;
private __delete;
/**
* Updates a tool by name or ID.
*
* @param {string} nameOrId - The name or the ID of the tool to update.
* @param {Phonic.UpdateToolRequest} request
* @param {Tools.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Phonic.BadRequestError}
* @throws {@link Phonic.NotFoundError}
* @throws {@link Phonic.ConflictError}
*
* @example
* await client.tools.update("nameOrId", {
* project: "main",
* description: "Updated description for booking appointments with enhanced features",
* endpoint_headers: {
* "Authorization": "Bearer updated_token456"
* },
* endpoint_timeout_ms: 7000
* })
*/
update(nameOrId: string, request?: Phonic.UpdateToolRequest, requestOptions?: Tools.RequestOptions): core.HttpResponsePromise<Phonic.ToolsUpdateResponse>;
private __update;
protected _getAuthorizationHeader(): Promise<string | undefined>;
}