{
  "id": "dVgmryFdDhX45Qtz",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "delete-intent-from-dialogflow",
  "tags": [],
  "nodes": [
    {
      "id": "4814e9e2-3437-4740-bd45-c57814bd2b07",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1296,
        352
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "d049076a-8ae3-4990-b234-94dc412c047b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1808,
        -16
      ],
      "parameters": {
        "color": 6,
        "width": 352,
        "height": 336,
        "content": "## Get the full intent\nHere you get the entire content of the intent (in JSON)\n\nEs: se obtiene el intent completo\nAqu\u00ed se obtiene todo el contenido del intent \n(en JSON)"
      },
      "typeVersion": 1
    },
    {
      "id": "b2c5cc2a-96f4-4ed4-ba5d-39fda661dc63",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        256
      ],
      "parameters": {
        "color": 4,
        "width": 320,
        "height": 288,
        "content": "## The intent is removed.\nEs: Mensaje de confirmaci\u00f3n.\n\nSe detalla que el intent ha sido eliminado."
      },
      "typeVersion": 1
    },
    {
      "id": "1987b3b7-981a-42e5-bc00-7671850f35f0",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        304,
        256
      ],
      "parameters": {
        "width": 272,
        "height": 256,
        "content": "## The intent is removed\nEs: se elimina el intent"
      },
      "typeVersion": 1
    },
    {
      "id": "2c26ee70-5c2d-4695-ad4b-76c0c10763c0",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        176
      ],
      "parameters": {
        "color": 5,
        "width": 1008,
        "height": 512,
        "content": "## The user and the submitted keyword are validated.\nEs: Se valida al usuario y la palabra clave enviada."
      },
      "typeVersion": 1
    },
    {
      "id": "2cbbdcf0-8ed0-4e2a-a341-9ad5d946aea5",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1808,
        336
      ],
      "parameters": {
        "color": 6,
        "width": 352,
        "height": 1040,
        "content": "## \ud83d\udd0d Get the **Intent ID** from the URL in Dialogflow\n\nWhen you access Dialogflow and open an intent in your browser, the address bar displays a URL with the following structure:\n\nhttps://dialogflow.cloud.google.com/#/agent/{TU_PROJECT_ID}/intents/{INTENT_ID}/edit\n\nThis would be the final URL you should enter:\nhttps://dialogflow.cloud.google.com/#/agent/{TU_PROJECT_ID}/intents/{INTENT_ID}/edit\n\n- **`{TU_PROJECT_ID}`** \u2192 Corresponds to your project ID in Google Cloud.\n- **`{INTENT_ID}`** \u2192 This is the unique identifier of the intent.\n\n\ud83d\udccc **The `INTENT_ID` is always the last part of the URL before `/edit`**.\nThis is the value you should use to delete a specific intent. \n\n\n\nEs:\n## \ud83d\udd0d Obtener el **Intent ID** desde la URL en Dialogflow\n\nCuando accedes a Dialogflow y abres un intent en tu navegador, la barra de direcciones muestra una URL con la siguiente estructura:\nhttps://dialogflow.cloud.google.com/#/agent/{TU_PROJECT_ID}/intents/{INTENT_ID}/edit\n\nAs\u00ed ser\u00eda la URL final que debes colocar:\nhttps://dialogflow.googleapis.com/v2/projects/{TU_PROJECT_ID}/agent/intents/{INTENT_ID}\n\n- **`{TU_PROJECT_ID}`** \u2192 Corresponde al ID de tu proyecto en Google Cloud.\n- **`{INTENT_ID}`** \u2192 Es el identificador \u00fanico del intent.\n\n\ud83d\udccc **El `INTENT_ID` es siempre la \u00faltima parte de la URL antes de `/edit`**.  \nEste es el valor que debes usar para eliminar un intent espec\u00edfico.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "3c4f9e57-aead-4dfd-b2a1-734df9162de0",
      "name": "HTTP Request ELIMINAR",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        400,
        336
      ],
      "parameters": {
        "url": "https://dialogflow.googleapis.com/v2/projects/bot-encuestador-9iar/agent/intents/acd91730-f3b5-4e58-a7c5-f20f402be4c7",
        "method": "DELETE",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleApi"
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "0cfce610-cd70-4b9d-a775-e5a8c2cc981d",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        224
      ],
      "parameters": {
        "width": 288,
        "height": 320,
        "content": "Get the intent name to use in the confirmation message\n\nEs: se obtiene el nombre del intent para usarlo en el mensaje de confirmaci\u00f3n"
      },
      "typeVersion": 1
    },
    {
      "id": "b5d72f67-580b-42ca-9789-447e9c6bbcac",
      "name": "User validation by ID",
      "type": "n8n-nodes-base.if",
      "position": [
        -1072,
        352
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3f4c5e75-e48d-450a-896b-4bd396851417",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.message.from.id }}",
              "rightValue": "={{ Telegram_user_ID }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2d9191a8-202b-47d9-ba72-ddbe4f52cc1c",
      "name": "Keyword validation",
      "type": "n8n-nodes-base.if",
      "position": [
        -816,
        256
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "30b2659a-c708-4cb4-8576-913182ec1e65",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.message.text }}",
              "rightValue": "delete"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "07ed4d8b-0a8f-4b14-aeae-c9d462fdc9ec",
      "name": "Invalid user message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -928,
        512
      ],
      "parameters": {
        "text": "Invalid user\nUsuario inv\u00e1lido",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "bcdb9a56-ef1a-433b-9f04-802200220ca5",
      "name": "Invalid keyword message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -640,
        432
      ],
      "parameters": {
        "text": "Invalid word\nPalabra inv\u00e1lida",
        "chatId": "={{ $json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cc831247-9911-449d-b2f1-b05431513dfc",
      "name": "HTTP Request GET NAME",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -224,
        352
      ],
      "parameters": {
        "url": "https://dialogflow.googleapis.com/v2/projects/bot-encuestador-9iar/agent/intents/acd91730-f3b5-4e58-a7c5-f20f402be4c7",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "intentView",
              "value": "INTENT_VIEW_FULL"
            }
          ]
        },
        "nodeCredentialType": "googleApi"
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "07f32230-cd28-4461-a079-54b5886d4762",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        336
      ],
      "parameters": {
        "height": 304,
        "content": "After getting the intent name, we wait 1 second before deleting it.\n\nEs: luego de tener el nombre del intent, esperamos 1 segundo antes de eliminarlo"
      },
      "typeVersion": 1
    },
    {
      "id": "1e0f6c87-d607-45f4-8fd2-cc554fe31dba",
      "name": "simulated delay",
      "type": "n8n-nodes-base.wait",
      "position": [
        64,
        496
      ],
      "parameters": {
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "efd79893-8291-43e2-a310-7eadbe24184b",
      "name": "Confirmation message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        768,
        384
      ],
      "parameters": {
        "text": "=The intent: *{{ $('HTTP Request GET NAME').item.json.displayName }}* has been removed.\n\nEl intent: *{{ $('HTTP Request GET NAME').item.json.displayName }}* ha sido eliminado.",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "executeOnce": true,
      "typeVersion": 1.2
    },
    {
      "id": "224f76be-e487-404e-8e65-4827e9a18150",
      "name": "HTTP Request GET",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1680,
        144
      ],
      "parameters": {
        "url": "https://dialogflow.googleapis.com/v2/projects/bot-encuestador-9iar/agent/intents/587093b8-6732-4505-85e1-24a5889cac9b",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "intentView",
              "value": "INTENT_VIEW_FULL"
            }
          ]
        },
        "nodeCredentialType": "googleApi"
      },
      "typeVersion": 4.2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ad8f9a00-502c-42c9-b577-84869af7520c",
  "connections": {
    "simulated delay": {
      "main": [
        [
          {
            "node": "HTTP Request ELIMINAR",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "User validation by ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keyword validation": {
      "main": [
        [
          {
            "node": "HTTP Request GET NAME",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Invalid keyword message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request ELIMINAR": {
      "main": [
        [
          {
            "node": "Confirmation message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request GET NAME": {
      "main": [
        [
          {
            "node": "simulated delay",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "User validation by ID": {
      "main": [
        [
          {
            "node": "Keyword validation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Invalid user message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}