Quick overview
This scheduled workflow pulls last week’s Salesforce opportunities, tasks, and events for a specific rep, computes activity and pipeline health metrics, uses Groq (LLM) to generate coaching insights, creates a QuickChart performance chart URL, and emails a weekly behavioral report via Gmail.
How it works
- Runs weekly on a schedule.
- Retrieves a target Salesforce user and queries that user’s opportunities with activity in the last week.
- Builds an Opportunity ID list, then pulls related Salesforce Tasks and Events and merges them into a single activity stream alongside the opportunities.
- Calculates per-opportunity engagement metrics (touches, calls, emails, follow-ups, meetings) and the days since last activity based on activity subjects and dates.
- Aggregates the opportunity metrics into per-rep totals including revenue, won/lost deals, and a stale-deal count based on activity gaps.
- Generates a QuickChart URL visualizing weekly activity versus outcomes and sends the rep metrics to Groq to produce structured coaching insights.
- Combines the chart and AI insights and sends an HTML weekly coaching email through Gmail.
Setup
- Connect Salesforce OAuth2 credentials and set the Salesforce User ID used by the workflow to identify the rep.
- Verify or adjust the Salesforce opportunity query filters (for example LAST_WEEK and OwnerId) to match your reporting needs.
- Connect Groq API credentials for the LLM and keep the structured output schema as-is (or update it if you change the email fields).
- Connect Gmail OAuth2 credentials and set the email recipients and sender settings in the Gmail node.
- Ensure your Salesforce Task/Event subjects follow predictable keywords (call, email, follow-up, demo/meeting) or update the classifier logic to match your activity naming conventions.
Additional info
How To Customize Nodes
- Activity Keywords: Edit the
classifyActivity function in the Compute Opportunity Activity Metrics node to include your company’s specific Salesforce naming conventions (e.g., adding "Intro Zoom" to the "meeting" category).
- Chart Aesthetics: In the Generate Performance Chart URL node, you can modify the
backgroundColor values or change the type from "bar" to "radar" or "line" for a different visual style.
- Alternative AI Models: If you reach rate limits on Groq, you can switch the LLM Model node to use
llama3-70b-8192 or mixtral-8x7b-32768.
Add‑ons
- Manager CC: Add a "CC" address to the Send Weekly Coaching Email node so a manager can stay informed of the rep’s self-improvement goals.
- Slack Summaries: Add a Slack node after the AI analysis to post a "Win of the Week" summary to a team channel.
- Opportunity Filtering: Modify the SOQL query in the Fetch Opportunities node to only analyze "High Value" deals (e.g.,
Amount > 10000).
Use Case Examples
- Stale Deal Recovery: Identifying which deals haven't been touched in 7+ days and creating an immediate follow-up plan.
- Prospecting Quality Check: Analyzing the ratio of outreach (Emails/Calls) to Meetings to see if the rep's messaging needs adjustment.
- Funnel Balance: Spotting "New-Lead Bias" where a rep is so focused on new outreach that they forget to close existing meetings.
- Closing Friction Analysis: Identifying cases where a rep has many meetings but low "Won" rates, signaling a need for objection-handling training.
- Weekly Goal Setting: Using the "Next Week Action Plan" generated by AI to set measurable targets for the team stand-up.
Troubleshooting Guide
| Issue |
Possible Cause |
Solution |
| No opportunities found |
Incorrect Salesforce User ID |
Ensure the Get user node is successfully retrieving your recent Salesforce items. |
| Chart image is broken |
Invalid Chart Configuration |
Check the Generate Performance Chart URL node for any syntax errors in the JSON config sent to QuickChart. |
| AI node returns error |
Groq API Rate Limit |
Increase the delay between runs or switch to a different Groq model in the LLM Model node. |
| Email fails to send |
Gmail OAuth expired |
Re-authenticate your Gmail credentials in the n8n settings. |
Need Help?
Analyzing sales behavior is a complex task that requires clean data and precise AI prompting. If you need help refining your Salesforce SOQL queries, adjusting the behavioral metrics or integrating this report into a larger sales dashboard, our n8n workflow development experts are ready to assist.
Contact WeblineIndia to help you build, customize or scale your sales automation and AI coaching tools today!