Guest User

txt2html

a guest
Dec 4th, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.15 KB | None | 0 0
  1. {
  2. "nodes": [
  3. {
  4. "parameters": {
  5. "public": true,
  6. "initialMessages": "Please upload a TXT file, and the bot will generate an HTML version of the file.",
  7. "options": {
  8. "allowFileUploads": true,
  9. "allowedFilesMimeTypes": "txt",
  10. "responseMode": "lastNode",
  11. "showWelcomeScreen": false
  12. }
  13. },
  14. "id": "aa5f3deb-1da8-4b19-8ba5-5edf359c7732",
  15. "name": "When chat message received",
  16. "type": "@n8n/n8n-nodes-langchain.chatTrigger",
  17. "typeVersion": 1.1,
  18. "position": [
  19. -200,
  20. 40
  21. ],
  22. "webhookId": "a7342398-9e87-4e4e-8b11-396a05a06c5b"
  23. },
  24. {
  25. "parameters": {
  26. "assignments": {
  27. "assignments": [
  28. {
  29. "id": "11a4b1e5-2065-4bfd-ba7c-12def5c65116",
  30. "name": "sessionId",
  31. "value": "={{ $('When chat message received').first().json.sessionId }}",
  32. "type": "string"
  33. },
  34. {
  35. "id": "43953933-fc55-46c0-8376-cfc357789dbb",
  36. "name": "action",
  37. "value": "={{ $('When chat message received').first().json.action }}",
  38. "type": "string"
  39. },
  40. {
  41. "id": "9869788e-1743-41dc-ad6d-b48a80fa86af",
  42. "name": "chatInput",
  43. "value": "={{ $('When chat message received').first().json.chatInput }}",
  44. "type": "string"
  45. },
  46. {
  47. "id": "d2834c08-396e-4735-a919-05a46109c311",
  48. "name": "files",
  49. "value": "={{ $json.files }}",
  50. "type": "array"
  51. }
  52. ]
  53. },
  54. "options": {}
  55. },
  56. "id": "a3094b72-6c9f-4ae3-a79e-f864fced2c46",
  57. "name": "Set Fields",
  58. "type": "n8n-nodes-base.set",
  59. "typeVersion": 3.4,
  60. "position": [
  61. 500,
  62. 20
  63. ]
  64. },
  65. {
  66. "parameters": {},
  67. "id": "85daf9c3-ccf7-4634-8897-688a7bd9dd9a",
  68. "name": "Execute Workflow Trigger",
  69. "type": "n8n-nodes-base.executeWorkflowTrigger",
  70. "typeVersion": 1,
  71. "position": [
  72. 180,
  73. 420
  74. ]
  75. },
  76. {
  77. "parameters": {
  78. "assignments": {
  79. "assignments": [
  80. {
  81. "id": "f1f677cd-31be-4383-adcf-f01eb83899d7",
  82. "name": "response",
  83. "value": "={{ $json.fileName }}",
  84. "type": "string"
  85. }
  86. ]
  87. },
  88. "options": {}
  89. },
  90. "id": "4d7b4a5f-3cf0-4b17-a25a-f8623753aa09",
  91. "name": "Send Response1",
  92. "type": "n8n-nodes-base.set",
  93. "typeVersion": 3.4,
  94. "position": [
  95. 1000,
  96. 420
  97. ]
  98. },
  99. {
  100. "parameters": {
  101. "promptType": "define",
  102. "text": "=chatInput: {{ $json.chatInput }}\nuploadedFile: {{\n$json.files\n ? `/home/node/temp/${$json.files[0].fileName}`\n : ''\n}}",
  103. "options": {
  104. "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."
  105. }
  106. },
  107. "id": "ebb30072-305c-49cc-bbc4-fb2c21dd8c79",
  108. "name": "AI Agent",
  109. "type": "@n8n/n8n-nodes-langchain.agent",
  110. "typeVersion": 1.7,
  111. "position": [
  112. 700,
  113. 20
  114. ]
  115. },
  116. {
  117. "parameters": {
  118. "rules": {
  119. "values": [
  120. {
  121. "conditions": {
  122. "options": {
  123. "caseSensitive": true,
  124. "leftValue": "",
  125. "typeValidation": "strict",
  126. "version": 2
  127. },
  128. "conditions": [
  129. {
  130. "leftValue": "={{ $json.files }}",
  131. "rightValue": "",
  132. "operator": {
  133. "type": "array",
  134. "operation": "notExists",
  135. "singleValue": true
  136. }
  137. }
  138. ],
  139. "combinator": "and"
  140. },
  141. "renameOutput": true,
  142. "outputKey": "without files"
  143. },
  144. {
  145. "conditions": {
  146. "options": {
  147. "caseSensitive": true,
  148. "leftValue": "",
  149. "typeValidation": "strict",
  150. "version": 2
  151. },
  152. "conditions": [
  153. {
  154. "id": "0d67ec0a-1d61-4f6a-97e5-965b0d340ae4",
  155. "leftValue": "={{ $json.files }}",
  156. "rightValue": "",
  157. "operator": {
  158. "type": "array",
  159. "operation": "exists",
  160. "singleValue": true
  161. }
  162. }
  163. ],
  164. "combinator": "and"
  165. },
  166. "renameOutput": true,
  167. "outputKey": "with files"
  168. }
  169. ]
  170. },
  171. "options": {}
  172. },
  173. "id": "6a898fc0-5767-4a28-bba3-7dfe807add96",
  174. "name": "Has Files?",
  175. "type": "n8n-nodes-base.switch",
  176. "typeVersion": 3.2,
  177. "position": [
  178. -20,
  179. 40
  180. ]
  181. },
  182. {
  183. "parameters": {
  184. "fileSelector": "={{ $json.query.filepath }}",
  185. "options": {}
  186. },
  187. "id": "767e8e71-1126-4f9c-8f57-33cecf42607a",
  188. "name": "Read File",
  189. "type": "n8n-nodes-base.readWriteFile",
  190. "typeVersion": 1,
  191. "position": [
  192. 400,
  193. 420
  194. ]
  195. },
  196. {
  197. "parameters": {},
  198. "id": "acdde5ce-69c4-43a1-becc-3eb4bb42c4f9",
  199. "name": "Window Buffer Memory",
  200. "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
  201. "typeVersion": 1.3,
  202. "position": [
  203. 620,
  204. 280
  205. ]
  206. },
  207. {
  208. "parameters": {
  209. "operation": "write",
  210. "fileName": "={{ `/home/node/temp/${$json.files[0].fileName}` }}",
  211. "dataPropertyName": "data0",
  212. "options": {}
  213. },
  214. "id": "4c271ad3-92aa-4420-9990-6d0d0f44002d",
  215. "name": "Read/Write Files from Disk",
  216. "type": "n8n-nodes-base.readWriteFile",
  217. "typeVersion": 1,
  218. "position": [
  219. 220,
  220. 140
  221. ]
  222. },
  223. {
  224. "parameters": {
  225. "options": {
  226. "baseURL": "https://oneapi.6868ai.com/v1"
  227. }
  228. },
  229. "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
  230. "typeVersion": 1,
  231. "position": [
  232. 440,
  233. 280
  234. ],
  235. "id": "3f727155-1c15-4301-80a9-0ae0b8ba1c77",
  236. "name": "OpenAI Chat Model",
  237. "credentials": {
  238. "openAiApi": {
  239. "id": "oYt1X4B1EySK0Ho4",
  240. "name": "OpenAi account"
  241. }
  242. }
  243. },
  244. {
  245. "parameters": {
  246. "operation": "html",
  247. "options": {}
  248. },
  249. "type": "n8n-nodes-base.convertToFile",
  250. "typeVersion": 1.1,
  251. "position": [
  252. 620,
  253. 420
  254. ],
  255. "id": "13c15c26-0657-4a02-a4a9-7ecf9361b6cc",
  256. "name": "Convert to File"
  257. },
  258. {
  259. "parameters": {
  260. "operation": "write",
  261. "fileName": "={{ $('Execute Workflow Trigger').item.json.query.filepath.replaceAll('.txt', '.html') }}",
  262. "options": {}
  263. },
  264. "type": "n8n-nodes-base.readWriteFile",
  265. "typeVersion": 1,
  266. "position": [
  267. 820,
  268. 420
  269. ],
  270. "id": "4fe96e16-530a-44b9-b154-8eca49f4c5b2",
  271. "name": "Read/Write Files from Disk1"
  272. },
  273. {
  274. "parameters": {
  275. "name": "txt2pdf",
  276. "description": "Use this tool to convert the TXT file at the specified path to an HTML file",
  277. "workflowId": {
  278. "__rl": true,
  279. "value": "={{ $workflow.id }}",
  280. "mode": "id"
  281. },
  282. "fields": {
  283. "values": [
  284. {
  285. "name": "filePath",
  286. "stringValue": "={{ $fromAI(\"filepath\", \".txt file path\", \"\") }}"
  287. }
  288. ]
  289. },
  290. "specifyInputSchema": true,
  291. "schemaType": "manual",
  292. "inputSchema": "{\n\"type\": \"object\",\n\"properties\": {\n\t\"filepath\": { \"type\": \"string\" }\n }\n}"
  293. },
  294. "id": "4daf5aca-46b2-44cd-b16f-31556a1725df",
  295. "name": "txt2html",
  296. "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
  297. "typeVersion": 1.2,
  298. "position": [
  299. 780,
  300. 280
  301. ]
  302. }
  303. ],
  304. "connections": {
  305. "When chat message received": {
  306. "main": [
  307. [
  308. {
  309. "node": "Has Files?",
  310. "type": "main",
  311. "index": 0
  312. }
  313. ]
  314. ]
  315. },
  316. "Set Fields": {
  317. "main": [
  318. [
  319. {
  320. "node": "AI Agent",
  321. "type": "main",
  322. "index": 0
  323. }
  324. ]
  325. ]
  326. },
  327. "Execute Workflow Trigger": {
  328. "main": [
  329. [
  330. {
  331. "node": "Read File",
  332. "type": "main",
  333. "index": 0
  334. }
  335. ]
  336. ]
  337. },
  338. "AI Agent": {
  339. "main": [
  340. []
  341. ]
  342. },
  343. "Has Files?": {
  344. "main": [
  345. [
  346. {
  347. "node": "Set Fields",
  348. "type": "main",
  349. "index": 0
  350. }
  351. ],
  352. [
  353. {
  354. "node": "Read/Write Files from Disk",
  355. "type": "main",
  356. "index": 0
  357. }
  358. ]
  359. ]
  360. },
  361. "Read File": {
  362. "main": [
  363. [
  364. {
  365. "node": "Convert to File",
  366. "type": "main",
  367. "index": 0
  368. }
  369. ],
  370. []
  371. ]
  372. },
  373. "Window Buffer Memory": {
  374. "ai_memory": [
  375. [
  376. {
  377. "node": "AI Agent",
  378. "type": "ai_memory",
  379. "index": 0
  380. }
  381. ]
  382. ]
  383. },
  384. "Read/Write Files from Disk": {
  385. "main": [
  386. [
  387. {
  388. "node": "Set Fields",
  389. "type": "main",
  390. "index": 0
  391. }
  392. ]
  393. ]
  394. },
  395. "OpenAI Chat Model": {
  396. "ai_languageModel": [
  397. [
  398. {
  399. "node": "AI Agent",
  400. "type": "ai_languageModel",
  401. "index": 0
  402. }
  403. ]
  404. ]
  405. },
  406. "Convert to File": {
  407. "main": [
  408. [
  409. {
  410. "node": "Read/Write Files from Disk1",
  411. "type": "main",
  412. "index": 0
  413. }
  414. ]
  415. ]
  416. },
  417. "Read/Write Files from Disk1": {
  418. "main": [
  419. [
  420. {
  421. "node": "Send Response1",
  422. "type": "main",
  423. "index": 0
  424. }
  425. ]
  426. ]
  427. },
  428. "txt2html": {
  429. "ai_tool": [
  430. [
  431. {
  432. "node": "AI Agent",
  433. "type": "ai_tool",
  434. "index": 0
  435. }
  436. ]
  437. ]
  438. }
  439. },
  440. "pinData": {
  441. "Execute Workflow Trigger": [
  442. {
  443. "query": {
  444. "filepath": "/home/node/temp/hello.txt"
  445. }
  446. }
  447. ]
  448. }
  449. }
Advertisement
Add Comment
Please, Sign In to add comment