create_payment_prompt

View as MarkdownOpen in Claude

Static helper that builds a payment prompt object for use with the prompts parameter of pay(). Payment prompts customize the TTS messages played during different stages of payment collection.

Parameters

for_situation
strRequired

The payment stage this prompt applies to (e.g., "payment-card-number", "expiration-date", "security-code", "postal-code").

actions
list[dict[str, str]]Required

List of prompt actions. Use create_payment_action() to build each entry.

card_type
str | NoneDefaults to None

Space-separated card types this prompt applies to (e.g., "visa mastercard").

error_type
str | NoneDefaults to None

Space-separated error types this prompt handles.

Returns

dict[str, Any] — prompt dictionary to pass in the prompts list of pay().

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):
prompt = FunctionResult.create_payment_prompt(
for_situation="payment-card-number",
actions=[
FunctionResult.create_payment_action("Say", "Please enter your credit card number.")
]
)
return (
FunctionResult("I'll collect your payment now.")
.pay(
payment_connector_url="https://api.example.com/pay",
charge_amount="49.99",
prompts=[prompt]
)
)
agent.serve()