API & n8n
Add this as an x-api-key header in every request from n8n.
—https://lunch.rahaty.shop/api/n8n/accountsList active accounts — copy the id to use as account_id below
https://lunch.rahaty.shop/api/n8n/templates?account_id=…List approved templates for an account
https://lunch.rahaty.shop/api/n8n/sendSend a text or template message — see examples below
Each object in components maps to a section of your template. Parameters fill variables in order: {{1}} {{2}} etc. Only include sections your template actually uses.
{
"phone": "971501234567",
"account_id": "YOUR_ACCOUNT_ID",
"type": "template",
"template_name": "order_confirmation",
"language": "ar",
"components": [
// Header — fills {{1}} in the header text
{
"type": "header",
"parameters": [
{ "type": "text", "text": "Mohamed" }
]
},
// Body — fills {{1}}, {{2}}, {{3}} in order
{
"type": "body",
"parameters": [
{ "type": "text", "text": "ORD-12345" },
{ "type": "text", "text": "149 درهم" },
{ "type": "text", "text": "2-3 أيام" }
]
},
// URL button — fills the dynamic URL suffix
{
"type": "button",
"sub_type": "url",
"index": "0",
"parameters": [
{ "type": "text", "text": "track-ORD-12345" }
]
},
// Quick-reply button — payload sent back when tapped
{
"type": "button",
"sub_type": "quick_reply",
"index": "1",
"parameters": [
{ "type": "payload", "payload": "CONFIRM_ORDER" }
]
}
]
}In n8n — replace hardcoded values with expressions:
{{ $json.customer_name }} → customer name from trigger
{{ $json.order_id }} → order ID from trigger
{{ $json.phone }} → customer phone number
Every inbound message — including button taps and list selections — is forwarded to your n8n instance automatically. Set the env var below in Vercel, then create a Webhook trigger node in n8n to receive events.
Add to Vercel → Project → Environment Variables:
N8N_WEBHOOK_URLhttps://your-n8n.com/webhook/YOUR_IDEvents sent to n8n:
message— Any regular inbound text messagebutton_reply— Customer tapped a quick-reply button in a templatelist_reply— Customer selected an item from a list templatePayload shape (button_reply example):
{
"event": "button_reply",
"payload": "CONFIRM_ORDER",
"button_title": "Confirm",
"phone": "971501234567",
"contact_name": "Mohamed",
"contact_id": "uuid",
"conversation_id": "uuid",
"account_id": "uuid",
"message_type": "interactive",
"body": "[Button: Confirm]",
"timestamp": "2026-06-19T12:00:00.000Z"
}n8n workflow tip
Add a Switch node after the Webhook trigger — branch on {{ $json.event }} to run different flows for button_reply vs message.
Use {{ $json.payload }} to match the button ID (e.g. CONFIRM_ORDER) and {{ $json.phone }} to send the follow-up template back via POST /api/n8n/send.