Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "nodes": [
- {
- "parameters": {
- "public": true,
- "initialMessages": "Please upload a TXT file, and the bot will generate an HTML version of the file.",
- "options": {
- "allowFileUploads": true,
- "allowedFilesMimeTypes": "txt",
- "responseMode": "lastNode",
- "showWelcomeScreen": false
- }
- },
- "id": "aa5f3deb-1da8-4b19-8ba5-5edf359c7732",
- "name": "When chat message received",
- "type": "@n8n/n8n-nodes-langchain.chatTrigger",
- "typeVersion": 1.1,
- "position": [
- -200,
- 40
- ],
- "webhookId": "a7342398-9e87-4e4e-8b11-396a05a06c5b"
- },
- {
- "parameters": {
- "assignments": {
- "assignments": [
- {
- "id": "11a4b1e5-2065-4bfd-ba7c-12def5c65116",
- "name": "sessionId",
- "value": "={{ $('When chat message received').first().json.sessionId }}",
- "type": "string"
- },
- {
- "id": "43953933-fc55-46c0-8376-cfc357789dbb",
- "name": "action",
- "value": "={{ $('When chat message received').first().json.action }}",
- "type": "string"
- },
- {
- "id": "9869788e-1743-41dc-ad6d-b48a80fa86af",
- "name": "chatInput",
- "value": "={{ $('When chat message received').first().json.chatInput }}",
- "type": "string"
- },
- {
- "id": "d2834c08-396e-4735-a919-05a46109c311",
- "name": "files",
- "value": "={{ $json.files }}",
- "type": "array"
- }
- ]
- },
- "options": {}
- },
- "id": "a3094b72-6c9f-4ae3-a79e-f864fced2c46",
- "name": "Set Fields",
- "type": "n8n-nodes-base.set",
- "typeVersion": 3.4,
- "position": [
- 500,
- 20
- ]
- },
- {
- "parameters": {},
- "id": "85daf9c3-ccf7-4634-8897-688a7bd9dd9a",
- "name": "Execute Workflow Trigger",
- "type": "n8n-nodes-base.executeWorkflowTrigger",
- "typeVersion": 1,
- "position": [
- 180,
- 420
- ]
- },
- {
- "parameters": {
- "assignments": {
- "assignments": [
- {
- "id": "f1f677cd-31be-4383-adcf-f01eb83899d7",
- "name": "response",
- "value": "={{ $json.fileName }}",
- "type": "string"
- }
- ]
- },
- "options": {}
- },
- "id": "4d7b4a5f-3cf0-4b17-a25a-f8623753aa09",
- "name": "Send Response1",
- "type": "n8n-nodes-base.set",
- "typeVersion": 3.4,
- "position": [
- 1000,
- 420
- ]
- },
- {
- "parameters": {
- "promptType": "define",
- "text": "=chatInput: {{ $json.chatInput }}\nuploadedFile: {{\n$json.files\n ? `/home/node/temp/${$json.files[0].fileName}`\n : ''\n}}",
- "options": {
- "systemMessage": "You are a file conversion assistant and can use the txt2html tool to convert the user's uploaded file into an HTML file.\n\nReply to the user with the final download link for the HTML file."
- }
- },
- "id": "ebb30072-305c-49cc-bbc4-fb2c21dd8c79",
- "name": "AI Agent",
- "type": "@n8n/n8n-nodes-langchain.agent",
- "typeVersion": 1.7,
- "position": [
- 700,
- 20
- ]
- },
- {
- "parameters": {
- "rules": {
- "values": [
- {
- "conditions": {
- "options": {
- "caseSensitive": true,
- "leftValue": "",
- "typeValidation": "strict",
- "version": 2
- },
- "conditions": [
- {
- "leftValue": "={{ $json.files }}",
- "rightValue": "",
- "operator": {
- "type": "array",
- "operation": "notExists",
- "singleValue": true
- }
- }
- ],
- "combinator": "and"
- },
- "renameOutput": true,
- "outputKey": "without files"
- },
- {
- "conditions": {
- "options": {
- "caseSensitive": true,
- "leftValue": "",
- "typeValidation": "strict",
- "version": 2
- },
- "conditions": [
- {
- "id": "0d67ec0a-1d61-4f6a-97e5-965b0d340ae4",
- "leftValue": "={{ $json.files }}",
- "rightValue": "",
- "operator": {
- "type": "array",
- "operation": "exists",
- "singleValue": true
- }
- }
- ],
- "combinator": "and"
- },
- "renameOutput": true,
- "outputKey": "with files"
- }
- ]
- },
- "options": {}
- },
- "id": "6a898fc0-5767-4a28-bba3-7dfe807add96",
- "name": "Has Files?",
- "type": "n8n-nodes-base.switch",
- "typeVersion": 3.2,
- "position": [
- -20,
- 40
- ]
- },
- {
- "parameters": {
- "fileSelector": "={{ $json.query.filepath }}",
- "options": {}
- },
- "id": "767e8e71-1126-4f9c-8f57-33cecf42607a",
- "name": "Read File",
- "type": "n8n-nodes-base.readWriteFile",
- "typeVersion": 1,
- "position": [
- 400,
- 420
- ]
- },
- {
- "parameters": {},
- "id": "acdde5ce-69c4-43a1-becc-3eb4bb42c4f9",
- "name": "Window Buffer Memory",
- "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
- "typeVersion": 1.3,
- "position": [
- 620,
- 280
- ]
- },
- {
- "parameters": {
- "operation": "write",
- "fileName": "={{ `/home/node/temp/${$json.files[0].fileName}` }}",
- "dataPropertyName": "data0",
- "options": {}
- },
- "id": "4c271ad3-92aa-4420-9990-6d0d0f44002d",
- "name": "Read/Write Files from Disk",
- "type": "n8n-nodes-base.readWriteFile",
- "typeVersion": 1,
- "position": [
- 220,
- 140
- ]
- },
- {
- "parameters": {
- "options": {
- "baseURL": "https://oneapi.6868ai.com/v1"
- }
- },
- "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
- "typeVersion": 1,
- "position": [
- 440,
- 280
- ],
- "id": "3f727155-1c15-4301-80a9-0ae0b8ba1c77",
- "name": "OpenAI Chat Model",
- "credentials": {
- "openAiApi": {
- "id": "oYt1X4B1EySK0Ho4",
- "name": "OpenAi account"
- }
- }
- },
- {
- "parameters": {
- "operation": "html",
- "options": {}
- },
- "type": "n8n-nodes-base.convertToFile",
- "typeVersion": 1.1,
- "position": [
- 620,
- 420
- ],
- "id": "13c15c26-0657-4a02-a4a9-7ecf9361b6cc",
- "name": "Convert to File"
- },
- {
- "parameters": {
- "operation": "write",
- "fileName": "={{ $('Execute Workflow Trigger').item.json.query.filepath.replaceAll('.txt', '.html') }}",
- "options": {}
- },
- "type": "n8n-nodes-base.readWriteFile",
- "typeVersion": 1,
- "position": [
- 820,
- 420
- ],
- "id": "4fe96e16-530a-44b9-b154-8eca49f4c5b2",
- "name": "Read/Write Files from Disk1"
- },
- {
- "parameters": {
- "name": "txt2pdf",
- "description": "Use this tool to convert the TXT file at the specified path to an HTML file",
- "workflowId": {
- "__rl": true,
- "value": "={{ $workflow.id }}",
- "mode": "id"
- },
- "fields": {
- "values": [
- {
- "name": "filePath",
- "stringValue": "={{ $fromAI(\"filepath\", \".txt file path\", \"\") }}"
- }
- ]
- },
- "specifyInputSchema": true,
- "schemaType": "manual",
- "inputSchema": "{\n\"type\": \"object\",\n\"properties\": {\n\t\"filepath\": { \"type\": \"string\" }\n }\n}"
- },
- "id": "4daf5aca-46b2-44cd-b16f-31556a1725df",
- "name": "txt2html",
- "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
- "typeVersion": 1.2,
- "position": [
- 780,
- 280
- ]
- }
- ],
- "connections": {
- "When chat message received": {
- "main": [
- [
- {
- "node": "Has Files?",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Set Fields": {
- "main": [
- [
- {
- "node": "AI Agent",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Execute Workflow Trigger": {
- "main": [
- [
- {
- "node": "Read File",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "AI Agent": {
- "main": [
- []
- ]
- },
- "Has Files?": {
- "main": [
- [
- {
- "node": "Set Fields",
- "type": "main",
- "index": 0
- }
- ],
- [
- {
- "node": "Read/Write Files from Disk",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Read File": {
- "main": [
- [
- {
- "node": "Convert to File",
- "type": "main",
- "index": 0
- }
- ],
- []
- ]
- },
- "Window Buffer Memory": {
- "ai_memory": [
- [
- {
- "node": "AI Agent",
- "type": "ai_memory",
- "index": 0
- }
- ]
- ]
- },
- "Read/Write Files from Disk": {
- "main": [
- [
- {
- "node": "Set Fields",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "OpenAI Chat Model": {
- "ai_languageModel": [
- [
- {
- "node": "AI Agent",
- "type": "ai_languageModel",
- "index": 0
- }
- ]
- ]
- },
- "Convert to File": {
- "main": [
- [
- {
- "node": "Read/Write Files from Disk1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Read/Write Files from Disk1": {
- "main": [
- [
- {
- "node": "Send Response1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "txt2html": {
- "ai_tool": [
- [
- {
- "node": "AI Agent",
- "type": "ai_tool",
- "index": 0
- }
- ]
- ]
- }
- },
- "pinData": {
- "Execute Workflow Trigger": [
- {
- "query": {
- "filepath": "/home/node/temp/hello.txt"
- }
- }
- ]
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment