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



