{
  "name": "VK Teams Node Verification Matrix",
  "description": "Draft workflow for real VK Teams custom-node verification: action matrix via form plus long-poll trigger branch. Assign a VK Teams API credential after import.",
  "nodes": [
    {
      "id": "ffda8181-d51a-4b9c-8249-450328f64852",
      "name": "Verification Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -460
      ],
      "parameters": {
        "width": 640,
        "height": 340,
        "color": 4,
        "content": "## VK Teams verification matrix\n\nForm branch sends real VK Teams messages with clickable inline keyboards and returns the generated callbackData values plus sent message ids. It leaves the messages in chat so a human can press the buttons later.\n\nTrigger branch listens for real callbackQuery events, tries `callback.answerCallbackQuery` on the real queryId, and writes a compact execution summary so you can manually validate whether the click arrived and whether VK Teams accepted the callback answer.\n\nKeep this workflow active only while validating callbacks. It creates a real long-poll consumer for the bot and can conflict with other active VK Teams trigger workflows."
      }
    },
    {
      "id": "859546f5-3004-419d-8ee0-eaaee8e13020",
      "name": "Run VK Teams Verification Form",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.5,
      "position": [
        0,
        0
      ],
      "parameters": {
        "authentication": "none",
        "formTitle": "VK Teams node verification matrix",
        "formDescription": "Sends real VK Teams messages with clickable keyboards and returns the exact callbackData values to validate later in n8n executions.",
        "formFields": {
          "values": [
            {
              "fieldName": "chatId",
              "fieldLabel": "Test chatId",
              "fieldType": "text",
              "placeholder": "chatId for a bot-accessible test chat",
              "requiredField": true
            },
            {
              "fieldName": "fileId",
              "fieldLabel": "Existing fileId fallback",
              "fieldType": "text",
              "placeholder": "Optional; used if sendFile does not return fileId",
              "requiredField": false
            },
            {
              "fieldName": "label",
              "fieldLabel": "Run label",
              "fieldType": "text",
              "placeholder": "Optional label for this run",
              "requiredField": false
            }
          ]
        },
        "responseMode": "lastNode",
        "options": {
          "path": "vk-teams-node-verification",
          "buttonLabel": "Send VK Teams verification",
          "appendAttribution": false
        }
      }
    },
    {
      "id": "3b6389a3-ac90-4249-9d5d-b5f6c581c892",
      "name": "Prepare Matrix Inputs",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        280,
        0
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const source = $input.first().json;\nconst value = (name) => String(source[name] ?? '').trim();\nconst runId = new Date().toISOString().replace(/[:.]/g, '-');\nconst label = value('label') || 'manual';\nconst chatId = value('chatId');\nif (!chatId) { throw new Error('chatId is required for real VK Teams action verification'); }\nreturn [{ json: {\n  runId,\n  label,\n  chatId,\n  fileId: value('fileId'),\n  text: '<b>n8n VK Teams</b> sendText keyboard ' + runId + ' [' + label + ']',\n  editableText: 'n8n VK Teams edit target ' + runId + ' [' + label + ']',\n  editedText: '<i>n8n VK Teams edited keyboard</i> ' + runId + ' [' + label + ']',\n  fileCaption: '<b>n8n VK Teams file</b> keyboard ' + runId + ' [' + label + ']',\n  callbackText: 'n8n verification callback answered ' + runId,\n  textParseMode: 'HTML',\n  expectedCallbacks: [\n    'vk-teams-verification-text:' + runId,\n    'vk-teams-verification-edited:' + runId,\n    'vk-teams-verification-file:' + runId,\n    'vk-teams-verification-voice:' + runId,\n  ],\n} }];"
      }
    },
    {
      "id": "16289691-87da-45e9-a09b-41b28ab3939a",
      "name": "Bot Get Self",
      "type": "n8n-nodes-vk-teams.vkTeams",
      "typeVersion": 1,
      "position": [
        560,
        -180
      ],
      "parameters": {
        "resource": "bot",
        "operation": "getSelf"
      }
    },
    {
      "id": "91057dea-6d26-423e-8686-616768ffa559",
      "name": "Chat Get Info",
      "type": "n8n-nodes-vk-teams.vkTeams",
      "typeVersion": 1,
      "position": [
        820,
        -180
      ],
      "parameters": {
        "resource": "chat",
        "operation": "getInfo",
        "chatId": "={{ $(\"Prepare Matrix Inputs\").item.json.chatId }}"
      }
    },
    {
      "id": "440db5d2-f12e-48d5-9a8a-0cbb49e45a6d",
      "name": "Send Text",
      "type": "n8n-nodes-vk-teams.vkTeams",
      "typeVersion": 1,
      "position": [
        1080,
        -180
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendText",
        "chatId": "={{ $(\"Prepare Matrix Inputs\").item.json.chatId }}",
        "text": "={{ $(\"Prepare Matrix Inputs\").item.json.text }}",
        "parseMode": "={{ $(\"Prepare Matrix Inputs\").item.json.textParseMode }}",
        "keyboard": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "Text Callback",
                    "buttonType": "callbackData",
                    "callbackData": "={{ \"vk-teams-verification-text:\" + $(\"Prepare Matrix Inputs\").item.json.runId }}",
                    "style": "primary"
                  },
                  {
                    "text": "Docs URL",
                    "buttonType": "url",
                    "url": "https://teams.vk.com/botapi/",
                    "style": "base"
                  }
                ]
              }
            }
          ]
        }
      }
    },
    {
      "id": "c34cc0b7-b0ed-4047-84ef-642d8f5f0705",
      "name": "Edit Text",
      "type": "n8n-nodes-vk-teams.vkTeams",
      "typeVersion": 1,
      "position": [
        1600,
        -180
      ],
      "parameters": {
        "resource": "message",
        "operation": "editText",
        "chatId": "={{ $(\"Prepare Matrix Inputs\").item.json.chatId }}",
        "msgId": "={{ $(\"Send Editable Text\").item.json.msgId }}",
        "text": "={{ $(\"Prepare Matrix Inputs\").item.json.editedText }}",
        "parseMode": "={{ $(\"Prepare Matrix Inputs\").item.json.textParseMode }}",
        "keyboard": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "Edited Callback",
                    "buttonType": "callbackData",
                    "callbackData": "={{ \"vk-teams-verification-edited:\" + $(\"Prepare Matrix Inputs\").item.json.runId }}",
                    "style": "attention"
                  }
                ]
              }
            }
          ]
        }
      }
    },
    {
      "id": "77ad59ad-d556-4e38-bf7a-e4a5a6c7d1a8",
      "name": "Prepare File Binary",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1860,
        -180
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const source = $items('Prepare Matrix Inputs')[0].json;\nconst content = 'VK Teams sendFile verification\\nrunId=' + source.runId + '\\nlabel=' + source.label + '\\n';\nreturn [{ json: { ...source }, binary: { data: { data: Buffer.from(content, 'utf8').toString('base64'), mimeType: 'text/plain', fileName: 'vk-teams-verification-' + source.runId + '.txt' } } }];"
      }
    },
    {
      "id": "22efd2d0-813d-4eaf-a64e-78a13fe5d427",
      "name": "Send File",
      "type": "n8n-nodes-vk-teams.vkTeams",
      "typeVersion": 1,
      "position": [
        2120,
        -180
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendFile",
        "chatId": "={{ $(\"Prepare Matrix Inputs\").item.json.chatId }}",
        "binaryPropertyName": "data",
        "caption": "={{ $(\"Prepare Matrix Inputs\").item.json.fileCaption }}",
        "parseMode": "={{ $(\"Prepare Matrix Inputs\").item.json.textParseMode }}",
        "keyboard": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "File Callback",
                    "buttonType": "callbackData",
                    "callbackData": "={{ \"vk-teams-verification-file:\" + $(\"Prepare Matrix Inputs\").item.json.runId }}",
                    "style": "base"
                  },
                  {
                    "text": "File Docs",
                    "buttonType": "url",
                    "url": "https://teams.vk.com/botapi/",
                    "style": "primary"
                  }
                ]
              }
            }
          ]
        }
      }
    },
    {
      "id": "0d0c67e1-5d48-4f5f-a0bd-ef0b5eb0e26d",
      "name": "File Get Info",
      "type": "n8n-nodes-vk-teams.vkTeams",
      "typeVersion": 1,
      "position": [
        2380,
        -180
      ],
      "parameters": {
        "resource": "file",
        "operation": "getInfo",
        "fileId": "={{ $(\"Send File\").item.json.fileId || $(\"Prepare Matrix Inputs\").item.json.fileId }}"
      }
    },
    {
      "id": "3532152c-07b1-4304-8ac0-a31d3d49457b",
      "name": "File Download",
      "type": "n8n-nodes-vk-teams.vkTeams",
      "typeVersion": 1,
      "position": [
        2640,
        -180
      ],
      "parameters": {
        "resource": "file",
        "operation": "download",
        "fileId": "={{ $(\"Send File\").item.json.fileId || $(\"Prepare Matrix Inputs\").item.json.fileId }}"
      }
    },
    {
      "id": "8059327b-5ba2-4106-9466-c0d7eee56c7a",
      "name": "Prepare Voice Binary",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2900,
        -180
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const source = $items('Prepare Matrix Inputs')[0].json;\nconst wav = Buffer.from([0x52,0x49,0x46,0x46,0x24,0x00,0x00,0x00,0x57,0x41,0x56,0x45,0x66,0x6d,0x74,0x20,0x10,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x40,0x1f,0x00,0x00,0x40,0x1f,0x00,0x00,0x01,0x00,0x08,0x00,0x64,0x61,0x74,0x61,0x00,0x00,0x00,0x00]);\nreturn [{ json: { ...source }, binary: { data: { data: wav.toString('base64'), mimeType: 'audio/wav', fileName: 'vk-teams-verification-' + source.runId + '.wav' } } }];"
      }
    },
    {
      "id": "36d819c7-4c1a-4b06-9669-6f4325db8d57",
      "name": "Send Voice",
      "type": "n8n-nodes-vk-teams.vkTeams",
      "typeVersion": 1,
      "position": [
        3160,
        -180
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendVoice",
        "chatId": "={{ $(\"Prepare Matrix Inputs\").item.json.chatId }}",
        "binaryPropertyName": "data",
        "keyboard": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "Voice Callback",
                    "buttonType": "callbackData",
                    "callbackData": "={{ \"vk-teams-verification-voice:\" + $(\"Prepare Matrix Inputs\").item.json.runId }}",
                    "style": "attention"
                  }
                ]
              }
            }
          ]
        }
      }
    },
    {
      "id": "b06b30da-715f-48b1-8ba2-c7c46afd86d6",
      "name": "Build Action Report",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3680,
        -180
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const input = $(\"Prepare Matrix Inputs\").first().json;\nreturn [{ json: {\n  phase: \"action_setup\",\n  runId: input.runId,\n  label: input.label,\n  expectedCallbacks: input.expectedCallbacks,\n  messageIds: {\n    sendText: $(\"Send Text\").first().json.msgId,\n    editText: $(\"Send Editable Text\").first().json.msgId,\n    sendFile: $(\"Send File\").first().json.msgId,\n    sendVoice: $(\"Send Voice\").first().json.msgId,\n  },\n  instructions: [\n    \"1. Activate this workflow before clicking buttons so the callback trigger starts long polling.\",\n    \"2. Press the callback buttons in VK Teams.\",\n    \"3. Inspect trigger executions of this workflow: Summarize Trigger Event shows callback payload and Answer Callback Query result.\",\n  ],\n} }];"
      }
    },
    {
      "id": "f6ce6e0e-19a4-48d9-8e0c-8566a8e30f9d",
      "name": "VK Teams Trigger All Events",
      "type": "n8n-nodes-vk-teams.vkTeamsTrigger",
      "typeVersion": 1,
      "position": [
        0,
        520
      ],
      "parameters": {
        "events": [
          "callbackQuery"
        ],
        "chatIds": "",
        "userIds": "",
        "downloadFiles": true
      }
    },
    {
      "id": "9d2bbac1-6065-41ba-a4fb-4dbe341cd74b",
      "name": "Summarize Trigger Event",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        880,
        520
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const event = $(\"Extract Callback Event\").first().json;\nconst answer = $input.first()?.json ?? {};\nreturn [{ json: {\n  verificationArea: \"trigger.callbackQuery\",\n  runId: event.runId,\n  callbackData: event.callbackData,\n  queryId: event.queryId,\n  eventId: event.eventId,\n  userId: event.userId,\n  chatId: event.chatId,\n  messageId: event.messageId,\n  answerStatus: answer.error ? \"failed\" : (answer.ok === true ? \"passed\" : \"unknown\"),\n  answerError: answer.error,\n  answerResult: answer.error ? undefined : answer,\n} }];"
      }
    },
    {
      "id": "7af98ba4-ea5f-4e10-b118-0aa8f4f17ac8",
      "name": "Send Editable Text",
      "type": "n8n-nodes-vk-teams.vkTeams",
      "typeVersion": 1,
      "position": [
        1340,
        -180
      ],
      "credentials": {},
      "parameters": {
        "resource": "message",
        "operation": "sendText",
        "chatId": "={{ $(\"Prepare Matrix Inputs\").item.json.chatId }}",
        "text": "={{ $(\"Prepare Matrix Inputs\").item.json.editableText }}",
        "keyboard": "none"
      }
    },
    {
      "id": "d6e497cc-0f5d-4f5f-bfc7-c47ffb6ebef5",
      "name": "Extract Callback Event",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        320,
        520
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const event = $input.first().json;\nconst callbackData = String(event.payload?.callbackData ?? \"\");\nconst isVerificationCallback = callbackData.startsWith(\"vk-teams-verification-\");\nif (!isVerificationCallback) {\n  return [];\n}\nreturn [{ json: {\n  phase: \"trigger_callback\",\n  runId: callbackData.split(\":\").slice(1).join(\":\"),\n  callbackData,\n  queryId: event.payload?.queryId,\n  eventId: event.eventId,\n  userId: event.payload?.from?.userId,\n  chatId: event.payload?.message?.chat?.chatId ?? event.payload?.chat?.chatId,\n  messageId: event.payload?.message?.msgId,\n} }];"
      }
    },
    {
      "id": "c5bb5efe-9c09-4f74-be2b-c6dcaaf16a59",
      "name": "Answer Callback Query",
      "type": "n8n-nodes-vk-teams.vkTeams",
      "typeVersion": 1,
      "position": [
        600,
        520
      ],
      "parameters": {
        "resource": "callback",
        "operation": "answerCallbackQuery",
        "queryId": "={{ $(\"Extract Callback Event\").item.json.queryId }}",
        "text": "={{ \"Recorded callback \" + $(\"Extract Callback Event\").item.json.callbackData }}"
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "5b34f1bb-cae7-4ff7-8e36-8358c4771a58",
      "name": "Send Callback Confirmation",
      "type": "n8n-nodes-vk-teams.vkTeams",
      "typeVersion": 1,
      "position": [
        600,
        660
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendText",
        "chatId": "={{ $(\"Extract Callback Event\").item.json.chatId }}",
        "text": "={{ \"Callback received: \" + $(\"Extract Callback Event\").item.json.callbackData }}"
      },
      "onError": "continueRegularOutput"
    }
  ],
  "connections": {
    "Run VK Teams Verification Form": {
      "main": [
        [
          {
            "node": "Prepare Matrix Inputs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Matrix Inputs": {
      "main": [
        [
          {
            "node": "Bot Get Self",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bot Get Self": {
      "main": [
        [
          {
            "node": "Chat Get Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Get Info": {
      "main": [
        [
          {
            "node": "Send Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Text": {
      "main": [
        [
          {
            "node": "Send Editable Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Text": {
      "main": [
        [
          {
            "node": "Prepare File Binary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare File Binary": {
      "main": [
        [
          {
            "node": "Send File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send File": {
      "main": [
        [
          {
            "node": "File Get Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File Get Info": {
      "main": [
        [
          {
            "node": "File Download",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File Download": {
      "main": [
        [
          {
            "node": "Prepare Voice Binary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Voice Binary": {
      "main": [
        [
          {
            "node": "Send Voice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Voice": {
      "main": [
        [
          {
            "node": "Build Action Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "VK Teams Trigger All Events": {
      "main": [
        [
          {
            "node": "Extract Callback Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Editable Text": {
      "main": [
        [
          {
            "node": "Edit Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Callback Event": {
      "main": [
        [
          {
            "node": "Answer Callback Query",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Callback Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Answer Callback Query": {
      "main": [
        [
          {
            "node": "Summarize Trigger Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": false
}