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

블로그 신규 포스팅 → SNS 자동 공유

  • ▸Gmail Trigger로 첨부파일이 있는 메일만 감지할 수 있다
  • ▸첨부파일 이름과 MIME 타입으로 파일 종류를 분류할 수 있다
  • ▸Google Drive 지정 폴더에 첨부파일을 자동 저장할 수 있다

✅사전 준비

  • □Gmail 자격증명 연결 완료
  • □Google Drive 자격증명 연결 완료
  • □Drive에 분류별 폴더 생성 및 폴더 ID 확인 (예: 계약서 / 이미지 / 기타)
  • □폴더 ID는 Drive URL의 /folders/ 뒤 문자열

Gmail Trigger 설정값

Poll Every:   15 Minutes
Filters:
  Has Attachment: true
  Read Status:    Unread Only

첨부파일 분류 — Switch 노드 조건

PDF 문서:
{{ $json.mimeType === "application/pdf" }}

이미지:
{{ $json.mimeType.startsWith("image/") }}

엑셀/스프레드시트:
{{ $json.mimeType.includes("spreadsheet") || $json.mimeType.includes("excel") }}

Google Drive — 파일 업로드 설정

Operation:  Upload
File Name:  {{ $now.toFormat("yyyyMMdd") }}_{{ $json.fileName }}
Parent ID:  분류별_폴더ID_입력
Binary Data: 첨부파일 바이너리 참조
💡 TIPGmail 노드에서 첨부파일을 바이너리 데이터로 가져오려면 'Download Attachments' 옵션을 ON으로 설정해야 합니다. 설정하지 않으면 파일 메타데이터만 옵니다.
⚡

워크플로우 JSON

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

📥 n8n 임포트 방법
n8n 화면 우측 상단 메뉴 (⋮) → Import from JSON → 아래 JSON 전체 복사 후 붙여넣기 → Import 클릭
{
  "name": "recipe012_blog_post_sns_share",
  "nodes": [
    {
      "parameters": {
        "url": "={{ $env.BLOG_RSS_URL }}"
      },
      "id": "rss-012-01",
      "name": "블로그 RSS 새 글 감지",
      "type": "n8n-nodes-base.rssFeedReadTrigger",
      "typeVersion": 1.1,
      "position": [
        200,
        400
      ]
    },
    {
      "parameters": {
        "jsCode": "const title = $json.title || '';\nconst link = $json.link || '';\nconst summary = $json.contentSnippet || $json.summary || '';\nreturn [{\n  json: {\n    title,\n    link,\n    summary: summary.slice(0, 200),\n    twitterText: title + ' ' + link,\n    linkedinText: '[새 글 발행] ' + title + '\\n\\n' + summary.slice(0, 150) + '\\n\\n🔗 ' + link,\n    facebookText: title + '\\n\\n' + summary.slice(0, 200) + '\\n\\n' + link,\n    slackText: '📝 새 블로그 글이 발행됐어요!\\n*' + title + '*\\n' + summary.slice(0, 100) + '\\n🔗 ' + link\n  }\n}];"
      },
      "id": "code-012-02",
      "name": "SNS별 메시지 포맷 생성",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        420,
        400
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.twitter.com/2/tweets",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "={{ $json.twitterText }}"
            }
          ]
        },
        "options": {}
      },
      "id": "http-012-03",
      "name": "Twitter 발행",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        640,
        200
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://graph.facebook.com/v19.0/me/feed",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "message",
              "value": "={{ $json.facebookText }}"
            }
          ]
        },
        "options": {}
      },
      "id": "http-012-04",
      "name": "Facebook 발행",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        640,
        400
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.linkedin.com/v2/ugcPosts",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "={{ $json.linkedinText }}"
            }
          ]
        },
        "options": {}
      },
      "id": "http-012-05",
      "name": "LinkedIn 발행",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        640,
        600
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "post",
        "channel": "#marketing-content",
        "text": "={{ $json.slackText }}"
      },
      "id": "slack-012-06",
      "name": "Slack 팀 알림",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [
        640,
        800
      ]
    }
  ],
  "connections": {
    "블로그 RSS 새 글 감지": {
      "main": [
        [
          {
            "node": "SNS별 메시지 포맷 생성",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SNS별 메시지 포맷 생성": {
      "main": [
        [
          {
            "node": "Twitter 발행",
            "type": "main",
            "index": 0
          },
          {
            "node": "Facebook 발행",
            "type": "main",
            "index": 0
          },
          {
            "node": "LinkedIn 발행",
            "type": "main",
            "index": 0
          },
          {
            "node": "Slack 팀 알림",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "timezone": "Asia/Seoul"
  },
  "meta": {
    "chapter": 2,
    "recipe": "012",
    "title": "블로그 신규 포스팅 → SNS 자동 공유",
    "difficulty": "⭐⭐",
    "estimatedTime": "30분",
    "apps": [
      "RSS Feed",
      "Twitter",
      "Facebook Pages",
      "LinkedIn",
      "Slack"
    ]
  }
}
← 이전 레시피☰ 목차다음 레시피 →