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
dict[str, Any] | NoneDefaults to None

Parameters for the RPC method.

call_id
str | NoneDefaults to None

Target call ID for the RPC command.

node_id
str | NoneDefaults to None

Target node ID for the RPC command.

Returns

FunctionResult — self, for chaining.

Example

from signalwire import AgentBase
from signalwire import FunctionResult
agent = AgentBase(name="my-agent", route="/agent")
agent.set_prompt_text("You are a helpful assistant.")
@agent.tool(name="execute_custom_rpc", description="Execute a custom RPC command")
def execute_custom_rpc(args, raw_data):
return (
FunctionResult("Executing RPC.")
.execute_rpc(
method="ai_message",
call_id="target-call-id",
params={"role": "system", "message_text": "Hello from another call."}
)
)
agent.serve()