Quick overview
This workflow receives incoming WhatsApp messages via an n8n webhook, loads an FAQ knowledge base from Google Sheets, and uses Groq (Llama 3.3) to classify intent and generate a reply. It sends the response through the AiSensy API, logs the conversation to Google Sheets, and alerts via Gmail and Telegram.
How it works
- Receives a POST request from AiSensy on a WhatsApp webhook when a customer sends a message.
- Extracts the customer phone, name, message text, and timestamp, and ignores requests missing required fields.
- Loads FAQ question-and-answer rows from Google Sheets and sends them with the customer message to Groq (Llama 3.3) to classify intent, detect language and urgency, and draft a reply.
- Parses and validates the model’s JSON output and formats a safe fallback reply if parsing fails.
- Sends the generated reply back to the customer using the AiSensy WhatsApp API.
- Sends a Gmail alert when the intent is COMPLAINT and posts a Telegram alert when the intent is ESCALATE.
- Appends or updates a conversation log row in Google Sheets and returns a 200 OK webhook response.
Setup
- Configure AiSensy to send message events to this workflow’s webhook URL (path:
/whatsapp-support).
- Add a Groq API credential in n8n and select it in the Groq LLM node.
- Create a Google Sheets FAQ knowledge base with
question and answer columns, connect Google Sheets credentials, and select the document and sheet in the “Load Knowledge Base” step.
- Create a Google Sheets conversation log sheet, connect it in the “Log to Sheets” step, and ensure it has columns for timestamp/phone/name/message/intent/urgency/language/reply.
- Replace
YOUR_AISENSY_API_KEY, confirm the support-reply template exists in AiSensy with one parameter, and set any campaign/template values as needed.
- Add Gmail OAuth credentials and set the complaint notification recipient email, and add Telegram bot credentials and replace
YOUR_TELEGRAM_CHAT_ID for escalation alerts.