Skip to navigation

rpcAiMessage

View as MarkdownOpen in Claude

Send a message, global data, or both to the AI agent running on another call. Useful for cross-call coordination, such as notifying a held caller’s agent about a status change.

The two payloads behave differently. messageText lands as a turn in the other agent’s conversation, where it competes with everything else arriving at that moment. globalData is merged into the other call’s global data, where it stays silent until a prompt expands it with ${global_data.your_key}, so data is the better channel for content a later step needs to say. To send data only, use rpcAiGlobalData().

Parameters

callId
stringRequired

Call ID of the target call whose AI agent should receive the message.

messageText
string | null

The message text to inject into the target AI’s conversation.

role
stringDefaults to system

Role for the injected message, sent with the message. Typically "system" for instructions.

globalData
Record<string, unknown>

Object merged into the target call’s global data.

Throws an Error when neither messageText nor globalData is given.

Returns

FunctionResult — this, for chaining.

Example

import { FunctionResult } from '@signalwire/sdk';
const result = new FunctionResult('Tell the driver the passenger has been updated.')
.rpcAiMessage(
'<WAITING_CALL_ID>',
'Your driver is on the way. Tell the caller their pickup is confirmed.',
'system',
{ eta_minutes: 8 },
);