Ai knowledge and logicHelpers

send_transactional_email

Send a one-off email to any address without creating a conversation.

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

Sends a one-off email to any address, such as an internal team, a supplier or a partner. No conversation or ticket is created: use it for messages that are not customer communication agents need to see.

To email a customer and keep that communication in the help desk, use send_outbound_email instead.


Parameters

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

params keys:

KeyTypeRequiredDescription
tostrYesRecipient email address
subjectstrYesEmail subject line
textstrYesPlain-text body of the email
htmlstrNoHTML body, shown instead of the text body
reply_tostrNoAddress that receives replies, such as the customer

Returns

dict: {"success": bool, "messageId": str | None, "testMode": bool}

When the organization limit is reached, success is False and error explains the limit.

Behavior

  • The email is sent from Octocom's notification address, with the business name as the sender name. Set reply_to so replies reach a person.
  • The send is recorded on the current conversation's timeline.
  • In test and playground conversations nothing is sent and testMode is True, so you can test workflows safely. Without a conversation (for example in test_python_action), a mock response is returned.
  • Each organization can send at most 60 transactional emails per hour and 300 per day.

Examples

Forward a request to an internal team

The team replies straight to the customer because reply_to is the customer's address.

def execute_action(context):
    customer_email = (context.get("customer") or {}).get("email")
    if not customer_email:
        return {"success": False, "message": "Ask the customer for their email address first."}

    transcript = "\n\n".join(
        f"{m['sender']}: {m['content']}" for m in context["conversation"]["messages"]
    )

    result = send_transactional_email(context, {
        "to": "b2b-team@example.com",
        "subject": context["conversation"]["subject"] or "New business request",
        "text": f"Forwarded from Octocom. Reply to this email to reach the customer.\n\n{transcript}",
        "reply_to": customer_email,
    })

    if not result["success"]:
        return {"success": False, "message": "Could not forward the request. Transfer the conversation instead."}
    return {"success": True, "message": "The request was forwarded to the business team."}

On this page