See llms.txt for all machine-readable content.

Back to Templates

Route WhatsApp leads and location alerts with Google Sheets, Gemini, and Telegram

Quick overview

This workflow receives WhatsApp message events from Evolution API, normalizes and deduplicates them, upserts each contact into Google Sheets, detects shared locations, and routes actionable leads to Telegram using keyword rules and Google Gemini AI classification.

How it works

  1. Receives a POST webhook event from Evolution API for an incoming WhatsApp message.
  2. Normalizes the payload to extract contact details, message text, and optional latitude/longitude, then skips group/broadcast chats and messages sent by the connected WhatsApp account.
  3. Deduplicates events by WhatsApp message ID using workflow static data and logs skipped/duplicate events.
  4. Upserts the lead and latest message details into a Google Sheets “Leads” worksheet using the contact identifier as the match key.
  5. If the message includes a location pin or map link, sends a Telegram alert with the Google Maps URL and message context.
  6. Routes the message using keyword rules to immediately alert Telegram for direct visit/measurement/contract signals, ignore non-actionable greetings/price-only messages, or send relevant inquiries to Google Gemini for JSON-based lead qualification.
  7. Parses and validates the Gemini response and sends a Telegram alert for AI-qualified hot leads, otherwise logs non-hot results or falls back to conservative keyword rules and alerts Telegram when the fallback deems it actionable.

Setup

  1. Activate the workflow and configure Evolution API to POST messages.upsert events to the Webhook production URL for the whatsapp-lead-router-location-alerts path.
  2. Add a Google Sheets OAuth credential, replace REPLACE_WITH_GOOGLE_SHEET_ID, and ensure the “Leads” sheet contains the required header columns (including contact as the upsert match key).
  3. Add a Telegram bot credential and replace YOUR_TELEGRAM_CHAT_ID in all Telegram nodes with a chat/group ID where the bot is allowed to post.
  4. Add a Google Gemini (PaLM) API credential and ensure the selected Gemini model is available in your region/account for the AI qualification step.