Stale Deal Nudger
Module 15 · business · intermediate
Solutions 15 · Stale Deal Nudger
Exercise 1
- In Settings, extend
owners:{ '12345678': { name: 'Alex Rivera', slack_user_id: 'U01ABC…' }, … }. - In
Map HubSpot Deals, addowner_id: ownerIdto each deal; inGroup by Owner, addslack_user_id: $('Settings (edit me)').first().json.owners[deals[0].owner_id]?.slack_user_idto each owner item. - Replace the No Operation node with Slack → Message → Send, Send Message To User, User
{{ $json.slack_user_id }}, Text{{ $json.message }}.
The schedule path only reaches this node for owners that have stale deals, because Group by Owner only creates items for owners present in the stale list.
Exercise 2
After Group by Owner (schedule branch), add IF Monday? ({{ $now.weekday === 1 }}) → Code Manager Summary (Run Once for All Items):
const owners = $input.all().map(i => i.json);
const money = n => '$' + Math.round(n).toLocaleString('en-US');
const total = owners.reduce((s, o) => s + o.pipeline_at_risk, 0);
const top = owners.flatMap(o => o.deals).sort((a, b) => b.urgency - a.urgency).slice(0, 3);
const text = [
`📊 Weekly pipeline check: ${money(total)} at risk`,
'',
...owners.map(o => `• ${o.owner}: ${o.deal_count} stale (${money(o.pipeline_at_risk)})`),
'',
'Most urgent:',
...top.map((d, i) => `${i + 1}. ${d.name} (${d.owner}, ${money(d.amount)}, ${d.idle_days ?? '?'} days quiet)`),
].join('\n');
return [{ json: { text } }];
→ Slack/Gmail to the manager.
Exercise 3
Pipedrive branch from the schedule (parallel to HubSpot):
- Pipedrive → Deal → Get Many, Return All, filter status open.
- Code
Map Pipedrive Deals:
return $input.all().map(({ json: d }) => ({ json: {
id: String(d.id), name: d.title, stage: String(d.stage_id), amount: Number(d.value ?? 0),
owner: d.owner_name ?? 'Unassigned', contact: d.person_name ?? '',
last_activity: d.last_activity_date ?? d.update_time ?? null,
url: `https://YOURCOMPANY.pipedrive.com/deal/${d.id}`,
}}));
Pipedrive stage ids are numbers, so add them to stale_days (e.g. '3': 5). Connect the mapper to Find Stale Deals. Field names come from Pipedrive's deal object; check one real item in the node's output before relying on them (this solution hasn't been run against a live Pipedrive account).