{
  "name": "01 · Wholesale · Inquiry intake",
  "nodes": [
    {
      "id": "d836a2f3-e338-44f1-a836-a2f3e33874f1",
      "name": "About this workflow",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -260
      ],
      "parameters": {
        "content": "## 01 · Wholesale · Inquiry intake\nA café fills in the wholesale form. Within a minute it is in HubSpot with a fit score, and it has an answer that suits its size: a call with the owner, the price list, or a pointer to the subscription.\n\nA sample from work-with-nick.com/n8n. Fictional business; connect your own credentials before running it.",
        "width": 560,
        "height": 186,
        "color": 5
      }
    },
    {
      "id": "9f001121-6d6a-44ff-af00-11216d6ac4ff",
      "name": "Wholesale inquiry form",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "formTitle": "Wholesale coffee for your business",
        "formDescription": "Tell us a little about your café, restaurant or shop. Maya, our owner, reads every one, and you will hear back by email within the hour.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Business name",
              "requiredField": true
            },
            {
              "fieldLabel": "Your name",
              "requiredField": true
            },
            {
              "fieldLabel": "Email",
              "fieldType": "email",
              "requiredField": true
            },
            {
              "fieldLabel": "Business type",
              "fieldType": "dropdown",
              "requiredField": true,
              "fieldOptions": {
                "values": [
                  {
                    "option": "Café or coffee shop"
                  },
                  {
                    "option": "Restaurant"
                  },
                  {
                    "option": "Grocery or retail"
                  },
                  {
                    "option": "Office"
                  },
                  {
                    "option": "Other"
                  }
                ]
              }
            },
            {
              "fieldLabel": "Coffee per week (lbs)",
              "fieldType": "number",
              "requiredField": true
            },
            {
              "fieldLabel": "City and state"
            },
            {
              "fieldLabel": "Mostly espresso or brewed?",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Mostly espresso"
                  },
                  {
                    "option": "Mostly brewed"
                  },
                  {
                    "option": "About half and half"
                  }
                ]
              }
            },
            {
              "fieldLabel": "Anything else?",
              "fieldType": "textarea"
            }
          ]
        },
        "responseMode": "onReceived",
        "options": {
          "appendAttribution": false,
          "ignoreBots": true,
          "useWorkflowTimezone": true,
          "respondWithOptions": {
            "values": {
              "formSubmittedText": "Thanks! Maya will be in touch by email shortly."
            }
          }
        }
      },
      "webhookId": "6f0e4f43-1c0b-4c3e-9d0a-wholesale0001"
    },
    {
      "id": "d129de18-6ad3-4afc-a129-de186ad31afc",
      "name": "Clean up the answers",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        260,
        0
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a-0001",
              "name": "business_name",
              "value": "={{ $json['Business name'].trim() }}",
              "type": "string"
            },
            {
              "id": "a-0002",
              "name": "contact_name",
              "value": "={{ $json['Your name'].trim() }}",
              "type": "string"
            },
            {
              "id": "a-0003",
              "name": "first_name",
              "value": "={{ $json['Your name'].trim().split(' ')[0] }}",
              "type": "string"
            },
            {
              "id": "a-0004",
              "name": "email",
              "value": "={{ $json.Email.trim().toLowerCase() }}",
              "type": "string"
            },
            {
              "id": "a-0005",
              "name": "business_type",
              "value": "={{ $json['Business type'] }}",
              "type": "string"
            },
            {
              "id": "a-0006",
              "name": "lbs_per_week",
              "value": "={{ Number($json['Coffee per week (lbs)']) }}",
              "type": "number"
            },
            {
              "id": "a-0007",
              "name": "location",
              "value": "={{ $json['City and state'].trim() }}",
              "type": "string"
            },
            {
              "id": "a-0008",
              "name": "focus",
              "value": "={{ $json['Mostly espresso or brewed?'] }}",
              "type": "string"
            },
            {
              "id": "a-0009",
              "name": "message",
              "value": "={{ $json['Anything else?'].trim() }}",
              "type": "string"
            },
            {
              "id": "a-000a",
              "name": "submitted_at",
              "value": "={{ $json.submittedAt }}",
              "type": "string"
            },
            {
              "id": "a-000b",
              "name": "source",
              "value": "wholesale-form",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "9dfb1e6f-2c7e-447b-adfb-1e6f2c7ea47b",
      "name": "Score the fit",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        520,
        0
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Code node, JavaScript, Mode: Run Once for Each Item.\n// $input.item is the item being processed; return one item back.\nconst j = $input.item.json;\nconst lbs = Number(j.lbs_per_week) || 0;\n\n// Volume carries most of the score. Wholesale pricing starts at 10 lb a week,\n// and 50 lb a week is a café that reorders every Monday.\nlet score = Math.min(Math.round(lbs * 1.2), 60);\n\nconst typePoints = {\n  'Café or coffee shop': 25,\n  'Restaurant': 15,\n  'Grocery or retail': 15,\n  'Office': 10,\n};\nscore += typePoints[j.business_type] ?? 5;\n\n// Espresso bars reorder like clockwork and need the most training, so\n// Maya wants to meet them in person.\nif (j.focus === 'Mostly espresso') score += 15;\nscore = Math.min(score, 100);\n\nconst tier = lbs >= 30 || score >= 70 ? 'priority'\n  : lbs >= 10 ? 'standard'\n  : 'small';\n\nreturn { json: { ...j, fit_score: score, tier } };"
      }
    },
    {
      "id": "2cde979a-a742-4f7e-acde-979aa7426f7e",
      "name": "Add to HubSpot",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.1,
      "position": [
        780,
        0
      ],
      "parameters": {
        "authentication": "appToken",
        "resource": "contact",
        "operation": "upsert",
        "email": "={{ $json.email }}",
        "additionalFields": {
          "companyName": "={{ $json.business_name }}",
          "firstName": "={{ $json.first_name }}",
          "lifeCycleStage": "lead",
          "customPropertiesUi": {
            "customPropertiesValues": [
              {
                "property": "wholesale_fit_score",
                "value": "={{ $json.fit_score }}"
              },
              {
                "property": "lbs_per_week",
                "value": "={{ $json.lbs_per_week }}"
              }
            ]
          }
        }
      },
      "credentials": {
        "hubspotAppToken": {
          "id": "70399e4109894a",
          "name": "Copperleaf HubSpot (app token)"
        }
      },
      "onError": "continueErrorOutput"
    },
    {
      "id": "eb2af1d7-cd80-4773-ab2a-f1d7cd80f773",
      "name": "Tell #wholesale HubSpot missed it",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        1040,
        200
      ],
      "parameters": {
        "authentication": "oAuth2",
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "#wholesale",
          "mode": "name"
        },
        "text": "=HubSpot did not take {{ $('Score the fit').item.json.business_name }} ({{ $('Score the fit').item.json.email }}): {{ $json.error.message }}. Please add them by hand. Their reply email is still going out.",
        "otherOptions": {}
      },
      "credentials": {
        "slackOAuth2Api": {
          "id": "8a62bbb7f65c47",
          "name": "Copperleaf Slack (bot)"
        }
      }
    },
    {
      "id": "471f0441-ab5a-4a2d-a71f-0441ab5aaa2d",
      "name": "Carry on either way",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        1300,
        0
      ],
      "parameters": {}
    },
    {
      "id": "696f6700-f580-44bc-a96f-6700f58084bc",
      "name": "Route by tier",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        1560,
        0
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "c-000c",
                    "leftValue": "={{ $('Score the fit').item.json.tier }}",
                    "rightValue": "priority",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Priority"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "c-000d",
                    "leftValue": "={{ $('Score the fit').item.json.tier }}",
                    "rightValue": "standard",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Standard"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "Small"
        }
      }
    },
    {
      "id": "6a977a98-601d-4d3a-aa97-7a98601d9d3a",
      "name": "Post to #wholesale",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        1820,
        0
      ],
      "parameters": {
        "authentication": "oAuth2",
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "#wholesale",
          "mode": "name"
        },
        "messageType": "block",
        "blocksUi": "={\"blocks\":[{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\"Wholesale lead: {{ $('Score the fit').item.json.business_name }}\"}},{\"type\":\"section\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Who*\\n{{ $('Score the fit').item.json.contact_name }}\"},{\"type\":\"mrkdwn\",\"text\":\"*Where*\\n{{ $('Score the fit').item.json.location }}\"},{\"type\":\"mrkdwn\",\"text\":\"*Volume*\\n{{ $('Score the fit').item.json.lbs_per_week }} lb a week\"},{\"type\":\"mrkdwn\",\"text\":\"*Fit*\\n{{ $('Score the fit').item.json.fit_score }}/100\"}]}]}",
        "text": "=Wholesale lead: {{ $('Score the fit').item.json.business_name }}",
        "otherOptions": {}
      },
      "credentials": {
        "slackOAuth2Api": {
          "id": "8a62bbb7f65c47",
          "name": "Copperleaf Slack (bot)"
        }
      }
    },
    {
      "id": "84d528ab-70b0-46db-a4d5-28ab70b0a6db",
      "name": "Note from Maya",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        2080,
        0
      ],
      "parameters": {
        "resource": "message",
        "operation": "send",
        "sendTo": "={{ $('Score the fit').item.json.email }}",
        "subject": "=Coffee for {{ $('Score the fit').item.json.business_name }}",
        "emailType": "text",
        "message": "=Hi {{ $('Score the fit').item.json.first_name }},\n\nThanks for reaching out about wholesale. At {{ $('Score the fit').item.json.lbs_per_week }} pounds a week we would love to roast for {{ $('Score the fit').item.json.business_name }}.\n\nThe best next step is a short call and a box of samples, so you can taste three of our espresso and filter roasts on your own equipment. Pick a time here: copperleaf.example/wholesale-call\n\nMaya Okoye\nCopperleaf Coffee Roasters, Asheville",
        "options": {
          "appendAttribution": false,
          "senderName": "Maya Okoye"
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "de56a6ca123545",
          "name": "Maya’s Gmail (OAuth2)"
        }
      }
    },
    {
      "id": "44c8c129-9aef-40ab-a4c8-c1299aeff0ab",
      "name": "Get the price list",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1820,
        200
      ],
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "1CopperleafPriceList2026",
          "mode": "list",
          "cachedResultName": "Copperleaf Wholesale Price List 2026.pdf"
        },
        "options": {
          "binaryPropertyName": "data"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "526b847486ee44",
          "name": "Copperleaf Google (OAuth2)"
        }
      }
    },
    {
      "id": "5a2554b2-ef9e-44e2-aa25-54b2ef9e34e2",
      "name": "Send the price list",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        2080,
        200
      ],
      "parameters": {
        "resource": "message",
        "operation": "send",
        "sendTo": "={{ $('Score the fit').item.json.email }}",
        "subject": "Copperleaf wholesale prices",
        "emailType": "text",
        "message": "=Hi {{ $('Score the fit').item.json.first_name }},\n\nThanks for asking about wholesale for {{ $('Score the fit').item.json.business_name }}. Our price list is attached. At {{ $('Score the fit').item.json.lbs_per_week }} pounds a week you are on our standard tier, with free delivery in Buncombe County and two-day shipping everywhere else.\n\nIf you would like samples first, reply with your address and I will send a box this week.\n\nMaya Okoye\nCopperleaf Coffee Roasters, Asheville",
        "options": {
          "appendAttribution": false,
          "senderName": "Maya Okoye",
          "attachmentsUi": {
            "attachmentsBinary": [
              {
                "property": "data"
              }
            ]
          }
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "de56a6ca123545",
          "name": "Maya’s Gmail (OAuth2)"
        }
      }
    },
    {
      "id": "4c495302-9c0a-4eda-ac49-53029c0aceda",
      "name": "Suggest the café subscription",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1820,
        400
      ],
      "parameters": {
        "resource": "message",
        "operation": "send",
        "sendTo": "={{ $('Score the fit').item.json.email }}",
        "subject": "Fresh coffee for your team",
        "emailType": "text",
        "message": "=Hi {{ $('Score the fit').item.json.first_name }},\n\nThanks for thinking of us for {{ $('Score the fit').item.json.business_name }}. Wholesale starts at 10 pounds a week, so for {{ $('Score the fit').item.json.lbs_per_week }} pounds our office subscription is the better deal: freshly roasted bags every week or two, cancel any time. The code TEAM15 takes 15% off the first three months at copperleaf.example/subscribe.\n\nIf you grow into wholesale, just reply and I will set it up.\n\nMaya Okoye\nCopperleaf Coffee Roasters, Asheville",
        "options": {
          "appendAttribution": false,
          "senderName": "Maya Okoye"
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "de56a6ca123545",
          "name": "Maya’s Gmail (OAuth2)"
        }
      }
    }
  ],
  "connections": {
    "Wholesale inquiry form": {
      "main": [
        [
          {
            "node": "Clean up the answers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean up the answers": {
      "main": [
        [
          {
            "node": "Score the fit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Score the fit": {
      "main": [
        [
          {
            "node": "Add to HubSpot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add to HubSpot": {
      "main": [
        [
          {
            "node": "Carry on either way",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Tell #wholesale HubSpot missed it",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tell #wholesale HubSpot missed it": {
      "main": [
        [
          {
            "node": "Carry on either way",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Carry on either way": {
      "main": [
        [
          {
            "node": "Route by tier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by tier": {
      "main": [
        [
          {
            "node": "Post to #wholesale",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get the price list",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Suggest the café subscription",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to #wholesale": {
      "main": [
        [
          {
            "node": "Note from Maya",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get the price list": {
      "main": [
        [
          {
            "node": "Send the price list",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1",
    "timezone": "America/New_York",
    "saveDataSuccessExecution": "all",
    "saveDataErrorExecution": "all",
    "saveManualExecutions": true
  },
  "tags": [
    {
      "name": "wholesale"
    },
    {
      "name": "form"
    }
  ],
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "work-with-nick-sample"
  }
}