Quick overview
Youtube Video: https://youtu.be/zuvs-7xHKNs
This workflow replies to incoming WhatsApp messages, de-duplicates and debounces them with Redis, pulls a property inventory from Google Sheets, and uses Google Gemini to qualify the lead and recommend matching listings, optionally sharing an autofilled Cal.com scheduling link.
How it works
- Triggers when a new WhatsApp message is received and extracts the sender, message ID, type, and text.
- If the message is not text, it replies in WhatsApp asking the user to send a text message instead.
- Uses Redis to ignore duplicate message IDs, buffer multiple messages from the same phone number for a short window, and only continue when the latest message is stable.
- Acquires a short Redis lock to prevent parallel processing, combines the buffered messages into one prompt, and clears the buffer.
- Looks up the contact in HighLevel and upserts the lead into HighLevel if it does not already exist.
- Reads the full property inventory from Google Sheets, aggregates it, and sends the user’s combined message plus the inventory to a Google Gemini-powered AI agent with Redis chat memory.
- Parses the agent’s JSON output and sends either a qualifying follow-up message or a property recommendation message in WhatsApp, replacing any Cal.com link with an autofilled scheduling URL when provided, then releases the Redis lock.
Setup
- Connect WhatsApp Cloud API credentials for both the WhatsApp trigger and WhatsApp send actions, and set your Phone Number ID.
- Provide a Redis connection and ensure your instance allows key TTL/expire operations for the dedup, buffer, timestamp, lock, and chat memory keys.
- Add a Google Service Account credential and update the Google Sheets document ID and sheet tab to point to your property inventory.
- Add a Google Gemini (PaLM) API credential for the chat model used by the AI agent.
- Add a HighLevel OAuth2 credential and update the HighLevel locationId and contact upsert settings to match your account.
- If you want scheduling, ensure the AI returns a valid Cal.com link and that your Cal.com event accepts the prefill query parameters used in the autofilled URL.