Platform: Self-hosted n8n 1.108.1
Issue: WhatsApp Flow endpoint validation failing
Error: āResponse body is not Base64 encodedā + āFailed to decrypt responseā
What Iām Trying to Achieve
Building a WhatsApp Flow endpoint for Metaās WhatsApp Business Manager that:
-
Handles ping/health check requests
-
Processes encrypted Flow submissions (INIT, data_exchange)
-
Returns properly encrypted Base64 responses per Metaās specification
Current Setup
-
Self-hosted n8n with Docker Compose + Traefik
-
SSL enabled at
https://n8n.srv977544.hstgr.cloud -
Environment variables set:
textN8N_ENABLE_RAW_EXECUTION=true NODE_FUNCTION_ALLOW_BUILTIN=fs,crypto,path,os -
Private key mounted correctly (PKCS#8 encrypted format)
-
Workflow structure:
Webhook ā Code Node ā Respond to Webhook
The Problem
WhatsApp Flow validation keeps failing with:
-
āResponse body is not Base64 encodedā - Even when returning Base64 strings
-
āFailed to decrypt responseā - WhatsApp canāt decrypt my encrypted responses
What Iāve Tried
Attempt 1: Raw Base64 Response
javascript
returnencryptedData.toString('base64');// n8n error: not array format
Attempt 2: JSON Wrapped Response
javascript
return[{ json: { base64Response: encrypted.toString('base64') } }];// Respond to Webhook: {{$json.base64Response}}
Attempt 3: Different Encryption Approaches
-
Random AES keys for ping ā WhatsApp canāt decrypt
-
Simple Base64 JSON for ping ā ānot Base64 encodedā error
-
Using WhatsAppās provided AES keys ā still fails
Current Code Structure
javascript
constitems = $input.all();constbody = items[0].json; // For ping requests if(body.action === 'ping' || !body.encrypted_flow_data) { constresponseData = { version: "3.0", data: { status: "active" } }; // What format should this return???} // For encrypted requests // RSA decrypt AES key ā AES-GCM decrypt ā process ā encrypt response
Key Questions
-
Response format: Should ping responses be simple Base64-encoded JSON or encrypted data?
-
n8n compatibility: How to return raw Base64 strings that WhatsApp expects?
-
Encryption keys: For ping responses, what keys should I use if none provided?
-
Meta specification: Anyone successfully implemented WhatsApp Flow endpoints in n8n?
Meta Documentation Reference
Following: https://developers.facebook.com/docs/whatsapp/flows/guides/implementingyourflowendpoint
Looking For
-
Working n8n WhatsApp Flow implementation examples
-
Encryption strategy for ping vs encrypted requests
-
Response format that passes Meta validation
-
Environment variable configurations that work
Has anyone successfully implemented WhatsApp Flow endpoints (not regular WhatsApp messaging) with n8n? Any insights on the proper encryption/response format would be hugely appreciated!
Tags: #whatsapp-flow #encryption #base64 #meta-api #webhook-response



