발행일: 2026-10-06(화) 11:44
← 목차로 돌아가기|하루 30분 n8n 시리즈 ② 실무 자동화 레시피 100
RECIPE 030

계약 체결 → 온보딩 프로세스 자동 시작

  • ▸여러 Sheets에서 월간 KPI 데이터를 자동으로 집계할 수 있다
  • ▸Code 노드로 목표 대비 달성률을 계산할 수 있다
  • ▸집계 결과를 대시보드 시트에 자동 업데이트하고 팀에 공유할 수 있다

✅사전 준비

  • □Google Sheets 자격증명 연결 완료
  • □KPI 데이터 시트 구조 확정 (날짜/항목/실적/목표 컬럼)
  • □대시보드 시트 생성 (월별 집계 결과 표시용)
  • □Schedule Trigger: 매월 1일 오전 9시 (Cron: 0 9 1 * *)
  • □Slack 자격증명 연결 완료 (결과 공유용)

월간 데이터 필터링 — Code 노드

const items = $input.all();
const now = new Date();
const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1);
const monthStr = `${lastMonth.getFullYear()}-${String(lastMonth.getMonth()+1).padStart(2,'0')}`;

const filtered = items.filter(i =>
  i.json.날짜?.startsWith(monthStr)
);
return filtered;

KPI 집계 및 달성률 계산 — Code 노드

const items = $input.all();
const summary = {};

items.forEach(({ json }) => {
  const key = json.항목;
  if (!summary[key]) summary[key] = { 실적: 0, 목표: 0 };
  summary[key].실적 += Number(json.실적) || 0;
  summary[key].목표 += Number(json.목표) || 0;
});

return Object.entries(summary).map(([항목, v]) => ({
  json: {
    항목,
    실적: v.실적,
    목표: v.목표,
    달성률: v.목표 > 0 ? ((v.실적 / v.목표) * 100).toFixed(1) + '%' : 'N/A',
    달성여부: v.실적 >= v.목표 ? '✅ 달성' : '❌ 미달',
  }
}));

Slack 월간 KPI 리포트 메시지

📊 *{{ $now.minus({months:1}).toFormat('yyyy년 MM월') }} KPI 결과*

{{ $input.all().map(i =>
  `${i.json.달성여부} ${i.json.항목}: ${i.json.실적} / ${i.json.목표} (${i.json.달성률})`
).join('\n') }}
⚡

워크플로우 JSON

아래 JSON을 복사해 n8n에 바로 임포트하세요

📥 n8n 임포트 방법
n8n 화면 우측 상단 메뉴 (⋮) → Import from JSON → 아래 JSON 전체 복사 후 붙여넣기 → Import 클릭
{
  "recipeId": "recipe030",
  "title": "계약 체결 → 온보딩 프로세스 자동 시작",
  "chapter": 3,
  "category": "영업 & 리드 관리 자동화",
  "difficulty": "⭐⭐⭐",
  "estimatedTime": "50분",
  "description": "HubSpot에서 딜 상태가 '계약 완료'로 변경되면 온보딩 체크리스트를 구글 시트에 추가하고, CS팀·기술팀·어카운트 매니저에게 각각 Slack 알림을 보내며, 고객에게 환영 이메일을 자동 발송합니다.",
  "apps": [
    "HubSpot",
    "Google Sheets",
    "Slack",
    "Gmail"
  ],
  "nodes": [
    {
      "id": "trigger_hubspot_deal",
      "type": "trigger",
      "name": "HubSpot Trigger - 딜 상태 변경",
      "service": "hubspot",
      "config": {
        "event": "deal.propertyChange",
        "property": "dealstage",
        "toValue": "closedwon"
      }
    },
    {
      "id": "sheets_add_row",
      "type": "action",
      "name": "Google Sheets - 온보딩 체크리스트 추가",
      "service": "googleSheets",
      "config": {
        "operation": "appendRow",
        "documentId": "{{ $env.ONBOARDING_SHEET_ID }}",
        "sheetName": "온보딩 현황",
        "data": {
          "고객명": "={{ $json[\"dealname\"] }}",
          "계약일": "={{ $now.format(\"YYYY-MM-DD\") }}",
          "담당AM": "={{ $json[\"hubspot_owner_id\"] }}",
          "환경세팅": "미완료",
          "교육일정": "미완료",
          "첫통화": "미완료"
        }
      }
    },
    {
      "id": "slack_cs",
      "type": "action",
      "name": "Slack - CS팀 알림",
      "service": "slack",
      "config": {
        "channel": "={{ $env.SLACK_CS_CHANNEL }}",
        "message": "🎉 새 계약 완료! CS팀 온보딩 시작해주세요.\n고객: {{ $json[\"dealname\"] }}\n계약일: {{ $now.format(\"MM/DD\") }}"
      }
    },
    {
      "id": "slack_tech",
      "type": "action",
      "name": "Slack - 기술팀 알림",
      "service": "slack",
      "config": {
        "channel": "={{ $env.SLACK_TECH_CHANNEL }}",
        "message": "🔧 새 계약 완료! 환경 세팅 준비해주세요.\n고객: {{ $json[\"dealname\"] }}"
      }
    },
    {
      "id": "slack_am",
      "type": "action",
      "name": "Slack - 어카운트 매니저 알림",
      "service": "slack",
      "config": {
        "channel": "={{ $env.SLACK_AM_DM }}",
        "message": "✅ 담당 고객 계약 완료!\n고객: {{ $json[\"dealname\"] }}\n→ 온보딩 일정 잡아주세요."
      }
    },
    {
      "id": "gmail_welcome",
      "type": "action",
      "name": "Gmail - 환영 이메일 발송",
      "service": "gmail",
      "config": {
        "to": "={{ $json[\"customer_email\"] }}",
        "subject": "환영합니다! 서비스 이용을 시작해보세요 🎉",
        "body": "안녕하세요!\n\n계약을 완료해 주셔서 감사합니다.\n담당 매니저가 곧 연락드려 온보딩 일정을 안내해드리겠습니다.\n\n궁금하신 점은 언제든지 문의해 주세요.\n감사합니다."
      }
    }
  ],
  "connections": [
    {
      "from": "trigger_hubspot_deal",
      "to": "sheets_add_row"
    },
    {
      "from": "sheets_add_row",
      "to": "slack_cs"
    },
    {
      "from": "sheets_add_row",
      "to": "slack_tech"
    },
    {
      "from": "sheets_add_row",
      "to": "slack_am"
    },
    {
      "from": "sheets_add_row",
      "to": "gmail_welcome"
    }
  ],
  "envVars": [
    {
      "key": "ONBOARDING_SHEET_ID",
      "description": "온보딩 체크리스트 구글 시트 ID"
    },
    {
      "key": "SLACK_CS_CHANNEL",
      "description": "CS팀 Slack 채널 ID"
    },
    {
      "key": "SLACK_TECH_CHANNEL",
      "description": "기술팀 Slack 채널 ID"
    },
    {
      "key": "SLACK_AM_DM",
      "description": "어카운트 매니저 Slack DM 채널 ID"
    }
  ],
  "qrCodeUrl": "https://www.koreaaitimes.com/books/n8n-vol2/recipe030"
}
← 이전 레시피☰ 목차다음 레시피 →