create_payment_action

View as MarkdownOpen in Claude

Static helper that builds a single action entry for a payment prompt.

Parameters

action_type
strRequired

Action type.

  • "Say" — use text-to-speech
  • "Play" — play an audio file URL
phrase
strRequired

Text to speak (when action_type is "Say") or URL to play (when action_type is "Play").

Returns

dict[str, str] — action dictionary for use in create_payment_prompt().

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="collect_card", description="Collect card payment")
8def collect_card(args, raw_data):
9 say_action = FunctionResult.create_payment_action("Say", "Please enter your card number.")
10 play_action = FunctionResult.create_payment_action("Play", "https://example.com/card-prompt.mp3")
11 prompt = FunctionResult.create_payment_prompt(
12 for_situation="payment-card-number",
13 actions=[say_action]
14 )
15 return (
16 FunctionResult("I'll collect your payment now.")
17 .pay(
18 payment_connector_url="https://api.example.com/pay",
19 charge_amount="19.99",
20 prompts=[prompt]
21 )
22 )
23
24agent.serve()