This workflow corresponds to n8n.io template #4246 — we link there as the canonical source.
This workflow follows the Agent → HTTP Request recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "MVcw4IwqLxTDzdt5",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "Personal - Solicitar TRM",
"tags": [],
"nodes": [
{
"id": "f1d44561-9c6a-4e5d-835b-630e858a3181",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1140,
-620
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-nano",
"cachedResultName": "gpt-4.1-nano"
},
"options": {
"maxRetries": 2,
"temperature": 0
}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "2b3a4c40-77b2-48d3-a2af-8fc084d24183",
"name": "Once a Telegram Message is received",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
-400,
-840
],
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "d8686b18-59d7-461d-a24a-d8f44703db2c",
"name": "Local Current Date and Time",
"type": "n8n-nodes-base.code",
"position": [
920,
-840
],
"parameters": {
"jsCode": "const now = new Date();\n\n// Ajustar a hora local de Colombia (UTC-5)\nconst utc = now.getTime() + now.getTimezoneOffset() * 60000;\nconst colombiaTime = new Date(utc - 5 * 3600000);\n\n// Formato YYYY-MM-DD\nconst fecha = colombiaTime.toISOString().split('T')[0];\n\n// Formato YYYY-MM-DD HH:mm:ss\nconst fechaHora = colombiaTime.toISOString().replace('T', ' ').substring(0, 19);\n\nreturn [\n {\n json: {\n fecha_actual: fecha,\n fecha_hora_actual: fechaHora,\n }\n }\n];"
},
"typeVersion": 2
},
{
"id": "022626cd-5a65-4225-9307-817a024799c2",
"name": "Validate if Date is in the past",
"type": "n8n-nodes-base.if",
"position": [
1700,
-840
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "b245d771-5b2e-4384-8357-0357e5a1ce2e",
"operator": {
"type": "dateTime",
"operation": "after"
},
"leftValue": "={{ $json.output.date }}",
"rightValue": "={{ $('Local Current Date and Time').item.json.fecha_actual }}"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "f40edcdb-ff34-491e-b460-f09353aba40f",
"name": "Notify past date",
"type": "n8n-nodes-base.telegram",
"position": [
1920,
-940
],
"parameters": {
"text": "=Fecha posterior a fecha actual",
"chatId": "={{ $('Once a Telegram Message is received').item.json.message.from.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "9d8c17b5-ce7f-40c0-8e35-64b9b42927f5",
"name": "Get TRM",
"type": "n8n-nodes-base.httpRequest",
"position": [
1920,
-740
],
"parameters": {
"url": "=https://www.datos.gov.co/resource/32sa-8pi3.json?vigenciadesde={{ $json.output.date }}",
"options": {}
},
"typeVersion": 4.2,
"alwaysOutputData": true
},
{
"id": "cd58e419-7d3a-4314-afa3-9fde3c7e998b",
"name": "Check if Valor exists",
"type": "n8n-nodes-base.if",
"position": [
2140,
-740
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "9f3ed730-0414-4f19-9941-2e6663ae221c",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.valor }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "1813eccf-36ae-4201-bbbd-3bc6ebf63e3d",
"name": "Send message to user",
"type": "n8n-nodes-base.telegram",
"position": [
2360,
-840
],
"parameters": {
"text": "={{ $json.valor }}\nTRM del {{ $('Extractor Agent').item.json.output.date }}",
"chatId": "={{ $('Once a Telegram Message is received').item.json.message.from.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "93bb62fb-6e42-4498-a758-4d99ea54a852",
"name": "Generate an array with 10 numbers",
"type": "n8n-nodes-base.code",
"position": [
2360,
-640
],
"parameters": {
"jsCode": "// Generar array del 1 al 10\nconst counter = Array.from({ length: 10 }, (_, i) => i + 1);\n\n// Devolver el resultado en el formato adecuado\nreturn [\n {\n json: {\n counter\n }\n }\n];"
},
"typeVersion": 2
},
{
"id": "c85942c6-1627-49d4-8f62-ffda4f08c6f1",
"name": "Split Items for the loop",
"type": "n8n-nodes-base.splitOut",
"position": [
2580,
-640
],
"parameters": {
"options": {},
"fieldToSplitOut": "counter"
},
"typeVersion": 1
},
{
"id": "9c57b15e-958e-4b1a-ac30-701e7b874319",
"name": "Get the last 10 responses",
"type": "n8n-nodes-base.splitInBatches",
"position": [
2800,
-640
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "59168aad-9ec1-4dc9-9c46-85c1cf4f40a6",
"name": "Get TRM for past date",
"type": "n8n-nodes-base.httpRequest",
"position": [
3240,
-490
],
"parameters": {
"url": "=https://www.datos.gov.co/resource/32sa-8pi3.json?vigenciadesde={{ $json.adjustedDate }}",
"options": {}
},
"typeVersion": 4.2,
"alwaysOutputData": true
},
{
"id": "9a802ea6-8591-4229-840e-b2789e1ef4b5",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
3420,
-500
],
"parameters": {
"color": 4,
"width": 400,
"height": 180,
"content": "## Reason for Loop\nSome TRM are valid for several days, like during weekends or holidays, so 10 days are validated to grab the last available TRM"
},
"typeVersion": 1
},
{
"id": "ca8cae67-d0e1-4bb5-94b6-80c3d00f0b5c",
"name": "Convert date",
"type": "n8n-nodes-base.code",
"position": [
3020,
-640
],
"parameters": {
"jsCode": "const items = $input.all();\nlet counter = $input.first().json.counter;\n\nreturn items.map(item => {\n const originalDate = new Date($('Validate if Date is in the past').item.json.output.date);\n originalDate.setDate(originalDate.getDate() - counter);\n const adjustedDate = originalDate.toISOString().split('T')[0];\n\n const result = {\n ...item.json,\n adjustedDate,\n loopCounter: counter\n };\n\n counter++;\n return { json: result };\n});"
},
"typeVersion": 2
},
{
"id": "370fd786-7611-4148-be16-df28ef18c637",
"name": "Get non-empty rows",
"type": "n8n-nodes-base.filter",
"position": [
3020,
-840
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "2de92428-e76f-4a46-a67a-e28b3fefc845",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.valor }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2,
"alwaysOutputData": true
},
{
"id": "f468d509-68c5-4d78-b22d-86950d1a9792",
"name": "Sort most recent data",
"type": "n8n-nodes-base.sort",
"position": [
3460,
-1040
],
"parameters": {
"options": {},
"sortFieldsUi": {
"sortField": [
{
"order": "descending",
"fieldName": "vigenciadesde"
}
]
}
},
"typeVersion": 1
},
{
"id": "7696b138-dff9-4b08-848f-81d70422779a",
"name": "Get the last data",
"type": "n8n-nodes-base.limit",
"position": [
3680,
-1040
],
"parameters": {},
"typeVersion": 1
},
{
"id": "5fdafe49-ecec-45ac-8e58-f71951bdbacd",
"name": "Send current TRM",
"type": "n8n-nodes-base.telegram",
"position": [
3900,
-1040
],
"parameters": {
"text": "={{ $json.valor }}\nTRM del {{ $('Extractor Agent').item.json.output.date }}",
"chatId": "={{ $('Once a Telegram Message is received').item.json.message.from.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "cb29d564-95cd-4a66-b4a6-9f6ee5204452",
"name": "If",
"type": "n8n-nodes-base.if",
"position": [
3240,
-840
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "d8eff85a-bedc-4363-a46b-5ec32953113f",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.valor }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "dee431c6-80ee-4f37-a291-61b5ee74557e",
"name": "Send no data",
"type": "n8n-nodes-base.telegram",
"position": [
3460,
-840
],
"parameters": {
"text": "=No existe informaci\u00f3n para la fecha proporcionada: {{ $('Extractor Agent').item.json.output.date }}",
"chatId": "={{ $('Once a Telegram Message is received').item.json.message.from.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "d3bef604-c465-48da-8f0b-50a47896968a",
"name": "Calculator",
"type": "@n8n/n8n-nodes-langchain.toolCalculator",
"position": [
1260,
-620
],
"parameters": {},
"typeVersion": 1
},
{
"id": "08e70a77-6801-4beb-b81f-766404cb992a",
"name": "Think",
"type": "@n8n/n8n-nodes-langchain.toolThink",
"position": [
1380,
-620
],
"parameters": {},
"typeVersion": 1
},
{
"id": "ffd80923-e0e2-4198-8ce5-66bff53993fe",
"name": "Extractor Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1232,
-840
],
"parameters": {
"text": "={{ $('Edit Fields').item.json.text }}",
"options": {
"systemMessage": "=Eres un algoritmo experto en extracci\u00f3n de informaci\u00f3n.\nFecha actual: {{ $json.fecha_actual }}\nTu tarea es identificar y extraer fechas mencionadas en un texto escrito en espa\u00f1ol, incluso si est\u00e1n redactadas de forma natural o ambigua.\nSigue estas reglas:\n\t\u2022\tSi el texto menciona una fecha expl\u00edcita o relativa (por ejemplo: \u201c20 de mayo\u201d, \u201cel 17\u201d, \u201cayer\u201d, \u201cantier\u201d, \u201choy\u201d), extrae la fecha en formato AAAA-MM-DD.\n\t\u2022\tSi una fecha no incluye el a\u00f1o, asume el a\u00f1o actual.\n\t\u2022\tSi no incluye ni mes ni a\u00f1o, asume el mes y a\u00f1o actuales.\n\t\u2022\tSi el texto no contiene una fecha clara pero es ambiguo (como \u201cHola\u201d, \u201cok\u201d, \u201clisto\u201d, \u201cgracias\u201d), devuelve la fecha actual.\n\t\u2022\tNo generes ning\u00fan texto adicional, solo la fecha en formato AAAA-MM-DD."
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.9
},
{
"id": "8b49d5c6-ce05-4ca9-a231-0bd4686040bf",
"name": "Text only",
"type": "n8n-nodes-base.set",
"position": [
480,
-740
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "311e21c9-7edc-446d-9857-c9e60a429678",
"name": "text",
"type": "string",
"value": "={{ $json.message.text }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "e586891d-2af9-4a04-bb40-3b3f3f216bf4",
"name": "Audio Text",
"type": "n8n-nodes-base.set",
"position": [
480,
-940
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "49569683-a732-47a9-8fbf-6e6303c03ad1",
"name": "text",
"type": "string",
"value": "={{ $json.text }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "ff0b076d-9c39-4e98-a71c-a2f3f6df3231",
"name": "Edit Fields",
"type": "n8n-nodes-base.set",
"position": [
700,
-840
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "72ede214-3023-459d-8a27-14be602440bf",
"name": "text",
"type": "string",
"value": "={{ $json.text }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "70c427d1-8f32-49a0-ac32-6cf4a57d92e1",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
1500,
-620
],
"parameters": {
"jsonSchemaExample": "{\n\t\"date\": \"2025-04-01\"\n}"
},
"typeVersion": 1.2
},
{
"id": "9cde8b3a-6e49-4843-a11d-e78d46204c4c",
"name": "Validate Text or Audio",
"type": "n8n-nodes-base.switch",
"position": [
-180,
-840
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "voice",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "eaaa57f6-51e2-41c9-8a56-a78547c0a8c5",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.voice }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "text",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "1fda3a77-2a23-43b2-aaae-2ed3f0eed1f6",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.text }}",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {
"fallbackOutput": "none"
}
},
"typeVersion": 3.2
},
{
"id": "75fc07c0-455c-490a-8ac9-422ddfee9b48",
"name": "Download Audio",
"type": "n8n-nodes-base.telegram",
"position": [
40,
-940
],
"parameters": {
"fileId": "={{ $json.message.voice.file_id }}",
"resource": "file"
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "47379a28-148b-4a36-8f06-4c994613d83c",
"name": "Transcribe Audio",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
260,
-940
],
"parameters": {
"options": {
"language": "es",
"temperature": 0
},
"resource": "audio",
"operation": "transcribe",
"binaryPropertyName": "=data"
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.8
},
{
"id": "1e3e8207-fc34-4c83-8fb4-8aa7a4639c4b",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-900,
-1700
],
"parameters": {
"color": 3,
"width": 840,
"height": 780,
"content": "# \ud83d\udccc Workflow: Request TRM (Representative Market Rate)\n\n## \ud83c\udfaf Objective\n\nRetrieve the TRM (Colombian Peso to US Dollar exchange rate) for a specific date provided by the user via Telegram.\n\n## \ud83d\udd04 Summary Flow\n\n1. \ud83d\udce8 **Telegram Message** \n The user sends a text or audio to a Telegram Bot.\n\n2. \ud83e\udde0 **Date Extraction** \n AI (OpenAI) is used to identify the date in `YYYY-MM-DD` format.\n\n3. \ud83d\udcc5 **Validation** \n If the date is in the future, the user is notified that it is not valid.\n\n4. \ud83d\udce1 **TRM Query** \n The bot queries the open data API from the Colombian government.\n\n5. \ud83d\udce5 **Result** \n - \u2705 If TRM data exists for that date \u2192 The bot replies to the user. \n - \u274c If not \u2192 It searches up to 10 previous days for available data.\n\n6. \ud83d\udce4 **Final Response** \n The most recent available value is sent, or a message indicating no information is available.\n\n## \ud83d\udd17 Data Source\n**datos.gov.co** \u2013 [TRM](https://www.datos.gov.co/)"
},
"typeVersion": 1
}
],
"active": true,
"settings": {
"callerPolicy": "workflowsFromSameOwner",
"executionOrder": "v1",
"executionTimeout": 60
},
"versionId": "1141769b-3bb4-4f42-8bcf-d8c64ae27cd6",
"connections": {
"If": {
"main": [
[
{
"node": "Sort most recent data",
"type": "main",
"index": 0
}
],
[
{
"node": "Send no data",
"type": "main",
"index": 0
}
]
]
},
"Think": {
"ai_tool": [
[
{
"node": "Extractor Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Get TRM": {
"main": [
[
{
"node": "Check if Valor exists",
"type": "main",
"index": 0
}
]
]
},
"Text only": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Audio Text": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Calculator": {
"ai_tool": [
[
{
"node": "Extractor Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Local Current Date and Time",
"type": "main",
"index": 0
}
]
]
},
"Convert date": {
"main": [
[
{
"node": "Get TRM for past date",
"type": "main",
"index": 0
}
]
]
},
"Download Audio": {
"main": [
[
{
"node": "Transcribe Audio",
"type": "main",
"index": 0
}
]
]
},
"Extractor Agent": {
"main": [
[
{
"node": "Validate if Date is in the past",
"type": "main",
"index": 0
}
]
]
},
"Transcribe Audio": {
"main": [
[
{
"node": "Audio Text",
"type": "main",
"index": 0
}
]
]
},
"Get the last data": {
"main": [
[
{
"node": "Send current TRM",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Extractor Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Get non-empty rows": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"Check if Valor exists": {
"main": [
[
{
"node": "Send message to user",
"type": "main",
"index": 0
}
],
[
{
"node": "Generate an array with 10 numbers",
"type": "main",
"index": 0
}
]
]
},
"Get TRM for past date": {
"main": [
[
{
"node": "Get the last 10 responses",
"type": "main",
"index": 0
}
]
]
},
"Sort most recent data": {
"main": [
[
{
"node": "Get the last data",
"type": "main",
"index": 0
}
]
]
},
"Validate Text or Audio": {
"main": [
[
{
"node": "Download Audio",
"type": "main",
"index": 0
}
],
[
{
"node": "Text only",
"type": "main",
"index": 0
}
]
]
},
"Split Items for the loop": {
"main": [
[
{
"node": "Get the last 10 responses",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Extractor Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Get the last 10 responses": {
"main": [
[
{
"node": "Get non-empty rows",
"type": "main",
"index": 0
}
],
[
{
"node": "Convert date",
"type": "main",
"index": 0
}
]
]
},
"Local Current Date and Time": {
"main": [
[
{
"node": "Extractor Agent",
"type": "main",
"index": 0
}
]
]
},
"Validate if Date is in the past": {
"main": [
[
{
"node": "Notify past date",
"type": "main",
"index": 0
}
],
[
{
"node": "Get TRM",
"type": "main",
"index": 0
}
]
]
},
"Generate an array with 10 numbers": {
"main": [
[
{
"node": "Split Items for the loop",
"type": "main",
"index": 0
}
]
]
},
"Once a Telegram Message is received": {
"main": [
[
{
"node": "Validate Text or Audio",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
openAiApitelegramApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Retrieve the TRM (Colombian Peso to US Dollar exchange rate) for a specific date provided by the user via Telegram. 📨 Telegram Message The user sends a text or audio message to the Telegram Bot. 🧠 Date Extraction AI (OpenAI) is used to identify the date in format. 📅 Validation…
Source: https://n8n.io/workflows/4246/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
🎯 Create viral TikToks, Shorts, Reels, podcasts, and ASMR videos in minutes — all on autopilot.
Generate AI viral videos with NanoBanana & VEO3, shared on socials via Blotato 2. Uses @blotato/n8n-nodes-blotato, googleSheets, lmChatOpenAi, toolThink. Event-driven trigger; 94 nodes.
RAG CHATBOT Main. Uses telegram, telegramTrigger, lmChatOpenAi, n8n-nodes-mcp. Event-driven trigger; 87 nodes.
Creators, marketers, and brands that want to turn a single product photo into premium motion clips, then optionally publish to Instagram/TikTok/YouTube via LATE. No editing skills required.
Product to Social Video (xCodeWraith Edition). Uses telegram, agentTool, telegramTrigger, httpRequest. Event-driven trigger; 83 nodes.