{
  "name": "Dify FAQ 自動返答 v1 (IroHive)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "dify-faq",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "node-webhook",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300],
      "webhookId": "dify-faq-webhook"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.dify.ai/v1/chat-messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "application/json",
        "body": "={\n  \"inputs\": {},\n  \"query\": \"{{ $('Webhook').item.json.body.question }}\",\n  \"response_mode\": \"blocking\",\n  \"conversation_id\": \"\",\n  \"user\": \"{{ $('Webhook').item.json.body.user_id || 'anonymous' }}\"\n}",
        "options": {
          "timeout": 30000
        }
      },
      "id": "node-dify",
      "name": "Dify API呼び出し",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [460, 300],
      "notes": "【設定必須】Credentialsで「Dify API Key」(Header Auth) を作成し、Value に「Bearer app-あなたのAPIキー」を設定してください。セルフホストの場合はURLのドメインを変更してください。"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=YOUR_TEAMS_OR_SLACK_WEBHOOK_URL",
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "application/json",
        "body": "={\n  \"text\": \"*Q:* {{ $('Webhook').item.json.body.question }}\\n\\n*A:* {{ $json.answer }}\"\n}",
        "options": {}
      },
      "id": "node-notify",
      "name": "Teams / Slack 通知",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [680, 300],
      "notes": "【設定必須】URLを Teams または Slack の Incoming Webhook URL に書き換えてください。"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Dify API呼び出し",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dify API呼び出し": {
      "main": [
        [
          {
            "node": "Teams / Slack 通知",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "irohive"
  },
  "tags": [
    { "name": "Dify" },
    { "name": "FAQ" },
    { "name": "Teams" }
  ],
  "_readme": {
    "source": "https://irohive.com/blog/n8n-dify-integration/",
    "setup": [
      "1. n8n にインポート（ワークフロー一覧 → Import from file）",
      "2. 「Dify API呼び出し」ノードの Credentials を設定: Header Auth / Name=Authorization / Value=Bearer app-あなたのAPIキー",
      "3. 「Teams / Slack 通知」ノードの URL を Incoming Webhook URL に変更",
      "4. セルフホスト Dify の場合は URL を http://your-dify-server/v1/chat-messages に変更",
      "5. ワークフローを有効化",
      "6. テスト: curl -X POST https://your-n8n/webhook-test/dify-faq -H 'Content-Type: application/json' -d '{\"question\": \"有給休暇の申請方法は？\", \"user_id\": \"test\"}'"
    ]
  }
}
