execute_rpc

View as MarkdownOpen in Claude

Execute a generic RPC method on a call. This is the low-level interface for cross-call communication. For common operations, prefer the specific helpers rpc_dial(), rpc_ai_message(), and rpc_ai_unhold().

Parameters

method
strRequired

RPC method name (e.g., "dial", "ai_message", "ai_unhold").

params
Optional[dict[str, Any]]Defaults to None

Parameters for the RPC method.

call_id
Optional[str]Defaults to None

Target call ID for the RPC command.

node_id
Optional[str]Defaults to None

Target node ID for the RPC command.

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="execute_custom_rpc", description="Execute a custom RPC command")
8def execute_custom_rpc(args, raw_data):
9 return (
10 FunctionResult("Executing RPC.")
11 .execute_rpc(
12 method="ai_message",
13 call_id="target-call-id",
14 params={"role": "system", "message_text": "Hello from another call."}
15 )
16 )
17
18agent.serve()