Python helpers

send_outbound_email

Email a customer from the business and track the thread as a new help desk conversation.

send_outbound_email(context: dict, params: dict) -> dict

Sends an email from the business and creates a new conversation for it in the help desk. The conversation starts handed off, so the bot does not respond to it and your team handles any reply.

To send a one-off email that is not customer communication, such as forwarding a request to an internal team, use send_transactional_email: it creates no conversation.


Parameters

NameTypeDescription
contextdictThe context object passed to your action
paramsdictEmail parameters (see below)

params keys:

KeyTypeRequiredDescription
tostrYesRecipient email address
subjectstrYesEmail subject line
textstrYesPlain-text body of the email
customer_namestrNoRecipient name
inbox_idstrNoInbox to send from; defaults to the primary inbox
tagslist[str]NoTags to attach to the created conversation

Returns

dict: {"success": bool, "conversationId": str, "publicId": str}

Prerequisites

The business must have an email integration configured.

Each email counts against the organization's outbound email limit of 2,500 per UTC hour and 10,000 per UTC day, shared with every other outbound send. Over the limit the call raises an error and nothing is sent.


Examples

Notify a team about a flagged order

def execute_action(context):
    order_id = context["args"]["orderId"]

    send_outbound_email(context, {
        "to": "support-escalations@example.com",
        "subject": f"Flagged order {order_id}",
        "text": f"Order {order_id} was flagged for manual review during a chatbot conversation.",
        "tags": ["escalation", "flagged-order"],
    })

    return {"success": True, "message": "The team has been notified."}

Send a confirmation email to the customer

def execute_action(context):
    email = context["args"]["email"]
    name = context["args"].get("name")

    send_outbound_email(context, {
        "to": email,
        "subject": "Your request has been received",
        "text": "We've received your request and will get back to you within 24 hours.",
        "customer_name": name,
    })

    return {"success": True}

On this page