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

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="collect_card", description="Collect card payment")
def collect_card(args, raw_data):
say_action = FunctionResult.create_payment_action("Say", "Please enter your card number.")
play_action = FunctionResult.create_payment_action("Play", "https://example.com/card-prompt.mp3")
prompt = FunctionResult.create_payment_prompt(
for_situation="payment-card-number",
actions=[say_action]
)
return (
FunctionResult("I'll collect your payment now.")
.pay(
payment_connector_url="https://api.example.com/pay",
charge_amount="19.99",
prompts=[prompt]
)
)
agent.serve()