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.24 kB
text/typescript
import type * as Phonic from "../../../../index.mjs";
/**
* @example
* {
* 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,
* context: "Press the A button 5 times then gently shake the printer."
* }
*
* @example
* {
* 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
* {
* 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,
* wait_for_response: false
* }
*
* @example
* {
* 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",
* dynamic_dtmf: false,
* use_agent_phone_number: true,
* detect_voicemail: false,
* require_speech_before_tool_call: false
* }
*
* @example
* {
* 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
* }
*/
export interface CreateToolRequest {
/** The name of the project to create the tool in. */
project?: string;
/** The name of the tool. Must be snake_case and unique within the organization. */
name: string;
/** A description of what the tool does. */
description: string;
/** The type of tool. */
type: CreateToolRequest.Type;
/** Mode of operation. */
execution_mode: CreateToolRequest.ExecutionMode;
/**
* Array of parameter definitions.
* For `custom_webhook` tools with POST method, each parameter must include a `location` field.
* For `custom_webhook` tools with GET method, `location` defaults to `"query_string"` if not specified.
* For `custom_websocket`, `built_in_transfer_to_phone_number`, and `built_in_transfer_to_agent` tools, `location` must not be specified.
*/
parameters?: Phonic.ToolParameter[];
/** Required for webhook tools. HTTP method for the webhook endpoint. */
endpoint_method?: CreateToolRequest.EndpointMethod;
/** Required for webhook tools. */
endpoint_url?: string;
/** Optional headers for webhook tools. */
endpoint_headers?: Record<string, string>;
/** Timeout for webhook tools. */
endpoint_timeout_ms?: number;
/** Timeout for WebSocket tool responses. */
tool_call_output_timeout_ms?: number;
/** The E.164 formatted phone number to transfer calls to. Set to null if the agent should determine the phone number. */
phone_number?: string | null;
/** DTMF digits to send after the transfer connects (e.g., "1234"). Defaults to null. Ignored when dynamic_dtmf is true. */
dtmf?: string | null;
/** When true, the agent determines the DTMF digits at call time (and may choose to send none); the static dtmf is ignored. Only sent when use_agent_phone_number is true (not on a SIP REFER transfer). */
dynamic_dtmf?: boolean;
/** When true, Phonic will transfer the call using the agent's phone number. When false, Phonic will transfer the call using the phone number of the party to whom the agent is connected. This is only available for built_in_transfer_to_phone_number tools. */
use_agent_phone_number?: boolean;
/** When true, Phonic will listen in and tell the user if the transfer hits voicemail. This is only available for built_in_transfer_to_phone_number tools when use_agent_phone_number is true. */
detect_voicemail?: boolean;
/** Array of agent names that the LLM can choose from when transferring. Required for built_in_transfer_to_agent tools. All agents must exist in the same project as the tool. */
agents_to_transfer_to?: string[];
/** When true, forces the agent to speak before executing the tool. */
require_speech_before_tool_call?: boolean;
/** If true, the agent will wait to finish speaking before executing the tool. This is only available for custom_webhook and custom_websocket tools. */
wait_for_speech_before_tool_call?: boolean;
/** When true, forbids the agent from speaking after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
forbid_speech_after_tool_call?: boolean;
/** When true, allows the agent to chain and execute other tools after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
allow_tool_chaining?: boolean;
/** The agent doesn't typically wait for the response of async custom_websocket tools. When true, makes the agent wait for a response, not call other tools and inform the user of the result. Only available for async custom_websocket tools. */
wait_for_response?: boolean;
/** The static context returned to the agent. Required for custom_context tools. */
context?: string;
}
export declare namespace CreateToolRequest {
/** The type of tool. */
const Type: {
readonly CustomContext: "custom_context";
readonly CustomWebhook: "custom_webhook";
readonly CustomWebsocket: "custom_websocket";
readonly BuiltInTransferToPhoneNumber: "built_in_transfer_to_phone_number";
readonly BuiltInTransferToAgent: "built_in_transfer_to_agent";
};
type Type = (typeof Type)[keyof typeof Type];
/** Mode of operation. */
const ExecutionMode: {
readonly Sync: "sync";
readonly Async: "async";
};
type ExecutionMode = (typeof ExecutionMode)[keyof typeof ExecutionMode];
/** Required for webhook tools. HTTP method for the webhook endpoint. */
const EndpointMethod: {
readonly Get: "GET";
readonly Post: "POST";
};
type EndpointMethod = (typeof EndpointMethod)[keyof typeof EndpointMethod];
}