Quick overview
This workflow turns incoming WhatsApp messages (text, audio, images, and documents) into actionable support interactions by extracting content, detecting sentiment, and using an AI agent with a Supabase knowledge base to route requests to Google Calendar, HubSpot, Slack, Gmail, and back to WhatsApp.
How it works
- Receives incoming WhatsApp messages via a WhatsApp webhook trigger.
- Routes the message by type and converts it into text using OpenAI Whisper for audio, OpenAI GPT-4o Vision for images, or a PDF extractor for documents (or passes text messages through).
- Loads the sender’s session context from Supabase and runs sentiment/language detection on the extracted text.
- Uses a LangChain AI agent (Claude) with Supabase vector search (with OpenAI embeddings and Cohere reranking) plus tool access (Google Calendar, HubSpot, Slack, and Gmail) to produce a structured intent, response, and metadata.
- Logs conversation analytics (intent, sentiment, message type, and response length) to an n8n Data Table.
- Routes by intent to either create a Google Calendar event, create/update a HubSpot contact, email a document via Gmail (and upload it to Google Drive), create a HubSpot ticket and notify Slack, or escalate to Slack for urgent human follow-up.
- Saves the updated conversation session back to Supabase and sends the cleaned response text back to the user via WhatsApp.
Setup
- Configure WhatsApp Cloud API credentials in n8n and register the workflow’s webhook URL in your WhatsApp app so message updates are delivered.
- Add credentials for OpenAI (Whisper, GPT-4o Vision, and embeddings), Mistral Cloud (chat model), Cohere (reranker), and Supabase.
- Create the Supabase tables used by the workflow (at least
sessions and knowledge_base) and ensure the knowledge base is set up for vector retrieval.
- Add and authorize Google Calendar, HubSpot (Contacts and Tickets), Slack, Gmail, and Google Drive credentials, and set the target Slack channels (e.g.
support and urgent) and calendar.
- Review and adjust intent values and metadata expectations (e.g.
metadata.datetime, metadata.email, and optional metadata.fileName) to match your operational requirements.