{
  "name": "【通知】Googleフォームの回答をSlackとChatworkに送る",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "form-notify",
        "responseMode": "lastNode",
        "options": {}
      },
      "name": "フォームの回答を受け取る",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "id": "g1"
    },
    {
      "parameters": {
        "jsCode": "// Googleフォームから届いた回答を、通知の文面にする\nconst b = $input.first().json.body ?? {};\nconst answers = Array.isArray(b.answers) ? b.answers : [];\nconst when = b.submittedAt\n  ? DateTime.fromISO(b.submittedAt).setZone('Asia/Tokyo').toFormat('yyyy/MM/dd HH:mm')\n  : $now.setZone('Asia/Tokyo').toFormat('yyyy/MM/dd HH:mm');\nconst lines = answers.map(a => `■ ${a.question}\\n${Array.isArray(a.answer) ? a.answer.join('、') : (a.answer || '（未回答）')}`);\nconst text = `【${b.formTitle ?? 'フォーム'}】新しい回答（${when}）\\n\\n${lines.join('\\n\\n')}`;\nreturn [{ json: { text } }];"
      },
      "name": "通知の文面を作る",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        190,
        0
      ],
      "id": "g2"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://hooks.slack.com/services/XXXXXXXX/XXXXXXXX/XXXXXXXXXXXXXXXX",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ text: $json.text }) }}",
        "options": {}
      },
      "name": "Slackに送る",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        380,
        0
      ],
      "id": "g3"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.chatwork.com/v2/rooms/ROOM_ID/messages",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-chatworktoken",
              "value": "YOUR_CHATWORK_API_TOKEN"
            }
          ]
        },
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "body",
              "value": "={{ $('通知の文面を作る').item.json.text }}"
            }
          ]
        },
        "options": {}
      },
      "name": "Chatworkに送る",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        570,
        0
      ],
      "id": "g4"
    }
  ],
  "connections": {
    "フォームの回答を受け取る": {
      "main": [
        [
          {
            "node": "通知の文面を作る",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "通知の文面を作る": {
      "main": [
        [
          {
            "node": "Slackに送る",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slackに送る": {
      "main": [
        [
          {
            "node": "Chatworkに送る",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}