{
  "kind": "alaskan.workflow",
  "version": 1,
  "slug": "crm-hygiene-sweep",
  "name": "CRM hygiene sweep",
  "summary": "Every weekday at 5 the CRM dog turns the day's call notes into stage, amount and next-step changes, flags anything the notes don't support, and applies them after one yes.",
  "for": "Agencies and sales teams",
  "author": {
    "name": "Alaskan Labs"
  },
  "license": "MIT",
  "dog": "skagway",
  "trigger": {
    "type": "schedule",
    "when": "weekdays 17:00"
  },
  "nodes": [
    {
      "id": "calls",
      "type": "app",
      "title": "Read today's call notes",
      "app": "hubspot",
      "action": "HUBSPOT_LIST_CALLS",
      "input": {
        "since": "today"
      }
    },
    {
      "id": "deals",
      "type": "app",
      "title": "Read the open deals",
      "app": "hubspot",
      "action": "HUBSPOT_LIST_DEALS",
      "input": {
        "stage": "open"
      }
    },
    {
      "id": "changes",
      "type": "think",
      "title": "Work out the updates",
      "prompt": "From today's call notes, list every CRM change they imply: deal stage, amount, close date, next step and new contacts. One line each: record, field, from, to. Flag anything the notes don't clearly support."
    },
    {
      "id": "check",
      "type": "branch",
      "title": "Any changes?"
    },
    {
      "id": "approve",
      "type": "decide",
      "kind": "update",
      "title": "Apply today's CRM updates?",
      "prompt": "{{changes}}",
      "options": [
        {
          "key": "all",
          "label": "Apply all"
        },
        {
          "key": "unflagged",
          "label": "All but the flagged ones"
        },
        {
          "key": "skip",
          "label": "Don't apply",
          "effect": "decline"
        }
      ]
    },
    {
      "id": "apply",
      "type": "app",
      "title": "Apply the updates",
      "app": "hubspot",
      "action": "HUBSPOT_UPDATE_DEAL",
      "write": true,
      "input": {
        "changes": "{{changes}}"
      }
    },
    {
      "id": "apply-some",
      "type": "app",
      "title": "Apply the unflagged updates",
      "app": "hubspot",
      "action": "HUBSPOT_UPDATE_DEAL",
      "write": true,
      "input": {
        "changes": "{{changes}}",
        "skip": "flagged"
      }
    },
    {
      "id": "log",
      "type": "write",
      "title": "Log the sweep"
    }
  ],
  "edges": [
    [
      "calls",
      "deals"
    ],
    [
      "deals",
      "changes"
    ],
    [
      "changes",
      "check"
    ],
    [
      "check",
      "approve",
      "found"
    ],
    [
      "check",
      "log",
      "empty"
    ],
    [
      "approve",
      "apply",
      "all"
    ],
    [
      "approve",
      "apply-some",
      "unflagged"
    ],
    [
      "approve",
      "log",
      "skip"
    ],
    [
      "apply",
      "log"
    ],
    [
      "apply-some",
      "log"
    ]
  ]
}
