amator.app
Публічний API + n8n

Готовий workflow для n8n

П’ять вузлів: ручний старт, вузол Edit Fields із полями content і clubId, вузол If, що перевіряє, чи порожнє clubId, і два вузли HTTP Request — один публікує у ваш профіль, другий у клуб.

Workflow починається з ручного тригера, щоб його можна було перевірити одразу після імпорту. Коли все запрацює, замініть Start на те, що справді має його запускати, — Schedule, RSS, форму — і передайте його дані в ці два поля.

Завантажити .json
amator-public-post.json
{
  "name": "Amator — publish a post",
  "nodes": [
    {
      "id": "7b0f3a52-1c6e-4d1b-9a43-5e2f8c1d0a01",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "7b0f3a52-1c6e-4d1b-9a43-5e2f8c1d0a02",
      "name": "Post content",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ],
      "parameters": {
        "mode": "manual",
        "assignments": {
          "assignments": [
            {
              "id": "7b0f3a52-1c6e-4d1b-9a43-5e2f8c1d0b01",
              "name": "content",
              "value": "Hello from n8n! Training moved to 19:00 tonight.",
              "type": "string"
            },
            {
              "id": "7b0f3a52-1c6e-4d1b-9a43-5e2f8c1d0b02",
              "name": "clubId",
              "value": "",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "7b0f3a52-1c6e-4d1b-9a43-5e2f8c1d0a03",
      "name": "Club ID empty?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        440,
        0
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "7b0f3a52-1c6e-4d1b-9a43-5e2f8c1d0c01",
              "leftValue": "={{ $json.clubId }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      }
    },
    {
      "id": "7b0f3a52-1c6e-4d1b-9a43-5e2f8c1d0a04",
      "name": "Post to my profile",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        680,
        -120
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.amator.app/api/v1/public/posts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-API-KEY",
              "value": "YOUR_API_KEY_HERE"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ content: $json.content }) }}",
        "options": {}
      }
    },
    {
      "id": "7b0f3a52-1c6e-4d1b-9a43-5e2f8c1d0a05",
      "name": "Post to club",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        680,
        120
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.amator.app/api/v1/public/posts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-API-KEY",
              "value": "YOUR_API_KEY_HERE"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ content: $json.content, clubId: $json.clubId }) }}",
        "options": {}
      }
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Post content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post content": {
      "main": [
        [
          {
            "node": "Club ID empty?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Club ID empty?": {
      "main": [
        [
          {
            "node": "Post to my profile",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Post to club",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {},
  "pinData": {}
}

Імпорт у n8n

Скопіюйте JSON вище або завантажте файл.

У n8n відкрийте Workflows, створіть новий workflow і вставте скопійований JSON на порожнє полотно (Ctrl/Cmd+V). Файл можна імпортувати через меню ⋯ › Import from File.

В обох вузлах HTTP Request замініть YOUR_API_KEY_HERE на свій ключ. А ще краще — збережіть його як облікові дані n8n (Header Auth, назва X-API-KEY).

У вузлі Post content впишіть текст у content. Залиште clubId порожнім, щоб опублікувати у своєму профілі, або вставте ID клубу, щоб опублікувати від його імені.

Натисніть Execute workflow. Вузол HTTP покаже відповідь — у разі успіху 201 і url поста.

На цій сторінці