rpc_ai_message

View as MarkdownOpen in Claude

Inject a message into the AI agent running on another call. Useful for cross-call coordination, such as notifying a held caller’s agent about a status change or instructing it to relay information.

Parameters

call_id
strRequired

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

message_text
strRequired

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

role
strDefaults to system

Role for the injected message. Typically "system" for instructions.

Returns

FunctionResult — self, for chaining.

Example

1from signalwire import AgentBase
2from signalwire import FunctionResult
3
4agent = AgentBase(name="my-agent", route="/agent")
5agent.set_prompt_text("You are a helpful assistant.")
6
7@agent.tool(name="notify_caller", description="Notify the caller on the other line")
8def notify_caller(args, raw_data):
9 caller_call_id = args.get("original_call_id")
10 return (
11 FunctionResult("I'll let them know.")
12 .rpc_ai_message(
13 call_id=caller_call_id,
14 message_text="The person you're trying to reach is unavailable. Please leave a message."
15 )
16 )
17
18agent.serve()