{
  "id": "qLDMdUJcHbSoboM2",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Churn Guardian system alert",
  "tags": [
    {
      "id": "T75wN7b2Y1Q2X3nH",
      "name": "alert",
      "createdAt": "2025-11-20T18:06:09.140Z",
      "updatedAt": "2025-11-20T18:06:09.140Z"
    },
    {
      "id": "S94PaeZJiPKn5Ei9",
      "name": "gmail",
      "createdAt": "2025-08-14T09:57:18.678Z",
      "updatedAt": "2025-08-14T09:57:18.678Z"
    },
    {
      "id": "5iQR5Cw05Bzz7Aqt",
      "name": "Google",
      "createdAt": "2025-08-02T17:36:32.751Z",
      "updatedAt": "2025-08-02T17:36:32.751Z"
    },
    {
      "id": "IUTR4oS3KHYPxOqH",
      "name": "Jira",
      "createdAt": "2025-11-14T09:45:17.977Z",
      "updatedAt": "2025-11-14T09:45:17.977Z"
    },
    {
      "id": "6YEf66QgUoe2H0xV",
      "name": "postgresql",
      "createdAt": "2025-11-20T18:05:52.192Z",
      "updatedAt": "2025-11-20T18:05:52.192Z"
    },
    {
      "id": "bX1tZbypCr5HBJMz",
      "name": "product management",
      "createdAt": "2025-11-20T18:06:00.432Z",
      "updatedAt": "2025-11-20T18:06:00.432Z"
    },
    {
      "id": "rYuINsb3Y1XjrgNv",
      "name": "Productivity",
      "createdAt": "2025-08-02T17:36:49.812Z",
      "updatedAt": "2025-08-02T17:36:49.812Z"
    },
    {
      "id": "SenQnwINjVwewgLY",
      "name": "slack",
      "createdAt": "2025-11-20T18:05:28.955Z",
      "updatedAt": "2025-11-20T18:05:28.955Z"
    },
    {
      "id": "qCgJLisgQ1EsyJ62",
      "name": "sql",
      "createdAt": "2025-11-20T18:05:47.931Z",
      "updatedAt": "2025-11-20T18:05:47.931Z"
    }
  ],
  "nodes": [
    {
      "id": "49dfb1d2-fdbe-4194-bebe-0d4f238e36a8",
      "name": "analytivcs",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1008,
        -1040
      ],
      "parameters": {
        "url": "yoururl",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "2560c73a-16ad-4562-9220-d7d551cc610c",
      "name": "Get data related to an organization",
      "type": "n8n-nodes-base.zendesk",
      "position": [
        1008,
        -1216
      ],
      "parameters": {
        "id": "yourid",
        "resource": "organization",
        "operation": "getRelatedData"
      },
      "credentials": {
        "zendeskApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "15771604-4a77-4949-a795-7ad36c9ff49e",
      "name": "daily trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -416,
        -656
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5bee940e-4d55-4e9c-994a-a6d05ea7a6a2",
      "name": "Init config & thresholds",
      "type": "n8n-nodes-base.set",
      "position": [
        -256,
        -656
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "41767b1d-f392-467c-9c59-f77f13ea2b92",
              "name": "days_before_renewal",
              "type": "number",
              "value": "=30"
            },
            {
              "id": "c8572dd7-b155-4ad1-a4c4-b069058df6b1",
              "name": "churn_threshold_high",
              "type": "number",
              "value": "=0.7"
            },
            {
              "id": "159c7e9e-d79b-483c-9f16-ef3eed4be4e3",
              "name": "churn_threshold_medium",
              "type": "number",
              "value": "=0.4"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "246b9e8f-90cc-406d-bd25-299af7d82c5e",
      "name": "Fetch subscriptions expiring in J+30",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -80,
        -656
      ],
      "parameters": {
        "query": "SELECT\n  a.id          AS \"accountId\",\n  a.name        AS \"account_name\",\n  s.id          AS \"subscriptionId\",\n  s.end_date    AS \"endDate\",\n  s.status      AS \"subscription_status\",\n  s.mrr         AS \"mrr\",\n  s.plan        AS \"plan\"\nFROM subscriptions s\nJOIN accounts a\n  ON a.id = s.account_id\nWHERE s.status = 'active'\n  AND s.end_date = CURRENT_DATE + INTERVAL '30 day';\n",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.6
    },
    {
      "id": "33147bfe-52fd-41ee-8660-dc7e24ef16cd",
      "name": "Process subscriptions in batches",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        176,
        -656
      ],
      "parameters": {
        "options": {},
        "batchSize": 50
      },
      "typeVersion": 3
    },
    {
      "id": "929935d7-d621-459d-9c88-3462be51ecb0",
      "name": "HubSpot \u2013 Get engagement history",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        1008,
        -160
      ],
      "parameters": {
        "resource": "engagement",
        "operation": "getAll",
        "authentication": "oAuth2"
      },
      "credentials": {
        "hubspotOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "3e4ea5c2-bbd9-47ac-b349-b4cd41ad3560",
      "name": "Salesforce \u2013 Get account details",
      "type": "n8n-nodes-base.salesforce",
      "position": [
        1008,
        -336
      ],
      "parameters": {
        "options": {},
        "resource": "account",
        "operation": "getAll"
      },
      "credentials": {
        "salesforceOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fef8bece-356e-4725-a9a6-e20bb29fb241",
      "name": "Pipedrive \u2013 Get deal activities",
      "type": "n8n-nodes-base.pipedrive",
      "position": [
        1008,
        -512
      ],
      "parameters": {
        "dealId": "=",
        "resource": "dealActivity",
        "additionalFields": {}
      },
      "credentials": {
        "pipedriveApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "28368900-b3f3-413d-8b75-8d203b3dcc8d",
      "name": "Pipedrive \u2013 Get deal products",
      "type": "n8n-nodes-base.pipedrive",
      "position": [
        1008,
        -688
      ],
      "parameters": {
        "dealId": "name",
        "resource": "dealProduct",
        "operation": "getAll"
      },
      "credentials": {
        "pipedriveApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d5e39346-2718-4fa1-87e1-2d03a532449a",
      "name": "Analytics API \u2013 Feature usage",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1008,
        -880
      ],
      "parameters": {
        "url": "yoururl",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "d79baeb7-bb15-4346-b141-39eb85cca84c",
      "name": "Scoring API \u2013 Call",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1632,
        -752
      ],
      "parameters": {
        "url": "youturl",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "churn_score",
              "value": "=0-1"
            },
            {
              "name": "churn_label",
              "value": "=Low/Medium/High"
            },
            {
              "name": "top_reasons",
              "value": "explantation"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "6d2fa675-a9fa-464f-a1ba-58236528ab6d",
      "name": "Normalize scoring response",
      "type": "n8n-nodes-base.set",
      "position": [
        1952,
        -752
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ef2b85af-cf2f-42c6-adf9-587c3e4ee131",
              "name": "engagementScore",
              "type": "number",
              "value": "={{$json.engagement || 0}}"
            },
            {
              "id": "20c1197c-0966-4bcd-8af0-56f3d305dc6c",
              "name": "productUsage",
              "type": "number",
              "value": "={{$json.active_users || 0}}"
            },
            {
              "id": "7b83b210-063b-4ab4-b453-7d06466cfa6c",
              "name": "nbSupportTicketsLast30d",
              "type": "number",
              "value": "={{$json.tickets_last_30d || 0}}"
            },
            {
              "id": "11275367-16c9-45ec-87b0-40c834672c78",
              "name": "daysSinceLastActivity",
              "type": "number",
              "value": "={{$json.days_since_last_activity || 0}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4c931a93-0afe-417b-9a45-aed742d1c0e0",
      "name": "Compute churn score & level",
      "type": "n8n-nodes-base.set",
      "position": [
        2128,
        -752
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "42416ec1-a587-406a-b8d6-fe84b224cf65",
              "name": "riskScore",
              "type": "number",
              "value": "={{ (\n  ($json.engagementScore ?? 0) * 0.4 +\n  ($json.productUsage ?? 0) * 0.3 +\n  ($json.nbSupportTicketsLast30d > 5 ? 0.2 : 0) +\n  ($json.daysSinceLastActivity > 14 ? 0.1 : 0)\n).toFixed(2) }}"
            },
            {
              "id": "c6c0658e-81b6-4329-a7c3-3c734be573d6",
              "name": "riskLevel",
              "type": "string",
              "value": "={{ \n  $json.riskScore >= $json.churn_threshold_high\n    ? 'HIGH'\n    : $json.riskScore >= $json.churn_threshold_medium\n      ? 'MEDIUM'\n      : 'LOW'\n}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "bc529846-4d68-407c-8f6d-ff463067555d",
      "name": "Route by churn risk (HIGH / MEDIUM / LOW)",
      "type": "n8n-nodes-base.switch",
      "position": [
        2320,
        -768
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "73ec783c-e91d-41cd-a7e6-a07780defd32",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$json.riskLevel}}",
                    "rightValue": "High"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "91de0e08-d240-4f88-a7fc-6e6a22b50c26",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$json.riskLevel}}",
                    "rightValue": "Medium"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "34a9507c-ceb1-48af-b213-8a934695cf8d",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$json.riskLevel}}",
                    "rightValue": "Low"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.3
    },
    {
      "id": "62b9106e-e07c-4e85-91b1-a97c228c2fe0",
      "name": "Build daily summary",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        4064,
        -768
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "renameField": true,
              "outputFieldName": "summaryText",
              "fieldToAggregate": "summaryLine"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8c11718d-f6cf-4bb9-8b40-b37020d70829",
      "name": "Email \u2013 LOW info",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2832,
        -288
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=Hi {{ $json.csm_name || \"team\" }},  {{$json.account_name}} is classified as LOW risk for the upcoming renewal on {{$json.end_date}}.  Everything looks stable:  Good engagement  Usage within normal range  No critical support issues  A gentle renewal follow-up is recommended to maintain momentum.  Thanks,",
        "options": {},
        "subject": "Renewal preparation \u2014 {{$json.account_name}} (Low risk)"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "765cd687-4336-41ca-a786-3582d6864da5",
      "name": "Email \u2013 CSM/AM HIGH",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3136,
        -1104
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=Hi {{ $json.csm_name || \"team\" }},\n\nA high churn risk has been detected for {{$json.account_name}}, whose renewal is scheduled on {{$json.end_date}}.\n\nKey signals indicate a significant risk of non-renewal.\nHere\u2019s a quick summary:\n\nAccount: {{$json.account_name}}\n\nRenewal date: {{$json.end_date}}\n\nRisk level: HIGH\n\nChurn score: {{$json.riskScore}}\n\nLast activity: {{$json.lastActivity || \"N/A\"}}\n\nActive users: {{$json.activeUsers}} / {{$json.nbUsers}}\n\nRecommended actions (priority)\n\nSchedule an immediate check-in call with the customer\n\nReview current adoption blockers & open support tickets\n\nPropose a quick-win action plan and validate timelines\n\nAlign internally on renewal strategy (CS + AM)\n\nThe workflow has generated:\n\nA Jira ticket for follow-up\n\nA Trello card in the High-Risk board\n\nA Slack alert for visibility\nThanks,",
        "options": {},
        "subject": "Urgent \u2014 High churn risk detected for {{$json.account_name}}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "8c3b83ce-9b58-429c-98f2-6fdddc9e92ea",
      "name": "Email \u2013 CSM/ AM MEDIUM",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3024,
        -752
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=Hi {{ $json.csm_name || \"team\" }},  A moderate churn risk has been identified for {{$json.account_name}}, with renewal scheduled on {{$json.end_date}}.  Here are the main indicators:  Risk level: MEDIUM  Churn score: {{$json.riskScore}}  Usage trend: {{$json.usageTrend || \"check dashboard\"}}  Engagement: {{$json.engagementLevel || \"unknown\"}}  Next steps  This account doesn\u2019t require an urgent action, but a proactive touchpoint is recommended:  Send a quick message to check satisfaction  Review product usage with the customer  Address potential blockers before renewal  A Trello card has been created in the Medium Priority board.  Thanks,",
        "options": {},
        "subject": "Moderate churn risk identified \u2014 {{$json.account_name}}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "9510c3d2-f8bb-49ff-b305-7ada910f1f3b",
      "name": "jira ticket",
      "type": "n8n-nodes-base.jira",
      "position": [
        2768,
        -1104
      ],
      "parameters": {
        "project": {
          "__rl": true,
          "mode": "list",
          "value": "10002",
          "cachedResultName": "test2"
        },
        "summary": "=",
        "issueType": {
          "__rl": true,
          "mode": "list",
          "value": "10014",
          "cachedResultName": "Story"
        },
        "additionalFields": {
          "priority": {
            "__rl": true,
            "mode": "list",
            "value": "2",
            "cachedResultName": "High"
          }
        }
      },
      "credentials": {
        "jiraSoftwareCloudApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "268fb051-179d-4a6a-8294-e731a913e861",
      "name": "Slack notification",
      "type": "n8n-nodes-base.slack",
      "position": [
        2944,
        -1104
      ],
      "parameters": {
        "text": "Alert: risk of churn",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09V1228324",
          "cachedResultName": "tous-n8n"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "0d8efc47-8f7a-483e-98a7-f174ce619eba",
      "name": "Data personalisation",
      "type": "n8n-nodes-base.noOp",
      "position": [
        464,
        -672
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "50ffe277-88cd-48b5-9c6a-0eeb9f51165e",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -1232
      ],
      "parameters": {
        "width": 384,
        "height": 1264,
        "content": "## How it works\n\nThis workflow prevents churn by automatically identifying B2B/SaaS accounts whose licenses will expire in 30 days (J\u201330), enriching them with CRM, product usage and support data, scoring their churn risk, and triggering the appropriate playbook depending on the severity.\n\nEvery morning, the system queries your Postgres database to fetch all accounts with subscriptions ending in 30 days. For each account, it retrieves data from HubSpot, Salesforce, Pipedrive, analytics APIs and Zendesk. A scoring step computes a churn risk level (HIGH, MEDIUM, LOW) based on engagement, product usage, recent activity and support friction.\n\nIf the risk is LOW, the workflow only sends a soft renewal reminder.\nIf the risk is MEDIUM, it creates a Trello follow-up card and notifies the CSM.\nIf the risk is HIGH, it escalates automatically: Trello + Jira issue + Slack alert + emails to CSM and manager.\n\nEvery action is logged into Postgres, and a daily summary email is sent to the success team to review all processed accounts.\n\n## Requirements\n\n- Database: a table with a schema adapted to store workflow decisions\n- External APIs\n- HubSpot (engagement data)\n- Salesforce (account profile)\n- Pipedrive (deal activities & products)\n- Zendesk \n - **Communication Tools:**\n- Gmail \n- Slack \n- Trello \n- Jira \n"
      },
      "typeVersion": 1
    },
    {
      "id": "571f5cec-f32e-4f37-a451-f124cf194439",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        -1232
      ],
      "parameters": {
        "color": 7,
        "width": 2048,
        "height": 1264,
        "content": "## Data flow\n\nEvery morning, the system:\n\n- Queries Postgres to retrieve subscriptions expiring in J\u201330\n- Enriches each account with data from:\n- HubSpot (engagement)\n- Salesforce (account profile)\n- Pipedrive (deal activities & products)\n- Analytics API (feature usage)\n- Zendesk (support tickets)\n- Merges everything, computes the churn score, and routes the account through the proper playbook.\n- All enriched records flow into a unified scoring and decision engine."
      },
      "typeVersion": 1
    },
    {
      "id": "3fd9aaeb-800f-47bc-8f28-adc954b86c9c",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1616,
        -1232
      ],
      "parameters": {
        "color": 7,
        "width": 2896,
        "height": 1264,
        "content": "## Logging & Extensibility\n\nFor every processed account, the workflow stores a structured log entry in Postgres containing:\n- account_id & name\n- end date\n- riskScore & riskLevel\n- selected playbook\n- Trello/Jira links\n- timestamp & execution_id\n- A daily digest email summarizes all accounts processed.\n- This logging layer also makes the system extendable: dashboards, reports, AI analysis or additional automations can be plugged"
      },
      "typeVersion": 1
    },
    {
      "id": "79301630-a202-448a-be94-716d6c8d54c5",
      "name": "Prepare log payload",
      "type": "n8n-nodes-base.set",
      "position": [
        3488,
        -768
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7602ba53-e0ae-4d7b-a6ae-21746c9f8298",
              "name": "log_account_id",
              "type": "string",
              "value": "={{$json.accountId}}"
            },
            {
              "id": "016dedd9-4fa6-445c-9855-40cecfcc6f68",
              "name": "log_account_name",
              "type": "string",
              "value": "={{$json.accountName || $json.account_name}}"
            },
            {
              "id": "d6e7d3a4-e9b3-4e69-816c-5f5ac055daec",
              "name": "log_end_date",
              "type": "string",
              "value": "{{$json.endDate}}"
            },
            {
              "id": "0e8c9aae-02dd-414d-ade0-796056e88506",
              "name": "log_riskScore",
              "type": "string",
              "value": "={{$json.riskScore}}"
            },
            {
              "id": "e1ba3f03-f4fc-4b05-b5ff-838aa2dc4d99",
              "name": "log_riskLevel",
              "type": "string",
              "value": "={{$json.riskLevel}}"
            },
            {
              "id": "dbe3885d-cc3f-435c-909c-ba011ce55f8d",
              "name": "log_playbook",
              "type": "string",
              "value": "={{$json.riskLevel}}"
            },
            {
              "id": "8df48453-7f7e-4d17-8215-c95462dae144",
              "name": "log_trello_card",
              "type": "string",
              "value": "={{$json.trelloCardUrl || ''}}"
            },
            {
              "id": "df1039c2-abcb-4bf1-9802-d66783095480",
              "name": "log_jira_issue",
              "type": "string",
              "value": "={{$json.jiraIssueUrl || ''}}"
            },
            {
              "id": "a1bb98fa-ae12-4729-ae95-fb9f9a4798ad",
              "name": "log_timestamp",
              "type": "string",
              "value": "={{$now}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "32cf2ab9-e202-4452-a7e8-3e759f6f46a1",
      "name": "Build summary line",
      "type": "n8n-nodes-base.set",
      "position": [
        3888,
        -768
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c9e79c86-159c-4d07-92d9-614d4c020c6f",
              "name": "summaryLine",
              "type": "string",
              "value": "={{ $json.account_name + ' \u2013 ' + $json.riskLevel + ' \u2013 ' + $json.riskScore }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1b3a5d38-f973-4165-b674-d07a6f05d527",
      "name": "Engagement call",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1792,
        -752
      ],
      "parameters": {
        "url": "yoururl",
        "options": {},
        "sendQuery": true,
        "specifyQuery": "={\n \"engagement\": \"{{$json.engagement}}\",\n \"nb_users\": \"{{$json.nbUsers}}\",\n \"active_users\": \"{{$json.activeUsers}}\",\n \"days_since_last_activity\": \"{{$json.daysInactive}}\"\n}\n",
        "queryParameters": {
          "parameters": [
            {}
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "c00d4c50-0f22-4f28-ad8f-2d439554d112",
      "name": "Reporting email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        4272,
        -768
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=Hello, \n\nHere are the accounts treated today:\n{{ $json.summaryText }}\n",
        "options": {},
        "subject": "The account treated today"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "ca443b92-1bb9-49f9-864f-13e660ca5112",
      "name": "prepare daily summary",
      "type": "n8n-nodes-base.postgres",
      "position": [
        3680,
        -768
      ],
      "parameters": {
        "table": {
          "__rl": true,
          "mode": "name",
          "value": "=churn_logs"
        },
        "schema": {
          "__rl": true,
          "mode": "name",
          "value": "public"
        },
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.6
    },
    {
      "id": "4af9cfc9-12d6-4f88-88aa-98dad4b56d39",
      "name": "Trello Create MEDIUM risk card1",
      "type": "n8n-nodes-base.trello",
      "position": [
        2672,
        -752
      ],
      "parameters": {
        "name": "name",
        "listId": "yourid",
        "additionalFields": {}
      },
      "credentials": {
        "trelloApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "71ae0366-e8cc-4110-be6b-16438d1724a8",
      "name": "Trello Create HIGH risk card",
      "type": "n8n-nodes-base.trello",
      "position": [
        2592,
        -1104
      ],
      "parameters": {
        "name": "name",
        "listId": "yourid",
        "additionalFields": {}
      },
      "credentials": {
        "trelloApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4f66e58c-88c9-4d9d-b8c5-2949460384b2",
      "name": "Data merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        1440,
        -832
      ],
      "parameters": {
        "numberInputs": 7
      },
      "typeVersion": 3.2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "6f41882c-d350-4b2e-bb6c-b9f16f3ad01d",
  "connections": {
    "Data merge": {
      "main": [
        [
          {
            "node": "Scoring API \u2013 Call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "analytivcs": {
      "main": [
        [
          {
            "node": "Data merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "jira ticket": {
      "main": [
        [
          {
            "node": "Slack notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "daily trigger": {
      "main": [
        [
          {
            "node": "Init config & thresholds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Engagement call": {
      "main": [
        [
          {
            "node": "Normalize scoring response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build summary line": {
      "main": [
        [
          {
            "node": "Build daily summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email \u2013 LOW info": {
      "main": [
        [
          {
            "node": "Prepare log payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack notification": {
      "main": [
        [
          {
            "node": "Email \u2013 CSM/AM HIGH",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build daily summary": {
      "main": [
        [
          {
            "node": "Reporting email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare log payload": {
      "main": [
        [
          {
            "node": "prepare daily summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data personalisation": {
      "main": [
        [
          {
            "node": "HubSpot \u2013 Get engagement history",
            "type": "main",
            "index": 0
          },
          {
            "node": "Salesforce \u2013 Get account details",
            "type": "main",
            "index": 0
          },
          {
            "node": "Pipedrive \u2013 Get deal activities",
            "type": "main",
            "index": 0
          },
          {
            "node": "Pipedrive \u2013 Get deal products",
            "type": "main",
            "index": 0
          },
          {
            "node": "Analytics API \u2013 Feature usage",
            "type": "main",
            "index": 0
          },
          {
            "node": "analytivcs",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get data related to an organization",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scoring API \u2013 Call": {
      "main": [
        [
          {
            "node": "Engagement call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email \u2013 CSM/AM HIGH": {
      "main": [
        [
          {
            "node": "Prepare log payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "prepare daily summary": {
      "main": [
        [
          {
            "node": "Build summary line",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email \u2013 CSM/ AM MEDIUM": {
      "main": [
        [
          {
            "node": "Prepare log payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Init config & thresholds": {
      "main": [
        [
          {
            "node": "Fetch subscriptions expiring in J+30",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize scoring response": {
      "main": [
        [
          {
            "node": "Compute churn score & level",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compute churn score & level": {
      "main": [
        [
          {
            "node": "Route by churn risk (HIGH / MEDIUM / LOW)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trello Create HIGH risk card": {
      "main": [
        [
          {
            "node": "jira ticket",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analytics API \u2013 Feature usage": {
      "main": [
        [
          {
            "node": "Data merge",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Pipedrive \u2013 Get deal products": {
      "main": [
        [
          {
            "node": "Data merge",
            "type": "main",
            "index": 3
          }
        ]
      ]
    },
    "Trello Create MEDIUM risk card1": {
      "main": [
        [
          {
            "node": "Email \u2013 CSM/ AM MEDIUM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process subscriptions in batches": {
      "main": [
        [
          {
            "node": "Data personalisation",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Pipedrive \u2013 Get deal activities": {
      "main": [
        [
          {
            "node": "Data merge",
            "type": "main",
            "index": 4
          }
        ]
      ]
    },
    "HubSpot \u2013 Get engagement history": {
      "main": [
        [
          {
            "node": "Data merge",
            "type": "main",
            "index": 6
          }
        ]
      ]
    },
    "Salesforce \u2013 Get account details": {
      "main": [
        [
          {
            "node": "Data merge",
            "type": "main",
            "index": 5
          }
        ]
      ]
    },
    "Get data related to an organization": {
      "main": [
        [
          {
            "node": "Data merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch subscriptions expiring in J+30": {
      "main": [
        [
          {
            "node": "Process subscriptions in batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by churn risk (HIGH / MEDIUM / LOW)": {
      "main": [
        [
          {
            "node": "Trello Create HIGH risk card",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Trello Create MEDIUM risk card1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Email \u2013 LOW info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}