Ai knowledge and logicHelpers

send_outbound_email

Send an outbound email that creates a new handed-off conversation.

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

Sends an outbound email from the business and creates a new conversation that is already handed off (the bot will not respond to it).


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
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.


Examples

Notify a team about a flagged order

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

    send_outbound_email(context, {
        "to": "[email protected]",
        "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