RECIPE 054
WooCommerce 신규 주문 → Slack 알림 + 재고 확인
- ▸WooCommerce 신규 주문 발생 시 Slack 즉시 알림
- ▸주문 상품의 재고 수량 자동 확인
- ▸재고 부족 시 담당자에게 별도 경고 알림
✅사전 준비
- □WooCommerce REST API 키 발급 (WooCommerce → 설정 → 고급 → REST API)
- □WooCommerce 웹훅 등록 (WooCommerce → 설정 → 고급 → 웹훅)
- □Slack 채널 및 Bot 토큰 준비
- □재고 임계값 결정 (예: 5개 미만 경고)
WooCommerce 웹훅 설정
웹훅 등록 위치: WooCommerce → 설정 → 고급 → 웹훅
이름: n8n 주문 알림
상태: 활성
주제: Order created
배달 URL: https://your-n8n.com/webhook/woocommerce-order
Secret: YOUR_WEBHOOK_SECRET재고 확인 API 호출
Node: HTTP Request
Method: GET
URL: https://yourstore.com/wp-json/wc/v3/products/{{ $json.line_items[0].product_id }}
Authentication: Basic Auth
Username: YOUR_CONSUMER_KEY
Password: YOUR_CONSUMER_SECRETSlack 알림 메시지
:shopping_cart: *신규 주문 접수*
주문번호: #{{ $json.id }}
고객명: {{ $json.billing.first_name }} {{ $json.billing.last_name }}
총액: {{ $json.currency }} {{ $json.total }}
상품: {{ $json.line_items.map(i => i.name).join(', ') }}
결제방법: {{ $json.payment_method_title }}⚠️ 주의WooCommerce 웹훅 서명 검증을 위해 n8n Webhook 노드의 Header Auth에 `X-WC-Webhook-Signature` 값을 반드시 확인하세요.
⚡
워크플로우 JSON
아래 JSON을 복사해 n8n에 바로 임포트하세요
📥 n8n 임포트 방법
n8n 화면 우측 상단 메뉴 (⋮) → Import from JSON → 아래 JSON 전체 복사 후 붙여넣기 → Import 클릭
n8n 화면 우측 상단 메뉴 (⋮) → Import from JSON → 아래 JSON 전체 복사 후 붙여넣기 → Import 클릭
{
"recipeId": "recipe054",
"title": "휴가 신청 → 자동 승인 흐름",
"chapter": 5,
"category": "HR & 조직 운영 자동화",
"difficulty": "⭐⭐",
"estimatedTime": "35분",
"usedApps": [
"Google Forms",
"Slack",
"Google Calendar",
"Google Sheets"
],
"description": "구글 폼으로 휴가 신청을 받으면 팀장 Slack에 승인·반려 버튼 메시지를 보내고, 승인 시 구글 캘린더 자동 등록·구글 시트 기록·신청자 이메일 발송을 한 번에 처리합니다.",
"nodes": [
{
"id": "trigger_form",
"type": "trigger",
"service": "Google Sheets",
"name": "휴가 신청 폼 제출 감지",
"config": {
"event": "rowAdded",
"spreadsheetId": "{{$env.LEAVE_SHEET_ID}}",
"sheetName": "휴가신청"
}
},
{
"id": "send_approval_request",
"type": "action",
"service": "Slack",
"name": "팀장 승인 요청 메시지",
"config": {
"operation": "sendMessage",
"channel": "{{$env.MANAGER_SLACK_ID}}",
"message": "📋 휴가 승인 요청\n\n👤 신청자: {{$json['신청자']}}\n🏖 휴가 종류: {{$json['휴가종류']}}\n📅 기간: {{$json['시작일']}} ~ {{$json['종료일']}}\n📝 사유: {{$json['사유']}}\n\n아래 버튼을 눌러 승인 또는 반려해 주세요.",
"blocks": [
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "✅ 승인"
},
"style": "primary",
"action_id": "approve_leave",
"value": "{{$json['rowIndex']}}"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "❌ 반려"
},
"style": "danger",
"action_id": "reject_leave",
"value": "{{$json['rowIndex']}}"
}
]
}
]
}
},
{
"id": "trigger_slack_action",
"type": "trigger",
"service": "Webhook",
"name": "Slack 버튼 클릭 수신",
"config": {
"httpMethod": "POST",
"path": "/slack-leave-action"
}
},
{
"id": "check_action",
"type": "condition",
"service": "IF",
"name": "승인 여부 확인",
"config": {
"condition": "{{$json['actions'][0]['action_id'] === 'approve_leave'}}"
}
},
{
"id": "add_to_calendar",
"type": "action",
"service": "Google Calendar",
"name": "구글 캘린더 휴가 등록",
"config": {
"operation": "createEvent",
"calendarId": "{{$env.TEAM_CALENDAR_ID}}",
"summary": "{{$json['신청자']}} 휴가 ({{$json['휴가종류']}})",
"start": "{{$json['시작일']}}",
"end": "{{$json['종료일']}}",
"description": "사유: {{$json['사유']}}"
}
},
{
"id": "update_sheet_approved",
"type": "action",
"service": "Google Sheets",
"name": "시트 승인 상태 기록",
"config": {
"operation": "updateRow",
"spreadsheetId": "{{$env.LEAVE_SHEET_ID}}",
"sheetName": "휴가신청",
"rowNumber": "{{$json['rowIndex']}}",
"columns": {
"승인상태": "승인",
"처리일시": "{{$now.format('YYYY-MM-DD HH:mm')}}"
}
}
},
{
"id": "send_approved_email",
"type": "action",
"service": "Gmail",
"name": "승인 안내 이메일 발송",
"config": {
"operation": "sendEmail",
"to": "{{$json['이메일']}}",
"subject": "[휴가 승인] {{$json['시작일']}} ~ {{$json['종료일']}} 휴가가 승인되었습니다",
"body": "안녕하세요, {{$json['신청자']}}님!\n\n신청하신 휴가가 승인되었습니다. ✅\n\n🏖 휴가 종류: {{$json['휴가종류']}}\n📅 기간: {{$json['시작일']}} ~ {{$json['종료일']}}\n\n즐거운 휴가 되세요! 😊\n{{$env.COMPANY_NAME}} HR팀 드림"
}
},
{
"id": "update_sheet_rejected",
"type": "action",
"service": "Google Sheets",
"name": "시트 반려 상태 기록",
"config": {
"operation": "updateRow",
"spreadsheetId": "{{$env.LEAVE_SHEET_ID}}",
"sheetName": "휴가신청",
"rowNumber": "{{$json['rowIndex']}}",
"columns": {
"승인상태": "반려",
"처리일시": "{{$now.format('YYYY-MM-DD HH:mm')}}"
}
}
},
{
"id": "send_rejected_email",
"type": "action",
"service": "Gmail",
"name": "반려 안내 이메일 발송",
"config": {
"operation": "sendEmail",
"to": "{{$json['이메일']}}",
"subject": "[휴가 반려] 휴가 신청이 반려되었습니다",
"body": "안녕하세요, {{$json['신청자']}}님!\n\n안타깝게도 신청하신 휴가가 반려되었습니다.\n\n📅 신청 기간: {{$json['시작일']}} ~ {{$json['종료일']}}\n\n자세한 사유는 팀장님께 직접 문의해 주세요.\n{{$env.COMPANY_NAME}} HR팀 드림"
}
}
],
"edges": [
{
"from": "trigger_form",
"to": "send_approval_request"
},
{
"from": "trigger_slack_action",
"to": "check_action"
},
{
"from": "check_action",
"to": "add_to_calendar",
"branch": "true"
},
{
"from": "add_to_calendar",
"to": "update_sheet_approved"
},
{
"from": "update_sheet_approved",
"to": "send_approved_email"
},
{
"from": "check_action",
"to": "update_sheet_rejected",
"branch": "false"
},
{
"from": "update_sheet_rejected",
"to": "send_rejected_email"
}
],
"tips": [
"Slack 버튼 클릭을 Webhook으로 받으려면 Slack 앱 설정에서 Interactivity & Shortcuts에 n8n Webhook URL을 등록해야 해요.",
"반차 신청의 경우 시작 시간과 종료 시간을 폼에 추가하고 Google Calendar 이벤트를 시간 단위로 생성하도록 수정하세요.",
"연차 잔여일수를 시트에 관리하고 신청 시 잔여 일수를 자동 차감하는 Function 노드를 추가하면 더욱 완성도 높은 시스템이 돼요."
],
"qrUrl": "www.koreaaitimes.com/books/n8n-vol2/recipe054"
}