{
  "kind": "alaskan.workflow",
  "version": 1,
  "slug": "new-lead-intro",
  "name": "New-lead intro, with approval",
  "summary": "When a lead lands in the CRM, the outbound dog reads them, checks recent news, drafts a short first email and sends it only after you approve it, then logs it on the contact.",
  "for": "Outbound and sales teams",
  "author": {
    "name": "Alaskan Labs"
  },
  "license": "MIT",
  "dog": "kodiak",
  "trigger": {
    "type": "event",
    "event": "crm.lead.created"
  },
  "nodes": [
    {
      "id": "lead",
      "type": "app",
      "title": "Read the new lead",
      "app": "hubspot",
      "action": "HUBSPOT_LIST_CONTACTS",
      "input": {
        "limit": 1,
        "sort": "-createdate"
      }
    },
    {
      "id": "news",
      "type": "news",
      "title": "Look for recent news about them",
      "query": "{{lead}}"
    },
    {
      "id": "draft",
      "type": "think",
      "title": "Draft the intro",
      "prompt": "Write a first email to this lead: under 90 words, one specific reason we're writing now (from the news or their site), one line on what {{company}} does for companies like theirs, and a plain ask for 15 minutes. No flattery and no claims we can't show. Put a subject line under seven words first."
    },
    {
      "id": "approve",
      "type": "decide",
      "kind": "send",
      "title": "Send this intro?",
      "prompt": "{{draft}}",
      "options": [
        {
          "key": "send",
          "label": "Send it"
        },
        {
          "key": "skip",
          "label": "Don't send",
          "effect": "decline"
        }
      ]
    },
    {
      "id": "send",
      "type": "app",
      "title": "Send the intro from your inbox",
      "app": "gmail",
      "action": "GMAIL_SEND_EMAIL",
      "write": true,
      "input": {
        "body": "{{draft}}"
      }
    },
    {
      "id": "log",
      "type": "app",
      "title": "Log the email on the contact",
      "app": "hubspot",
      "action": "HUBSPOT_CREATE_NOTE",
      "write": true,
      "input": {
        "note": "Intro sent: {{draft}}"
      }
    },
    {
      "id": "skipped",
      "type": "write",
      "title": "Mark the lead as skipped"
    }
  ],
  "edges": [
    [
      "lead",
      "news"
    ],
    [
      "news",
      "draft"
    ],
    [
      "draft",
      "approve"
    ],
    [
      "approve",
      "send",
      "send"
    ],
    [
      "send",
      "log"
    ],
    [
      "approve",
      "skipped",
      "skip"
    ]
  ]
}
