Quick Overview
This workflow handles WhatsApp customer service via OpenWA, using Google Gemini and a Google Sheets knowledge base to answer personal chats, while routing conversations to a human queue in Google Sheets when escalation is needed.
How it works
- Triggers on OpenWA WhatsApp events and ignores message reactions except for specific ✅/☑ reactions used to re-enable AI handling.
- Normalizes incoming event fields and processes only personal chats (IDs ending with @c.us) that are not sent by your own WhatsApp account.
- Checks a Google Sheets “Session Chat” list to decide whether the conversation is currently handled by a human, and only continues to AI when no active human session is found.
- Uses a Google Gemini chat model with short-term memory and a Google Sheets “Database Company” tool to draft a friendly Indonesian response based only on the sheet data.
- If the AI response does not contain the #admin escalation token, it sends the reply back to the customer via OpenWA.
- If the AI response contains #admin, it appends the chat to the Google Sheets “Session Chat” sheet to flag it for human follow-up.
- When a ✅/☑ reaction is received for a chat, it finds and deletes the corresponding “Session Chat” row in Google Sheets so AI can handle new messages again.
Setup
- Configure the OpenWA credentials and set the correct OpenWA sessionId so the trigger and send-message action connect to your WhatsApp session.
- Add Google Gemini (PaLM/Gemini) API credentials for the chat model used by the AI agent.
- Add a Google Sheets service account credential and ensure it has access to the spreadsheet used for “Database Company” and “Session Chat.”
- Confirm the spreadsheet document ID and the two sheet tabs exist and match the workflow configuration (knowledge base tab and “Session Chat” tab with at least a chatId column).