{
  "name": "Tool - ask_clarifying_question (V3)",
  "nodes": [
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "chat_id"
            },
            {
              "name": "question"
            },
            {
              "name": "context"
            },
            {
              "name": "bot_id"
            },
            {
              "name": "image_paths"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.2,
      "position": [
        -736,
        16
      ],
      "id": "f3f66d3a-ce00-462a-b79a-de43a8c25bdd",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "value": "=CZYbTzwR1b6Hn3fr",
          "mode": "id"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "=session_key",
              "keyValue": "={{ $('When Executed by Another Workflow').item.json.bot_id }}_{{ $('When Executed by Another Workflow').item.json.chat_id }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "awaiting_clarification": true,
            "chat_id": "={{ $('When Executed by Another Workflow').item.json.chat_id }}",
            "conversation_history": "={{ JSON.stringify({ question: $('When Executed by Another Workflow').item.json.question, context: $('When Executed by Another Workflow').item.json.context, flagged_at: new Date().toISOString() }) }}",
            "bot_id": "={{ $('When Executed by Another Workflow').item.json.bot_id }}",
            "session_key": "={{ $('When Executed by Another Workflow').item.json.bot_id }}_{{ $('When Executed by Another Workflow').item.json.chat_id }}",
            "image_paths": "={{ $('When Executed by Another Workflow').item.json.image_paths }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "chat_id",
              "displayName": "chat_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "awaiting_clarification",
              "displayName": "awaiting_clarification",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "boolean",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "conversation_history",
              "displayName": "conversation_history",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "bot_id",
              "displayName": "bot_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "session_key",
              "displayName": "session_key",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "image_paths",
              "displayName": "image_paths",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        -336,
        16
      ],
      "id": "7ae6d9fe-1356-4448-ade0-974e069e0ae4",
      "name": "Upsert row(s)"
    },
    {
      "parameters": {
        "chatId": "={{ $json.chat_id }}",
        "text": "={{ $json.question }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -528,
        16
      ],
      "id": "bd27dbdb-e92d-4af9-abe7-c0c4e138a7c4",
      "name": "Send a text message",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a text message": {
      "main": [
        [
          {
            "node": "Upsert row(s)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "169aa104-46c7-4d63-a47a-cfb21095dee1",
  "nodeGroups": [],
  "id": "YRTFbyL20UDGMdPX",
  "tags": [
    {
      "updatedAt": "2026-07-27T07:50:01.682Z",
      "createdAt": "2026-07-27T07:50:01.682Z",
      "id": "oulTjbe8ViVdh1V7",
      "name": "AUTO-P1-V3"
    },
    {
      "updatedAt": "2026-07-20T07:40:54.445Z",
      "createdAt": "2026-07-20T07:40:54.445Z",
      "id": "sBao71AvdSJ3hx2O",
      "name": "3FS"
    }
  ]
}