Ai knowledge and logicHelpers

send_slack_notification

Send a notification to a Slack channel via an Incoming Webhook URL.

send_slack_notification(webhook_url: str, text: str) -> dict

Sends a message to a Slack channel using an Incoming Webhook URL. This is useful for notifying your team about events during a conversation — refund requests, escalations, high-value orders, etc.


Parameters

NameTypeDescription
webhook_urlstrThe Slack Incoming Webhook URL (starts with https://hooks.slack.com/services/). See setup guide
textstrThe message text to send. Supports Slack's mrkdwn formatting

Returns

dict{"success": bool, "message": str}


Examples

Notify your team about a refund request

def execute_action(context):
    order_id = context["args"]["orderId"]
    reason = context["args"]["reason"]
    conv_id = context["conversation"]["publicId"]

    send_slack_notification(
        "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXX",
        f"*Refund requested*\nOrder: {order_id}\nReason: {reason}\nConversation: {conv_id}",
    )

    return {"success": True, "message": "Your refund request has been submitted."}

Alert on high-value orders

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

    if order["total"] > 500:
        send_slack_notification(
            "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXX",
            f"*High-value order placed*\nOrder: {order['id']}\nTotal: ${order['total']}\nCustomer: {order['email']}",
        )

    return {"orderId": order["id"], "status": order["status"]}

On this page