Guest User

chat_hook

a guest
Dec 3rd, 2024
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.50 KB | None | 0 0
  1. {
  2. "nodes": [
  3. {
  4. "parameters": {
  5. "public": true,
  6. "initialMessages": "upload file",
  7. "options": {
  8. "allowFileUploads": true,
  9. "responseMode": "lastNode",
  10. "showWelcomeScreen": false
  11. }
  12. },
  13. "id": "efe737c4-eee0-4e66-9074-02722f9fd2ff",
  14. "name": "When chat message received",
  15. "type": "@n8n/n8n-nodes-langchain.chatTrigger",
  16. "typeVersion": 1.1,
  17. "position": [
  18. -340,
  19. 40
  20. ],
  21. "webhookId": "8ce80335-7615-4698-ae1b-650e7fea2431"
  22. },
  23. {
  24. "parameters": {
  25. "jsCode": "let results = [];\n\nfor (item of items) {\n for (key of Object.keys(item.binary)) {\n results.push({\n json: item.json.files.find(file => file.fileName === item.binary[key].fileName),\n binary: {\n data: item.binary[key],\n }\n });\n }\n}\n\nreturn results;"
  26. },
  27. "id": "974097b1-6144-4bbd-b471-01acab1b16f4",
  28. "name": "Files To List",
  29. "type": "n8n-nodes-base.code",
  30. "typeVersion": 2,
  31. "position": [
  32. 0,
  33. 240
  34. ]
  35. },
  36. {
  37. "parameters": {
  38. "assignments": {
  39. "assignments": [
  40. {
  41. "id": "11a4b1e5-2065-4bfd-ba7c-12def5c65116",
  42. "name": "sessionId",
  43. "value": "={{ $('Webhook').first().body.json.body?.sessionId || $('When chat message received').first().json.sessionId }}",
  44. "type": "string"
  45. },
  46. {
  47. "id": "43953933-fc55-46c0-8376-cfc357789dbb",
  48. "name": "action",
  49. "value": "={{ $('Webhook').first().body.json.body?.action || $('When chat message received').first().json.action }}",
  50. "type": "string"
  51. },
  52. {
  53. "id": "735ec242-faf2-4bf4-9db4-a43fbf8af206",
  54. "name": "chatInput",
  55. "value": "={{ $('Webhook').first().body.json.body?.chatInput || $('When chat message received').first().json.chatInput }}",
  56. "type": "string"
  57. },
  58. {
  59. "id": "dc70d10f-fecf-413a-87e6-008341f2fcb1",
  60. "name": "files",
  61. "value": "={{ $json.body?.files || $json.files }}",
  62. "type": "string"
  63. }
  64. ]
  65. },
  66. "options": {}
  67. },
  68. "id": "9fcd6842-91ae-4966-9ba7-f217cedf4258",
  69. "name": "Set Fields",
  70. "type": "n8n-nodes-base.set",
  71. "typeVersion": 3.4,
  72. "position": [
  73. 500,
  74. 60
  75. ]
  76. },
  77. {
  78. "parameters": {
  79. "options": {
  80. "baseURL": "https://oneapi.6868ai.com/v1"
  81. }
  82. },
  83. "id": "6b76891c-9586-436d-8206-03a25b8512df",
  84. "name": "OpenAI Chat Model",
  85. "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
  86. "typeVersion": 1,
  87. "position": [
  88. 740,
  89. 240
  90. ],
  91. "credentials": {
  92. "openAiApi": {
  93. "id": "oYt1X4B1EySK0Ho4",
  94. "name": "OpenAi account"
  95. }
  96. }
  97. },
  98. {
  99. "parameters": {},
  100. "id": "a852cd17-3c4c-40e9-88ae-dbdf49002dde",
  101. "name": "Execute Workflow Trigger",
  102. "type": "n8n-nodes-base.executeWorkflowTrigger",
  103. "typeVersion": 1,
  104. "position": [
  105. 420,
  106. 800
  107. ]
  108. },
  109. {
  110. "parameters": {
  111. "assignments": {
  112. "assignments": [
  113. {
  114. "id": "5771fb42-e4a9-44d7-8946-6bca673480c3",
  115. "name": "response",
  116. "value": "Unknown command. Try a different route.",
  117. "type": "string"
  118. }
  119. ]
  120. },
  121. "options": {}
  122. },
  123. "id": "871bdef7-ef10-4edb-bbae-080115e7a3c9",
  124. "name": "Unknown Route",
  125. "type": "n8n-nodes-base.set",
  126. "typeVersion": 3.4,
  127. "position": [
  128. 960,
  129. 1160
  130. ]
  131. },
  132. {
  133. "parameters": {
  134. "options": {
  135. "baseURL": "https://oneapi.6868ai.com/v1"
  136. }
  137. },
  138. "id": "5b8df1e1-992d-4ea6-848d-036f6649f6de",
  139. "name": "OpenAI Chat Model1",
  140. "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
  141. "typeVersion": 1,
  142. "position": [
  143. 1560,
  144. 480
  145. ],
  146. "credentials": {
  147. "openAiApi": {
  148. "id": "oYt1X4B1EySK0Ho4",
  149. "name": "OpenAi account"
  150. }
  151. }
  152. },
  153. {
  154. "parameters": {
  155. "operation": "pdf",
  156. "options": {}
  157. },
  158. "id": "7bf4532e-c36f-47b1-9961-08e13a3c3d93",
  159. "name": "Extract from File",
  160. "type": "n8n-nodes-base.extractFromFile",
  161. "typeVersion": 1,
  162. "position": [
  163. 1360,
  164. 340
  165. ]
  166. },
  167. {
  168. "parameters": {
  169. "rules": {
  170. "values": [
  171. {
  172. "conditions": {
  173. "options": {
  174. "caseSensitive": true,
  175. "leftValue": "",
  176. "typeValidation": "strict",
  177. "version": 2
  178. },
  179. "conditions": [
  180. {
  181. "leftValue": "={{ $json.fileType }}",
  182. "rightValue": "pdf",
  183. "operator": {
  184. "type": "string",
  185. "operation": "equals"
  186. }
  187. }
  188. ],
  189. "combinator": "and"
  190. },
  191. "renameOutput": true,
  192. "outputKey": "pdf"
  193. },
  194. {
  195. "conditions": {
  196. "options": {
  197. "caseSensitive": true,
  198. "leftValue": "",
  199. "typeValidation": "strict",
  200. "version": 2
  201. },
  202. "conditions": [
  203. {
  204. "id": "c0432ab1-1b11-4b47-a135-099be7fde656",
  205. "leftValue": "={{ [\"jpg\",\"jpeg\",\"png\",\"gif\"] }}",
  206. "rightValue": "={{ $json.fileType.toLowerCase() }}",
  207. "operator": {
  208. "type": "array",
  209. "operation": "contains",
  210. "rightType": "any"
  211. }
  212. }
  213. ],
  214. "combinator": "and"
  215. },
  216. "renameOutput": true,
  217. "outputKey": "image"
  218. }
  219. ]
  220. },
  221. "options": {}
  222. },
  223. "id": "b6e84b4b-c09c-46b9-a34e-410e9bef63a5",
  224. "name": "Handle FileType",
  225. "type": "n8n-nodes-base.switch",
  226. "typeVersion": 3.2,
  227. "position": [
  228. 1140,
  229. 480
  230. ]
  231. },
  232. {
  233. "parameters": {
  234. "options": {
  235. "baseURL": "https://oneapi.6868ai.com/v1"
  236. }
  237. },
  238. "id": "cbbe9df9-f535-45f9-9afc-fc03656b9693",
  239. "name": "OpenAI Chat Model2",
  240. "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
  241. "typeVersion": 1,
  242. "position": [
  243. 1380,
  244. 800
  245. ],
  246. "credentials": {
  247. "openAiApi": {
  248. "id": "oYt1X4B1EySK0Ho4",
  249. "name": "OpenAi account"
  250. }
  251. }
  252. },
  253. {
  254. "parameters": {
  255. "assignments": {
  256. "assignments": [
  257. {
  258. "id": "f1f677cd-31be-4383-adcf-f01eb83899d7",
  259. "name": "response",
  260. "value": "={{ $json.text }}",
  261. "type": "string"
  262. }
  263. ]
  264. },
  265. "options": {}
  266. },
  267. "id": "d79f3336-b51e-4bb2-b4ef-5ac13575e337",
  268. "name": "Send Response",
  269. "type": "n8n-nodes-base.set",
  270. "typeVersion": 3.4,
  271. "position": [
  272. 1680,
  273. 620
  274. ]
  275. },
  276. {
  277. "parameters": {
  278. "promptType": "define",
  279. "text": "={{ $('Execute Workflow Trigger').first().json.query.question }}",
  280. "messages": {
  281. "messageValues": [
  282. {
  283. "message": "Answer the user's question using the contents of the pdf provided."
  284. },
  285. {
  286. "type": "HumanMessagePromptTemplate",
  287. "message": "=This is the content of the pdf:\n{{ $json.text }}"
  288. }
  289. ]
  290. }
  291. },
  292. "id": "4a45d490-385a-4623-97dd-25a4267b1715",
  293. "name": "Answer from PDF Contents",
  294. "type": "@n8n/n8n-nodes-langchain.chainLlm",
  295. "typeVersion": 1.5,
  296. "position": [
  297. 1520,
  298. 340
  299. ]
  300. },
  301. {
  302. "parameters": {
  303. "assignments": {
  304. "assignments": [
  305. {
  306. "id": "f1f677cd-31be-4383-adcf-f01eb83899d7",
  307. "name": "response",
  308. "value": "={{ $json.text }}",
  309. "type": "string"
  310. }
  311. ]
  312. },
  313. "options": {}
  314. },
  315. "id": "5712e906-18ab-4f87-916d-d772bf3e81e5",
  316. "name": "Send Response1",
  317. "type": "n8n-nodes-base.set",
  318. "typeVersion": 3.4,
  319. "position": [
  320. 1840,
  321. 340
  322. ]
  323. },
  324. {
  325. "parameters": {
  326. "promptType": "define",
  327. "text": "={{ $json.chatInput }}\n{{\n$json.files\n ? `Here are the file locations:\n ${$json.files.map(file => file.fileName).join('\\n')}\n `\n : ''\n}}",
  328. "options": {
  329. "systemMessage": "Answer the user's question.\n\nAll files given by the user are stored in a directory. Use the tool to query the files where relevant."
  330. }
  331. },
  332. "id": "6c0b80a3-2541-456f-ae81-4f94255acc20",
  333. "name": "AI Agent",
  334. "type": "@n8n/n8n-nodes-langchain.agent",
  335. "typeVersion": 1.7,
  336. "position": [
  337. 740,
  338. 60
  339. ]
  340. },
  341. {
  342. "parameters": {
  343. "assignments": {
  344. "assignments": [
  345. {
  346. "id": "f1f677cd-31be-4383-adcf-f01eb83899d7",
  347. "name": "response",
  348. "value": "={{ $json.stdout }}",
  349. "type": "string"
  350. }
  351. ]
  352. },
  353. "options": {}
  354. },
  355. "id": "4847c2ee-1d07-478d-a4c6-1005c381aab5",
  356. "name": "Send Response2",
  357. "type": "n8n-nodes-base.set",
  358. "typeVersion": 3.4,
  359. "position": [
  360. 1140,
  361. 940
  362. ]
  363. },
  364. {
  365. "parameters": {
  366. "name": "read_file_from_directory",
  367. "description": "Call this tool to query the contents of a file saved in the directory. Please note that only the answer will be returned and not the file.",
  368. "workflowId": {
  369. "__rl": true,
  370. "value": "={{ $workflow.id }}",
  371. "mode": "id"
  372. },
  373. "fields": {
  374. "values": [
  375. {
  376. "name": "route",
  377. "stringValue": "read_file"
  378. }
  379. ]
  380. },
  381. "specifyInputSchema": true,
  382. "schemaType": "manual",
  383. "inputSchema": "{\n\"type\": \"object\",\n\"properties\": {\n \"question\": {\n \"type\": \"string\",\n \"description\": \"ensure this is a fully formed question\"\n },\n\t\"filepath\": { \"type\": \"string\" }\n }\n}"
  384. },
  385. "id": "70c0cd4f-ed1f-4f6f-938a-ed7e3dbd643f",
  386. "name": "Read File Tool",
  387. "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
  388. "typeVersion": 1.2,
  389. "position": [
  390. 1020,
  391. 240
  392. ]
  393. },
  394. {
  395. "parameters": {
  396. "name": "search_directory",
  397. "description": "Call this tool to search over the directory listing.",
  398. "workflowId": {
  399. "__rl": true,
  400. "value": "={{ $workflow.id }}",
  401. "mode": "id"
  402. },
  403. "fields": {
  404. "values": [
  405. {
  406. "name": "route",
  407. "stringValue": "search_file"
  408. }
  409. ]
  410. },
  411. "specifyInputSchema": true,
  412. "jsonSchemaExample": "{\n\t\"search_terms\": \"some_value\"\n}"
  413. },
  414. "id": "5b922642-c5ef-427a-96ef-fd5b4a365032",
  415. "name": "Search File Tool",
  416. "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
  417. "typeVersion": 1.2,
  418. "position": [
  419. 1160,
  420. 240
  421. ]
  422. },
  423. {
  424. "parameters": {
  425. "rules": {
  426. "values": [
  427. {
  428. "conditions": {
  429. "options": {
  430. "caseSensitive": true,
  431. "leftValue": "",
  432. "typeValidation": "strict",
  433. "version": 2
  434. },
  435. "conditions": [
  436. {
  437. "leftValue": "={{ $json.body?.files || $json.files }}",
  438. "rightValue": "",
  439. "operator": {
  440. "type": "array",
  441. "operation": "notExists",
  442. "singleValue": true
  443. }
  444. }
  445. ],
  446. "combinator": "and"
  447. },
  448. "renameOutput": true,
  449. "outputKey": "without files"
  450. },
  451. {
  452. "conditions": {
  453. "options": {
  454. "caseSensitive": true,
  455. "leftValue": "",
  456. "typeValidation": "strict",
  457. "version": 2
  458. },
  459. "conditions": [
  460. {
  461. "id": "0d67ec0a-1d61-4f6a-97e5-965b0d340ae4",
  462. "leftValue": "={{ $json.body?.files || $json.files }}",
  463. "rightValue": "",
  464. "operator": {
  465. "type": "array",
  466. "operation": "exists",
  467. "singleValue": true
  468. }
  469. }
  470. ],
  471. "combinator": "and"
  472. },
  473. "renameOutput": true,
  474. "outputKey": "with files"
  475. }
  476. ]
  477. },
  478. "options": {}
  479. },
  480. "id": "bebf197f-4f8d-4658-a5b0-320fac3ce179",
  481. "name": "Has Files?",
  482. "type": "n8n-nodes-base.switch",
  483. "typeVersion": 3.2,
  484. "position": [
  485. -180,
  486. 40
  487. ]
  488. },
  489. {
  490. "parameters": {
  491. "rules": {
  492. "values": [
  493. {
  494. "conditions": {
  495. "options": {
  496. "caseSensitive": true,
  497. "leftValue": "",
  498. "typeValidation": "strict",
  499. "version": 2
  500. },
  501. "conditions": [
  502. {
  503. "leftValue": "={{ $json.route }}",
  504. "rightValue": "read_file",
  505. "operator": {
  506. "type": "string",
  507. "operation": "equals"
  508. }
  509. }
  510. ],
  511. "combinator": "and"
  512. },
  513. "renameOutput": true,
  514. "outputKey": "Read File from Directory"
  515. },
  516. {
  517. "conditions": {
  518. "options": {
  519. "caseSensitive": true,
  520. "leftValue": "",
  521. "typeValidation": "strict",
  522. "version": 2
  523. },
  524. "conditions": [
  525. {
  526. "id": "2d2b7d5d-ac9b-492c-b85f-db423dce1545",
  527. "leftValue": "={{ $json.route }}",
  528. "rightValue": "search_file",
  529. "operator": {
  530. "type": "string",
  531. "operation": "equals",
  532. "name": "filter.operator.equals"
  533. }
  534. }
  535. ],
  536. "combinator": "and"
  537. },
  538. "renameOutput": true,
  539. "outputKey": "search_file"
  540. }
  541. ]
  542. },
  543. "options": {
  544. "fallbackOutput": "extra"
  545. }
  546. },
  547. "id": "62bd45ce-65ad-4471-9c3d-1bdf48ce593e",
  548. "name": "Handle Route",
  549. "type": "n8n-nodes-base.switch",
  550. "typeVersion": 3.2,
  551. "position": [
  552. 600,
  553. 800
  554. ]
  555. },
  556. {
  557. "parameters": {
  558. "content": "### 2. Split Files Array into Separate Items\nOnly way to split is to use the code node. This allows us to action each file separately.",
  559. "height": 97.49999999999994,
  560. "width": 333.74999999999994,
  561. "color": 7
  562. },
  563. "id": "aee16613-862d-4c3c-b2a1-d8162bed77f7",
  564. "name": "Sticky Note",
  565. "type": "n8n-nodes-base.stickyNote",
  566. "typeVersion": 1,
  567. "position": [
  568. -240,
  569. 400
  570. ]
  571. },
  572. {
  573. "parameters": {
  574. "aggregate": "aggregateAllItemData",
  575. "destinationFieldName": "files",
  576. "options": {}
  577. },
  578. "id": "cbdcb5af-7b97-4d17-b40e-e96cfeac8cba",
  579. "name": "Combine",
  580. "type": "n8n-nodes-base.aggregate",
  581. "typeVersion": 1,
  582. "position": [
  583. 320,
  584. 240
  585. ]
  586. },
  587. {
  588. "parameters": {
  589. "content": "### 3. Combine file paths using Aggregate node\nWhen returning the filepaths to the agent, we don't want them as separate items but rather just a single list to inject into the prompt.",
  590. "height": 106.24999999999991,
  591. "width": 363.74999999999994,
  592. "color": 7
  593. },
  594. "id": "d26fdc68-b5c0-4e5d-8255-fc37ad172d10",
  595. "name": "Sticky Note1",
  596. "type": "n8n-nodes-base.stickyNote",
  597. "typeVersion": 1,
  598. "position": [
  599. 320,
  600. 400
  601. ]
  602. },
  603. {
  604. "parameters": {
  605. "content": "### 1. Detect if files are included\nJust check the message before it hits the agent. You can put any number of other nodes in-between the chat trigger and AI agent.",
  606. "height": 113.74999999999994,
  607. "width": 333.74999999999994,
  608. "color": 7
  609. },
  610. "id": "a92dc4de-0a63-430f-8fb4-266b370e5d82",
  611. "name": "Sticky Note2",
  612. "type": "n8n-nodes-base.stickyNote",
  613. "typeVersion": 1,
  614. "position": [
  615. -120,
  616. -120
  617. ]
  618. },
  619. {
  620. "parameters": {
  621. "content": "### 4. Use tools to interact with the files saved to disk\nCustom workflow tools are preferred method here.",
  622. "height": 107.99999999999997,
  623. "width": 234.00000000000006,
  624. "color": 7
  625. },
  626. "id": "b1208271-9c55-45ea-87e4-666739fa4518",
  627. "name": "Sticky Note3",
  628. "type": "n8n-nodes-base.stickyNote",
  629. "typeVersion": 1,
  630. "position": [
  631. 800,
  632. -100
  633. ]
  634. },
  635. {
  636. "parameters": {
  637. "content": "### 5. This is an example of the subworkflow router pattern\nIt lets you have multiple subworkflow tools in one template.",
  638. "height": 115,
  639. "width": 277.00000000000006,
  640. "color": 7
  641. },
  642. "id": "c9314a75-9521-4ec8-aacd-66c9a4f45b23",
  643. "name": "Sticky Note4",
  644. "type": "n8n-nodes-base.stickyNote",
  645. "typeVersion": 1,
  646. "position": [
  647. 420,
  648. 640
  649. ]
  650. },
  651. {
  652. "parameters": {
  653. "content": "### 6. Extract contents from PDF\nTo read PDFs, you'll need to use the \"Extract from File\" node to get the text. Once extracted, provide it to the prompt as context.",
  654. "height": 115,
  655. "width": 338.00000000000006,
  656. "color": 7
  657. },
  658. "id": "098bbf38-52d6-43af-ae3f-c72ac371ccff",
  659. "name": "Sticky Note5",
  660. "type": "n8n-nodes-base.stickyNote",
  661. "typeVersion": 1,
  662. "position": [
  663. 1360,
  664. 200
  665. ]
  666. },
  667. {
  668. "parameters": {
  669. "fileSelector": "={{ $json.query.filepath }}",
  670. "options": {}
  671. },
  672. "id": "7f3d6bea-0337-421f-856a-bc7b3fcf23e1",
  673. "name": "Read File",
  674. "type": "n8n-nodes-base.readWriteFile",
  675. "typeVersion": 1,
  676. "position": [
  677. 960,
  678. 600
  679. ],
  680. "onError": "continueErrorOutput"
  681. },
  682. {
  683. "parameters": {
  684. "content": "### 7. Extract contents from Images\nTo read images, typically the AI can read this for you without prior conversion steps. Use the binary message type for user to achieve this with n8n.",
  685. "height": 112,
  686. "width": 356.0000000000001,
  687. "color": 7
  688. },
  689. "id": "b5d8e1b6-7d69-466d-aa85-4e58f58d75e5",
  690. "name": "Sticky Note6",
  691. "type": "n8n-nodes-base.stickyNote",
  692. "typeVersion": 1,
  693. "position": [
  694. 1500,
  695. 800
  696. ]
  697. },
  698. {
  699. "parameters": {
  700. "content": "### A note on Tool Design\nIdeally, you want the tool to return only the data you're looking for. Here the read file tool passes in a question alongside the filepath - this avoids the need to return the full file contents.",
  701. "height": 134,
  702. "width": 349
  703. },
  704. "id": "2c1f7b02-a7a0-4038-8ee8-4e262a4fb32e",
  705. "name": "Sticky Note7",
  706. "type": "n8n-nodes-base.stickyNote",
  707. "typeVersion": 1,
  708. "position": [
  709. 1040,
  710. -120
  711. ]
  712. },
  713. {
  714. "parameters": {},
  715. "id": "7d3edac0-6336-495f-ae2c-02744dccb414",
  716. "name": "Window Buffer Memory",
  717. "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
  718. "typeVersion": 1.3,
  719. "position": [
  720. 860,
  721. 240
  722. ]
  723. },
  724. {
  725. "parameters": {
  726. "promptType": "define",
  727. "text": "={{ $('Execute Workflow Trigger').first().json.query.question }}",
  728. "messages": {
  729. "messageValues": [
  730. {
  731. "message": "Answer the user's question using the contents of the image provided."
  732. },
  733. {
  734. "type": "HumanMessagePromptTemplate",
  735. "messageType": "imageBinary"
  736. }
  737. ]
  738. }
  739. },
  740. "id": "c0572521-faeb-4d98-8544-86f0d26dd283",
  741. "name": "Answer from Image Contents",
  742. "type": "@n8n/n8n-nodes-langchain.chainLlm",
  743. "typeVersion": 1.5,
  744. "position": [
  745. 1360,
  746. 620
  747. ]
  748. },
  749. {
  750. "parameters": {
  751. "assignments": {
  752. "assignments": [
  753. {
  754. "id": "5f95ad92-2eab-44ec-9bd9-d5170e6607bc",
  755. "name": "response",
  756. "value": "File not found. Be sure to prepend the full path `/home/node/temp/...`",
  757. "type": "string"
  758. }
  759. ]
  760. },
  761. "options": {}
  762. },
  763. "id": "0b1026db-7ca5-44a8-a04c-9a50033aa343",
  764. "name": "Not Found Response",
  765. "type": "n8n-nodes-base.set",
  766. "typeVersion": 3.4,
  767. "position": [
  768. 1140,
  769. 720
  770. ]
  771. },
  772. {
  773. "parameters": {
  774. "command": "=ls /home/node/temp | grep '{{ $json.query.search_terms.split(' ').join('\\\\|') }}'"
  775. },
  776. "id": "458cefb0-9451-4dcf-b092-b850618ea4d7",
  777. "name": "Search Directory",
  778. "type": "n8n-nodes-base.executeCommand",
  779. "typeVersion": 1,
  780. "position": [
  781. 960,
  782. 940
  783. ]
  784. },
  785. {
  786. "parameters": {
  787. "operation": "write",
  788. "fileName": "={{ `/home/node/temp/${$json.fileName}` }}",
  789. "options": {}
  790. },
  791. "id": "37d30ad9-72f1-4d2b-9301-91afe96a5801",
  792. "name": "Read/Write Files from Disk",
  793. "type": "n8n-nodes-base.readWriteFile",
  794. "typeVersion": 1,
  795. "position": [
  796. 160,
  797. 240
  798. ]
  799. },
  800. {
  801. "parameters": {
  802. "operation": "write",
  803. "fileName": "={{ `C:\\\\home\\\\node\\\\temp\\\\${$json.fileName}` }}",
  804. "options": {}
  805. },
  806. "id": "415cbac3-6ef0-4a3b-abb9-a54dc5e26063",
  807. "name": "Read/Write Files from Disk1",
  808. "type": "n8n-nodes-base.readWriteFile",
  809. "typeVersion": 1,
  810. "position": [
  811. 160,
  812. 460
  813. ]
  814. },
  815. {
  816. "parameters": {
  817. "httpMethod": "POST",
  818. "path": "test",
  819. "responseMode": "responseNode",
  820. "options": {}
  821. },
  822. "type": "n8n-nodes-base.webhook",
  823. "typeVersion": 2,
  824. "position": [
  825. -340,
  826. -100
  827. ],
  828. "id": "8c32e3fb-34fe-4151-9348-3599811bc963",
  829. "name": "Webhook",
  830. "webhookId": "a26f8763-f327-4a26-a1f0-988163540111"
  831. },
  832. {
  833. "parameters": {
  834. "options": {}
  835. },
  836. "type": "n8n-nodes-base.respondToWebhook",
  837. "typeVersion": 1.1,
  838. "position": [
  839. 1160,
  840. 60
  841. ],
  842. "id": "15722c2d-f1c2-4993-9b7e-8080494ccc85",
  843. "name": "Respond to Webhook"
  844. }
  845. ],
  846. "connections": {
  847. "When chat message received": {
  848. "main": [
  849. [
  850. {
  851. "node": "Has Files?",
  852. "type": "main",
  853. "index": 0
  854. }
  855. ]
  856. ]
  857. },
  858. "Files To List": {
  859. "main": [
  860. [
  861. {
  862. "node": "Read/Write Files from Disk",
  863. "type": "main",
  864. "index": 0
  865. }
  866. ]
  867. ]
  868. },
  869. "Set Fields": {
  870. "main": [
  871. [
  872. {
  873. "node": "AI Agent",
  874. "type": "main",
  875. "index": 0
  876. }
  877. ]
  878. ]
  879. },
  880. "OpenAI Chat Model": {
  881. "ai_languageModel": [
  882. [
  883. {
  884. "node": "AI Agent",
  885. "type": "ai_languageModel",
  886. "index": 0
  887. }
  888. ]
  889. ]
  890. },
  891. "Execute Workflow Trigger": {
  892. "main": [
  893. [
  894. {
  895. "node": "Handle Route",
  896. "type": "main",
  897. "index": 0
  898. }
  899. ]
  900. ]
  901. },
  902. "OpenAI Chat Model1": {
  903. "ai_languageModel": [
  904. [
  905. {
  906. "node": "Answer from PDF Contents",
  907. "type": "ai_languageModel",
  908. "index": 0
  909. }
  910. ]
  911. ]
  912. },
  913. "Extract from File": {
  914. "main": [
  915. [
  916. {
  917. "node": "Answer from PDF Contents",
  918. "type": "main",
  919. "index": 0
  920. }
  921. ]
  922. ]
  923. },
  924. "Handle FileType": {
  925. "main": [
  926. [
  927. {
  928. "node": "Extract from File",
  929. "type": "main",
  930. "index": 0
  931. }
  932. ],
  933. [
  934. {
  935. "node": "Answer from Image Contents",
  936. "type": "main",
  937. "index": 0
  938. }
  939. ]
  940. ]
  941. },
  942. "OpenAI Chat Model2": {
  943. "ai_languageModel": [
  944. [
  945. {
  946. "node": "Answer from Image Contents",
  947. "type": "ai_languageModel",
  948. "index": 0
  949. }
  950. ]
  951. ]
  952. },
  953. "Answer from PDF Contents": {
  954. "main": [
  955. [
  956. {
  957. "node": "Send Response1",
  958. "type": "main",
  959. "index": 0
  960. }
  961. ]
  962. ]
  963. },
  964. "AI Agent": {
  965. "main": [
  966. [
  967. {
  968. "node": "Respond to Webhook",
  969. "type": "main",
  970. "index": 0
  971. }
  972. ]
  973. ]
  974. },
  975. "Read File Tool": {
  976. "ai_tool": [
  977. [
  978. {
  979. "node": "AI Agent",
  980. "type": "ai_tool",
  981. "index": 0
  982. }
  983. ]
  984. ]
  985. },
  986. "Search File Tool": {
  987. "ai_tool": [
  988. [
  989. {
  990. "node": "AI Agent",
  991. "type": "ai_tool",
  992. "index": 0
  993. }
  994. ]
  995. ]
  996. },
  997. "Has Files?": {
  998. "main": [
  999. [
  1000. {
  1001. "node": "Set Fields",
  1002. "type": "main",
  1003. "index": 0
  1004. }
  1005. ],
  1006. [
  1007. {
  1008. "node": "Files To List",
  1009. "type": "main",
  1010. "index": 0
  1011. }
  1012. ]
  1013. ]
  1014. },
  1015. "Handle Route": {
  1016. "main": [
  1017. [
  1018. {
  1019. "node": "Read File",
  1020. "type": "main",
  1021. "index": 0
  1022. }
  1023. ],
  1024. [
  1025. {
  1026. "node": "Search Directory",
  1027. "type": "main",
  1028. "index": 0
  1029. }
  1030. ],
  1031. [
  1032. {
  1033. "node": "Unknown Route",
  1034. "type": "main",
  1035. "index": 0
  1036. }
  1037. ]
  1038. ]
  1039. },
  1040. "Combine": {
  1041. "main": [
  1042. [
  1043. {
  1044. "node": "Set Fields",
  1045. "type": "main",
  1046. "index": 0
  1047. }
  1048. ]
  1049. ]
  1050. },
  1051. "Read File": {
  1052. "main": [
  1053. [
  1054. {
  1055. "node": "Handle FileType",
  1056. "type": "main",
  1057. "index": 0
  1058. }
  1059. ],
  1060. [
  1061. {
  1062. "node": "Not Found Response",
  1063. "type": "main",
  1064. "index": 0
  1065. }
  1066. ]
  1067. ]
  1068. },
  1069. "Window Buffer Memory": {
  1070. "ai_memory": [
  1071. [
  1072. {
  1073. "node": "AI Agent",
  1074. "type": "ai_memory",
  1075. "index": 0
  1076. }
  1077. ]
  1078. ]
  1079. },
  1080. "Answer from Image Contents": {
  1081. "main": [
  1082. [
  1083. {
  1084. "node": "Send Response",
  1085. "type": "main",
  1086. "index": 0
  1087. }
  1088. ]
  1089. ]
  1090. },
  1091. "Search Directory": {
  1092. "main": [
  1093. [
  1094. {
  1095. "node": "Send Response2",
  1096. "type": "main",
  1097. "index": 0
  1098. }
  1099. ]
  1100. ]
  1101. },
  1102. "Read/Write Files from Disk": {
  1103. "main": [
  1104. [
  1105. {
  1106. "node": "Combine",
  1107. "type": "main",
  1108. "index": 0
  1109. }
  1110. ]
  1111. ]
  1112. },
  1113. "Read/Write Files from Disk1": {
  1114. "main": [
  1115. []
  1116. ]
  1117. },
  1118. "Webhook": {
  1119. "main": [
  1120. [
  1121. {
  1122. "node": "Has Files?",
  1123. "type": "main",
  1124. "index": 0
  1125. }
  1126. ]
  1127. ]
  1128. }
  1129. },
  1130. "pinData": {}
  1131. }
Advertisement
Add Comment
Please, Sign In to add comment