Skip to navigation

rpcAiGlobalData

View as MarkdownOpen in Claude

Merge data into another call’s global data without injecting a conversation turn. A thin wrapper over rpcAiMessage() with only globalData set. Use it when the other call needs a value rather than an instruction; that call’s prompt reads it back with ${global_data.key}.

Parameters

callId
stringRequired

Call ID of the target call.

data
Record<string, unknown>Required

Object merged into that call’s global data.

Returns

FunctionResult — this, for chaining.

Example

import { AgentBase, FunctionResult } from '@signalwire/sdk';
const agent = new AgentBase({ name: 'dispatch', route: '/dispatch' });
agent.setPromptText('You are Ada, the dispatcher for Bayview Taxi.');
agent.defineTool({
name: 'share_eta',
description: 'Send the ETA to the waiting caller',
parameters: {
type: 'object',
properties: {
waiting_call_id: { type: 'string', description: 'Call ID of the waiting caller' },
eta_minutes: { type: 'integer', description: 'Minutes until pickup' },
},
required: ['waiting_call_id', 'eta_minutes'],
},
handler: (args) => {
const waitingCallId = String(args.waiting_call_id);
return new FunctionResult('Tell the driver the passenger has been updated.')
.rpcAiGlobalData(waitingCallId, { eta_minutes: args.eta_minutes })
.rpcAiUnhold(waitingCallId);
},
});
await agent.serve();