{
  "schema_version": "1.0.0",
  "id": "after-hours-lead-owner-text",
  "title": "Text the owner about leads that arrive after hours",
  "category": "speed-to-lead",
  "difficulty": "beginner",
  "featured": false,
  "description": "Daytime form leads go to the sales channel; leads that arrive when the office is closed text the owner directly instead.",
  "tags": [
    "speed-to-lead",
    "after-hours",
    "twilio",
    "slack",
    "google-forms"
  ],
  "apps": [
    "Google Forms",
    "Code by Zapier",
    "Paths by Zapier",
    "Slack",
    "Twilio"
  ],
  "plan": {
    "minimum": "Professional",
    "reasons": [
      "multi-step Zap: 4 steps after the trigger",
      "Paths by Zapier"
    ]
  },
  "tasks": {
    "typical": 2,
    "max": 2
  },
  "trigger": {
    "app": "Google Forms",
    "event": "New Form Response",
    "kind": "polling",
    "title": "New quote request",
    "why": "Fires for each response to the quote form.",
    "config": {
      "Form": "Request a quote"
    },
    "outputs": [
      "timestamp",
      "full_name",
      "email",
      "phone",
      "project_type",
      "budget",
      "details"
    ],
    "sample": "sample-trigger.json"
  },
  "steps": [
    {
      "key": "hours",
      "kind": "code",
      "app": "Code by Zapier",
      "event": "Run JavaScript",
      "title": "Check whether the office is open",
      "why": "Decides who should hear about this lead.",
      "code": {
        "language": "javascript",
        "module": "business-hours",
        "file": "code/business-hours.js"
      },
      "input_data": {
        "timestamp": "{{trigger.timestamp}}",
        "utc_offset": "+00:00",
        "open_time": "09:00",
        "close_time": "17:30",
        "open_days": "Mon-Fri"
      },
      "outputs": [
        "is_open",
        "local_day",
        "local_time",
        "next_open",
        "minutes_until_open"
      ]
    },
    {
      "key": "route",
      "kind": "paths",
      "app": "Paths by Zapier",
      "event": "Split into paths",
      "title": "Sales channel or owner's phone",
      "why": "Exactly one path runs: the rules test is_open both ways.",
      "paths": [
        {
          "name": "Open",
          "conditions": [
            [
              {
                "field": "{{hours.is_open}}",
                "operator": "(Boolean) Is true"
              }
            ]
          ],
          "usually": true,
          "steps": [
            {
              "key": "sales",
              "kind": "action",
              "app": "Slack",
              "event": "Send Channel Message",
              "title": "Post to the sales channel",
              "why": "The person on shift claims it with a reaction.",
              "fields": {
                "Channel": "#sales",
                "Message Text": ":inbox_tray: New quote request from {{trigger.full_name}} ({{trigger.project_type}}, budget {{trigger.budget}}). {{trigger.phone}} / {{trigger.email}}\n> {{trigger.details}}",
                "Send as a bot?": "Yes",
                "Bot Name": "Zap alerts",
                "Include a link to this Zap?": "No"
              },
              "outputs": [
                "ts",
                "permalink"
              ]
            }
          ]
        },
        {
          "name": "Closed",
          "conditions": [
            [
              {
                "field": "{{hours.is_open}}",
                "operator": "(Boolean) Is false"
              }
            ]
          ],
          "usually": false,
          "steps": [
            {
              "key": "owner",
              "kind": "action",
              "app": "Twilio",
              "event": "Send SMS",
              "title": "Text the owner",
              "why": "A short text with the essentials. The owner decides whether to reply tonight.",
              "fields": {
                "From Number": "YOUR_TWILIO_NUMBER",
                "To Number": "YOUR_MOBILE_NUMBER",
                "Message": "After-hours lead: {{trigger.full_name}}, {{trigger.project_type}}, budget {{trigger.budget}}. Call {{trigger.phone}}. Office opens {{hours.next_open}}.",
                "Send Large Messages?": "No"
              },
              "outputs": [
                "sid",
                "status"
              ]
            }
          ]
        }
      ]
    }
  ]
}
