RECIPE 011
인스타그램 신규 팔로워 → 환영 DM 자동 발송
- ▸Twitter/X API v2를 HTTP Request로 호출해 멘션을 수집할 수 있다
- ▸수집된 멘션 데이터를 CRM(Google Sheets 또는 Notion)에 자동 등록할 수 있다
- ▸신규 멘션 발생 시 Slack으로 즉시 알림을 받을 수 있다
✅사전 준비
- □Twitter Developer Portal에서 앱 생성 및 Bearer Token 발급
- □모니터링할 계정의 Twitter User ID 확인
- □Google Sheets 또는 Notion 자격증명 연결 완료
- □Slack 자격증명 연결 완료
- □Schedule Trigger: 30분 간격 (Cron: */30 * * * *)
Twitter API v2 — 멘션 수집 HTTP Request
URL: https://api.twitter.com/2/users/YOUR_USER_ID/mentions
Headers:
Authorization: Bearer YOUR_BEARER_TOKEN
Query Parameters:
max_results: 10
tweet.fields: created_at,author_id,text
start_time: {{ $now.minus({minutes: 30}).toISO() }}Google Sheets — 멘션 데이터 매핑
트윗ID: {{ $json.id }}
내용: {{ $json.text }}
작성자ID: {{ $json.author_id }}
작성시각: {{ $json.created_at }}
수집일시: {{ $now.toFormat("yyyy-MM-dd HH:mm") }}Slack 알림 메시지
🐦 새 멘션이 들어왔어요!
{{ $json.text }}
🔗 https://twitter.com/i/web/status/{{ $json.id }}⚠️ 주의Twitter/X API 무료 플랜(Free tier)은 월 500건 읽기 제한이 있습니다. 폴링 간격을 너무 짧게 설정하면 금방 한도를 초과하니 주의하세요.
⚡
워크플로우 JSON
아래 JSON을 복사해 n8n에 바로 임포트하세요
📥 n8n 임포트 방법
n8n 화면 우측 상단 메뉴 (⋮) → Import from JSON → 아래 JSON 전체 복사 후 붙여넣기 → Import 클릭
n8n 화면 우측 상단 메뉴 (⋮) → Import from JSON → 아래 JSON 전체 복사 후 붙여넣기 → Import 클릭
{
"name": "recipe011_instagram_welcome_dm",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "hours",
"hoursInterval": 1
}
]
}
},
"id": "schedule-011-01",
"name": "1시간마다 실행",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.1,
"position": [
200,
400
]
},
{
"parameters": {
"method": "GET",
"url": "https://graph.instagram.com/me/followers",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"options": {}
},
"id": "http-011-02",
"name": "신규 팔로워 목록 가져오기",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
420,
400
]
},
{
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"value": "={{ $env.INSTAGRAM_FOLLOWERS_SHEET_ID }}"
},
"sheetName": {
"value": "sent_list"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"followerId": "={{ $json.id }}",
"username": "={{ $json.username }}",
"sentAt": "={{ $now.format('YYYY-MM-DD HH:mm') }}"
}
},
"options": {
"upsertOptions": {
"upsertKey": "followerId"
}
}
},
"id": "sheets-011-03",
"name": "발송 완료 목록 기록 (중복 방지)",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.4,
"position": [
640,
400
]
},
{
"parameters": {
"method": "POST",
"url": "https://graph.instagram.com/v19.0/me/messages",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "recipient",
"value": "={{ JSON.stringify({ id: $json.id }) }}"
},
{
"name": "message",
"value": "={{ JSON.stringify({ text: '안녕하세요, ' + $json.username + '님! 팔로우해주셔서 감사해요 🎉 첫 구매 10% 할인 쿠폰 코드: WELCOME10' }) }}"
}
]
},
"options": {}
},
"id": "http-011-04",
"name": "환영 DM 발송",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
860,
400
]
}
],
"connections": {
"1시간마다 실행": {
"main": [
[
{
"node": "신규 팔로워 목록 가져오기",
"type": "main",
"index": 0
}
]
]
},
"신규 팔로워 목록 가져오기": {
"main": [
[
{
"node": "발송 완료 목록 기록 (중복 방지)",
"type": "main",
"index": 0
}
]
]
},
"발송 완료 목록 기록 (중복 방지)": {
"main": [
[
{
"node": "환영 DM 발송",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"timezone": "Asia/Seoul"
},
"meta": {
"chapter": 2,
"recipe": "011",
"title": "인스타그램 신규 팔로워 → 환영 DM 자동 발송",
"difficulty": "⭐⭐",
"estimatedTime": "30분",
"apps": [
"Instagram API",
"Google Sheets"
]
}
}