Automated Next-Best Action Engine
Evaluates incoming email content to choose the optimal action: "reply", "forward", "archive", "assign", or "escalate".
Automated email decision engine determining routing, forwarding, assignment, archiving, or escalation rules.
https://rsflowhub.com/api/v1/ai/email-workflow
X-API-Key header{
"subject": "Cancel subscription",
"email_content": "I would like to cancel my subscription from next month, please assist.",
"allowed_actions": [
"reply",
"forward",
"archive",
"escalate"
],
"allowed_departments": [
"billing",
"support",
"sales"
],
"workflow_first": true
}
{
"result": {
"action": "auto_reply",
"department": "billing",
"confidence": 0.9,
"reasoning": "Clear duplicate-charge refund request covered by the standard refund policy.",
"category": "billing",
"intent": "refund_request",
"priority": "high",
"sentiment": "negative",
"language": "en",
"summary": "Duplicate charge on invoice INV-2041; customer requests a refund.",
"reply_text": "Thanks for reaching out. We have refunded the duplicate payment for INV-2041.",
"requires_human_escalation": false,
"escalation_reason": null
}
}
AI Email Automation & Auto-Routing Workflow API is a REST API on RSFlowHub for web, mobile and AI agent applications. Send a JSON request to POST /api/v1/ai/email-workflow with your API key; RSFlowHub runs it on a tuned AI model, falls back to a backup provider if needed, and returns a structured JSON result, usually within 1 to 3 seconds.
POST /api/v1/ai/email-workflowX-API-Key headerSend these fields as a JSON body. An invalid or missing field returns a 422 error that names the field.
| Field | Type | Required | Description |
|---|---|---|---|
email_content |
string | Required | The main body of the email to route (Max: 20,000 characters). |
subject |
string | Optional | Optional email subject line. |
allowed_actions |
array of strings | Optional | Optional strict list of allowed actions (e.g., ["reply", "forward", "archive", "escalate"]). |
allowed_departments |
array of strings | Optional | Optional strict list of allowed departments (e.g., ["support", "billing", "sales", "hr"]). |
workflow_first |
boolean | Optional | Optional. If true, runs in Workflow-First Mode. The API internally executes both analysis and reply drafting, returning all results (insights and drafted reply) in a single unified JSON response. Default is false. |
custom_instructions |
string | Optional | Optional instructions to guide routing decisions. |
Copy, replace rfh_your_api_key with your key and run. Prefer a client library? See the official SDKs.
curl -X POST "https://rsflowhub.com/api/v1/ai/email-workflow" \
-H "Content-Type: application/json" \
-H "X-API-Key: rfh_your_api_key" \
-d '{"subject":"Cancel subscription","email_content":"I would like to cancel my subscription from next month, please assist.","allowed_actions":["reply","forward","archive","escalate"],"allowed_departments":["billing","support","sales"],"workflow_first":true}'
<?php
$client = new \GuzzleHttp\Client();
$response = $client->post('https://rsflowhub.com/api/v1/ai/email-workflow', [
'headers' => [
'Content-Type' => 'application/json',
'X-API-Key' => 'rfh_your_api_key',
],
'json' => array (
'subject' => 'Cancel subscription',
'email_content' => 'I would like to cancel my subscription from next month, please assist.',
'allowed_actions' =>
array (
0 => 'reply',
1 => 'forward',
2 => 'archive',
3 => 'escalate',
),
'allowed_departments' =>
array (
0 => 'billing',
1 => 'support',
2 => 'sales',
),
'workflow_first' => true,
),
]);
echo $response->getBody();
const response = await fetch('https://rsflowhub.com/api/v1/ai/email-workflow', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'rfh_your_api_key'
},
body: JSON.stringify({"subject":"Cancel subscription","email_content":"I would like to cancel my subscription from next month, please assist.","allowed_actions":["reply","forward","archive","escalate"],"allowed_departments":["billing","support","sales"],"workflow_first":true})
});
const data = await response.json();
console.log(data);
import requests
url = "https://rsflowhub.com/api/v1/ai/email-workflow"
headers = {
"Content-Type": "application/json",
"X-API-Key": "rfh_your_api_key"
}
payload = {"subject":"Cancel subscription","email_content":"I would like to cancel my subscription from next month, please assist.","allowed_actions":["reply","forward","archive","escalate"],"allowed_departments":["billing","support","sales"],"workflow_first":true}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
Every RSFlowHub endpoint uses the same envelope, so one parser handles all of them. Failed calls are not charged.
{
"success": true,
"request_id": "req_3f9a2c7e-5b1d-4e8a-9c2f-7d6e1a0b4c8d",
"data": {
"result": {
"action": "auto_reply",
"department": "billing",
"confidence": 0.9,
"reasoning": "Clear duplicate-charge refund request covered by the standard refund policy.",
"category": "billing",
"intent": "refund_request",
"priority": "high",
"sentiment": "negative",
"language": "en",
"summary": "Duplicate charge on invoice INV-2041; customer requests a refund.",
"reply_text": "Thanks for reaching out. We have refunded the duplicate payment for INV-2041.",
"requires_human_escalation": false,
"escalation_reason": null
}
},
"meta": {
"version": "v1",
"timestamp": "2026-10-05T09:30:00Z"
}
}
{
"success": false,
"request_id": "req_8c1d4e2a-7f3b-4a9c",
"error": {
"code": "VALIDATION_ERROR",
"message": "The given data was invalid.",
"details": {
"email_content": [
"This field is required."
]
}
},
"meta": {
"version": "v1",
"timestamp": "2026-10-05T09:30:00Z"
}
}
| Field | Type | Meaning |
|---|---|---|
success | boolean | true when the call worked, false on any error. |
request_id | string | Unique id for this call. Quote it when you contact support. |
data.result | object | The result of this endpoint (see the example). |
error | object | Only on failure: code, message and details per field. |
meta | object | API version and server timestamp. |
All error codes: Errors reference
Evaluates incoming email content to choose the optimal action: "reply", "forward", "archive", "assign", or "escalate".
Automatically routes emails to correct team queues like billing, technical support, sales, or legal.
Detects urgent legal threats, executive complaints, or chargebacks requiring immediate human intervention.
Evaluates routing rules before drafting reply text to deliver lightning-fast routing execution.
How teams use the AI Email Automation & Auto-Routing Workflow API in production.
Route incoming main company contact email inquiries automatically to Billing, Sales, or Legal queues.
{"action": "assign", "department": "billing", "priority": "high", "reason": "subscription_cancellation"}Sorts every incoming email by category and priority the moment it arrives.
Instantly escalate emails containing chargeback threats or legal complaints to senior retention leads.
{"action": "escalate", "department": "legal_security", "priority": "critical"}Protects enterprise accounts through immediate escalation.
Assign incoming qualified sales demo requests to regional account executives based on company location.
{"action": "forward", "department": "sales_emea", "priority": "high"}Accelerates sales representative outreach speed.
The same job done three ways.
| Topic | RSFlowHub API | Raw LLM prompts | Rules / regex |
|---|---|---|---|
| Output | Validated JSON fields | Free text you have to parse | Fixed patterns only |
| Setup | One POST request, no prompts | Write and maintain prompts and parsing | Write and maintain rule lists |
| Provider outage | Automatic fallback to a backup model | You build retries and a second vendor | Not applicable |
| Pricing | 2 credits per call, failed calls free | Per token, per vendor | Your own servers and upkeep |
| Understands context | Yes, AI model | Yes, AI model | No, keywords only |
Free plan with 100 credits/month + 1,000 bonus credits when you sign in before 23 Nov. Test it in the playground first, no code needed.
Flowy
AI assistant