Quick Overview
This workflow builds a WhatsApp business assistant that uses OpenAI to classify incoming messages and route them to FAQ answers via Pinecone RAG, order placement and inventory updates in Google Sheets, order-status lookups, or Slack escalation for human support, with a Google Drive-to-Pinecone knowledge sync.
How it works
- Triggers when a new WhatsApp message is received and extracts the sender phone number, message text, and a timestamp.
- Uses OpenAI (GPT-4o) to classify the message intent as FAQ, ORDER, TRACK_ORDER, or HUMAN_SUPPORT and routes the request accordingly.
- For FAQ requests, retrieves relevant context from a Pinecone vector index and uses OpenAI to draft a short WhatsApp-style answer, then replies via WhatsApp.
- For ORDER requests, uses OpenAI to extract product and quantity, matches the request semantically against a Google Sheets product catalog, and validates the matched product.
- If the product is found and stock is sufficient, appends a new order row to a Google Sheets Orders sheet, updates stock in the Products sheet, and sends an order confirmation via WhatsApp.
- If the product is not found or stock is insufficient, sends an error/out-of-stock message via WhatsApp.
- For TRACK_ORDER requests, uses OpenAI to extract the order ID, looks up the order in Google Sheets, and replies with the current status via WhatsApp.
- For HUMAN_SUPPORT requests, posts the customer message details to a Slack channel and sends an acknowledgement back to the customer on WhatsApp.
Setup
- Configure WhatsApp Cloud API credentials in n8n and ensure your WhatsApp app is set to send message webhooks to the workflow trigger URL.
- Add OpenAI API credentials for intent classification, order extraction, semantic matching, order ID extraction, and FAQ response generation.
- Set up Google Sheets OAuth credentials and update the spreadsheet/document ID and sheet tabs for Products and Orders to match your own schema (including product_id, product_name, stock, and order_id fields).
- Create a Pinecone index (and namespace) compatible with OpenAI embeddings and add Pinecone API credentials, then populate it with your knowledge base content.
- Add Google Drive OAuth credentials and select the knowledge base file to watch so updates are downloaded, chunked, embedded, and stored in Pinecone.
- Add Slack API credentials and choose the target channel ID where human support requests should be posted.