Score customer health and churn risk with Salesforce, Gemini, and Gmail
Quick Overview This workflow runs every minute to pull accounts from Salesforce, enrich each customer with order, payment, support, and marketing data via HTTP APIs, analyze the combined profile with Google Gemini, then update the Salesforce account and send Gmail alerts for high-risk customers and execution outcomes.
How it works Runs every minute on a schedule and retrieves up to five Salesforce Account records. Processes accounts in batches and initializes a retry counter to control fault-tolerant data fetching. Fetches customer order data via an HTTP API, retrying up to three times with a wait delay and falling back to a backup HTTP endpoint if needed. Fetches payments, support tickets, and marketing engagement for the same customer via HTTP API requests and normalizes everything into a single customer profile. Sends the unified customer profile to Google Gemini to generate a JSON assessment with health score, churn risk, customer type, a summary, and a recommended action. Parses the AI output and emails a high-risk alert via Gmail when the churn risk equals HIGH. Routes by customer type, updates the Salesforce Account description with the AI summary, then logs the result and emails a success notification via Gmail. If any workflow execution fails, sends a Gmail error notification with execution details.
Setup Connect Salesforce OAuth2 credentials and ensure the workflow has permission to read and update Account records. Connect a Google Gemini (PaLM) API credential for the Gemini model used in the customer intelligence step. Connect Gmail OAuth2 credentials and fill in the recipient email address(es) for the high-risk, success, and error notification emails. Review and replace the HTTP API endpoints (currently dummyjson.com) with your ERP/orders, payments, support, and marketing systems, ensuring they accept the customer Id parameter. Adjust the schedule interval, batch size, and retry limits to match your data volume and external API rate limits.
Related Templates
AI Email Classifier & Auto-Delete for Gmail (SPAM/OFFER Cleaner)
This workflow is designed for freelancers, solopreneurs, and business owners who receive a high volume of irrelevant mes...
Generate Product Ad Copy & CTAs with GPT-4 for Slack and Airtable
⚡ AI Copywriter Pro: Instant Ad Copy & CTA Generator Transform product details into compelling marketing copy in second...
Auto-classify Gmail emails with AI and apply labels for inbox organization
Who is this for? Professionals and individuals who receive high volumes of emails, those who want to automatically organ...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments