send_transactional_email
Send a one-off email to any address without creating a conversation.
send_transactional_email(context: dict, params: dict) -> dictSends 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
| Name | Type | Description |
|---|---|---|
context | dict | The context object passed to your code |
params | dict | Email parameters (see below) |
params keys:
| Key | Type | Required | Description |
|---|---|---|---|
to | str | Yes | Recipient email address |
subject | str | Yes | Email subject line |
text | str | Yes | Plain-text body of the email |
html | str | No | HTML body, shown instead of the text body |
reply_to | str | No | Address 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_toso replies reach a person. - The send is recorded on the current conversation's timeline.
- In test and playground conversations nothing is sent and
testModeisTrue, so you can test workflows safely. Without a conversation (for example intest_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."}