Bot de Gestión de Recursos
Other
Aitor
(@TuXeD)
Este bot automatiza la gestión y publicación de recursos en un canal de Telegram dedicado a la comunidad de N8N. Permite a los usuarios enviar recursos con un formulario web, asignar hashtags y emojis según la categoría del recurso, y compartirlos automáticamente en el canal. Además, proporciona botones interactivos para ver o publicar nuevos recursos, facilitando la colaboración y el intercambio de conocimientos en la comunidad.
Creado: 2024-11-26
9 nodos
Editar Workflow
Visualización del Workflow
{
"name": "Recursos N8N",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "b633635c-1606-4910-94db-efcb0591cn8n",
"responseMode": "responseNode",
"options": {}
},
"id": "9e00d57c-3df2-4bf8-b292-22a9c680d7ac",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
300,
-80
],
"webhookId": "3aab327b-718f-4a21-9918-558f31247542"
},
{
"parameters": {
"chatId": "@comunidadn8n",
"text": "={{ $json.message }}",
"replyMarkup": "inlineKeyboard",
"inlineKeyboard": {
"rows": [
{
"row": {
"buttons": [
{
"text": "\ud83d\udd17 Ver Recurso",
"additionalFields": {
"url": "={{ $json.URL }}"
}
},
{
"text": "\u2764\ufe0f Publicar Recurso",
"additionalFields": {
"url": "https://t.me/recursosn8nbot"
}
}
]
}
}
]
},
"additionalFields": {
"appendAttribution": false,
"parse_mode": "HTML",
"message_thread_id": 25727
}
},
"id": "fe3c9fb7-9d4b-4779-81ed-3e1344dbe40e",
"name": "Telegram",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.1,
"position": [
780,
-80
],
"credentials": {
"telegramApi": {
"id": "fKFjxVRPWloDc0BR",
"name": "Greeg"
}
}
},
{
"parameters": {
"jsCode": "const formatMessage = (body) => {\n // Mapping of resources to hashtags and icons\n const resources = {\n 'API': { icon: '\ud83d\udd0c', hashtag: '#APIsUtiles' },\n 'IA': { icon: '\ud83e\udde0', hashtag: '#InteligenciaArtificial' },\n 'Nodes': { icon: '\ud83c\udf10', hashtag: '#NodesN8n' },\n 'Snippet': { icon: '\ud83d\udcc4', hashtag: '#CodigoSnippet' },\n 'Cursos': { icon: '\ud83c\udf93', hashtag: '#CursosOnline' },\n 'Herramientas': { icon: '\ud83d\udd28', hashtag: '#HerramientasUtiles' }\n };\n\n // Extract the relevant fields from the body\n const { username, recurso, titulo, descripci\u00f3n, URL } = body;\n\n // Split the resource to get the key (e.g., \"Extensiones\") and find the corresponding icon and hashtag\n const resourceKey = recurso.split(':')[0].trim(); // Get the key before the colon\n const { icon, hashtag } = resources[resourceKey] || { icon: '', hashtag: '' }; // Fallback in case the key doesn't match\n\n // Build the message with formatting\n let message = `${icon} ${titulo}\\n\\n${descripci\u00f3n}\\n\\nvia: @${username}\\n${hashtag}`;\n\n // Return the message and URL as separate properties\n return { message, URL };\n};\n\n// Assume we receive the response from a previous node\nconst responseBody = items[0].json.body; // This will be the actual path to the body in your n8n item\n\n// Process the responseBody with the formatMessage function\nconst outputData = formatMessage(responseBody);\n\n// Return the output in an n8n compatible format\nreturn [{json: outputData}];\n"
},
"id": "c29f3879-2eb7-41bf-bd6c-469a0b8150be",
"name": "Code",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
540,
-80
]
},
{
"parameters": {
"respondWith": "text",
"responseBody": "=https://t.me/c/1622923079/{{ $json[\"result\"][\"message_thread_id\"] }}/{{ $json[\"result\"][\"message_id\"] }}",
"options": {}
},
"id": "ddb2ab5a-f56c-43f4-837e-45e49f34fc6f",
"name": "Respond to Webhook",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
1000,
-80
]
},
{
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"id": "382abd5d-e6b8-467a-8870-3367369aaca8",
"name": "Telegram Trigger",
"type": "n8n-nodes-base.telegramTrigger",
"typeVersion": 1.1,
"position": [
300,
200
],
"webhookId": "4fc5e6e9-489d-4a3e-9a16-9efc580c9147",
"credentials": {
"telegramApi": {
"id": "G3CkOazOsHuhQmi3",
"name": "RecursosN8N"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "2d40f99c-7865-4dd1-b0fa-52382368a673",
"leftValue": "={{ $json.message.chat.is_forum }}",
"rightValue": "",
"operator": {
"type": "boolean",
"operation": "false",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "02b22014-8bb6-4612-b736-cf67cc8beafc",
"name": "If",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
500,
200
]
},
{
"parameters": {},
"id": "9ac91407-d0b4-4b4a-abca-78264cd64e9d",
"name": "No Operation, do nothing",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
760,
400
]
},
{
"parameters": {
"method": "POST",
"url": "https://api.telegram.org/botrestodetutoken****/sendMessage",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"chat_id\": \"{{ $json.message.chat.id }}\",\n \"text\": \"\u00a1Hola, {{ $json.message.chat.first_name }} bienvenido al bot de a\u00f1adir recursos de The {AI} rtist! \ud83d\udc4b\\n\\nMe especializo en ayudarte a compartir recursos valiosos con nuestra comunidad. Si tienes herramientas, art\u00edculos, noticias, o cualquier tipo de contenido que creas que puede aportar valor, estoy aqu\u00ed para facilitar su inclusi\u00f3n.\\n\\nHaz clic en el bot\u00f3n de abajo para enviar un recurso a trav\u00e9s de nuestro formulario f\u00e1cil de usar.\",\n \"parse_mode\": \"HTML\",\n \"reply_markup\": {\n \"inline_keyboard\": [\n [\n {\n \"text\": \"\u2795 A\u00f1adir recurso\",\n \"web_app\": {\n \"url\": \"https://n1mbot.cloud/recursos-n8n?username={{ $json.message.chat.username }}&first_name={{ $json.message.chat.first_name }}\"\n }\n }\n ]\n ]\n }\n}",
"options": {}
},
"id": "06135fff-6926-40fe-b6a7-531de3dd7dac",
"name": "Miembro",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
880,
180
]
},
{
"parameters": {
"chatId": "@comunidadn8n",
"text": "=\ud83d\udccc A\u00f1ade tu recurso ahora:\nHaz clic en el bot\u00f3n de abajo para compartir un recurso.\n",
"replyMarkup": "inlineKeyboard",
"inlineKeyboard": {
"rows": [
{
"row": {
"buttons": [
{
"text": "\u2795 A\u00f1adir recurso",
"additionalFields": {
"url": "=tg://resolve?domain=recursosn8nbot"
}
}
]
}
}
]
},
"additionalFields": {
"appendAttribution": false,
"parse_mode": "HTML",
"message_thread_id": 25727
}
},
"id": "88061888-a5f5-4813-8add-7da2c9f769a0",
"name": "Telegram1",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.1,
"position": [
0,
120
],
"credentials": {
"telegramApi": {
"id": "fKFjxVRPWloDc0BR",
"name": "Greeg"
}
}
}
],
"pinData": {},
"connections": {
"Webhook": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "Telegram",
"type": "main",
"index": 0
}
]
]
},
"Telegram": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
},
"Telegram Trigger": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"If": {
"main": [
[
{
"node": "Miembro",
"type": "main",
"index": 0
}
],
[
{
"node": "No Operation, do nothing",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1"
},
"versionId": "98267094-e1ed-4b2a-8be7-90d080d61169",
"meta": {
"instanceId": "48e98d95aab2af437c32c405e45972f4530dc31ea677ecacdd27272a056e4d7b"
},
"id": "rSYi2KmG9BLI3jAY",
"tags": [
{
"createdAt": "2023-03-05T17:20:00.336Z",
"updatedAt": "2023-03-05T17:20:00.336Z",
"id": "8",
"name": "HiveAgile"
}
]
}