Skip to main content

Work with voice calls

Available from runtime 2026.10.19

Check or change a function's version in the editor's status bar. See Runtime versions.

On a voice call, a function can hang up or forward the call itself, the way the End call and Call transfer nodes do in a flow. Return the action as the function's result. It's carried out once the function finishes, after anything the agent is still saying has been spoken.

import { sendMessage } from "@yellow/bot/responses";
import { endCall, transferCall } from "@yellow/bot/voice";

export default async function* ({ wantsAgent }) {
if (wantsAgent) {
return transferCall({
number: "+914412345678",
announcement: "Connecting you to our billing team.",
});
}

yield sendMessage("Thanks for calling. Goodbye!");
return endCall();
}

endCall()​

Hangs up once the function finishes.

transferCall(options)​

Forwards the call once the function finishes. Give number, sipUri, or both.

OptionDescription
numberPhone number to forward to, for example "+914412345678". Used first when both are given.
sipUriSIP URI or extension, for example "sip:[email protected]"
sipReferWith sipUri and no number: transfer with a SIP REFER. sipUri must then be a full SIP URI. Default false.
announcementSpoken to the caller just before the transfer, up to 500 characters
callerIdThe caller ID the receiving side sees
sipHeadersExtra SIP headers for the transferred leg, as [{ name, value }]
dtmfDigits played once the other side answers, for example "1#" to pick an IVR option
srtpDial the other side over TLS and SRTP. Your trunk needs a TLS/SRTP endpoint. Leave it out to keep the call's setting.
recordingWhat the call recording does at the transfer: "continue", "pause" or "stop". Leave it out to keep recording.
disconnectHang up the agent's side after the transfer. Default true.

Without number or sipUri, or with an option that isn't valid, transferCall stops the function with an error that names the option.

Things to know​

  • Return it, don't yield it. Yielding a call action stops the function with "return them, don't yield them".
  • Calls only. On a chat, or a call that can't be transferred, nothing happens and the agent is told so.
  • Where it works: when an AI agent calls the function as a tool during a call. In a flow's Function node the action isn't carried out yet; use the End call or Call transfer node there.
  • On the Run button, the run panel shows the action under Then, for example Ends the call or Transfers the call to +914412345678. Nothing is dialled.