-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemory-sessions-wit-Rj5LbJ7kvLB0teAF.json
1 lines (1 loc) · 15.3 KB
/
memory-sessions-wit-Rj5LbJ7kvLB0teAF.json
1
{"createdAt":"2024-12-27T16:30:26.244Z","updatedAt":"2024-12-27T16:30:26.244Z","id":"Rj5LbJ7kvLB0teAF","name":"Memory sessions wit","active":false,"nodes":[{"parameters":{"conditions":{"string":[{"value1":"={{ $json.message.text }}","value2":"/start"}]}},"id":"e33b8704-abfb-455d-a41a-41c438dc0d0f","name":"Check if start","type":"n8n-nodes-base.if","typeVersion":1,"position":[-480,1400]},{"parameters":{"chatId":"={{ $json.message.chat.id }}","text":"Choose memory:\n\n/m1 - memory 1\n/m2 - memory 2\n/m3 - memory 3","additionalFields":{}},"id":"a5ba3672-6f89-4f29-885e-408d48ffdfdf","name":"Choose memory [TELEGRAM]","type":"n8n-nodes-base.telegram","typeVersion":1,"position":[-240,1260]},{"parameters":{"conditions":{"string":[{"value1":"={{ $json.message.entities[0].type }}","value2":"bot_command"}]}},"id":"4f89542e-b1bf-4598-af69-8b26f135216c","name":"Check if command","type":"n8n-nodes-base.if","typeVersion":1,"position":[-240,1520]},{"parameters":{"operation":"get","propertyName":"currentMemory","key":"={{ $json.message.chat.id }}","options":{}},"id":"6b9791c5-aed4-4c3a-ac69-3eebeb7f7650","name":"Get current memory [REDIS]","type":"n8n-nodes-base.redis","typeVersion":1,"position":[-20,1980],"alwaysOutputData":false},{"parameters":{"updates":["message"],"additionalFields":{}},"id":"41050739-0d20-4d10-95a8-82dc2481e8b3","name":"Telegram trigger","type":"n8n-nodes-base.telegramTrigger","typeVersion":1,"position":[-680,1400],"webhookId":"e51e1f63-a0d4-4cfe-9577-2328ea808a22"},{"parameters":{"operation":"get","propertyName":"currentMemory","key":"={{ $('Telegram trigger').item.json.message.chat.id }}","options":{}},"id":"c5e70a20-4898-4b7f-a153-73a48ae95123","name":"Check current memory [REDIS]","type":"n8n-nodes-base.redis","typeVersion":1,"position":[520,570]},{"parameters":{"chatId":"={{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}","text":"=Current memory is {{ $json.currentMemory }}.","additionalFields":{}},"id":"f11b514b-1cb1-4c4d-a4aa-adf14fe27142","name":"Send memory info [TELEGRAM]","type":"n8n-nodes-base.telegram","typeVersion":1,"position":[720,570]},{"parameters":{"chatId":"={{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}","text":"Command not recognized.","additionalFields":{}},"id":"583b8a84-2dc1-4f06-9d20-51ebcc3b3227","name":"Command not recognized [TELEGRAM]","type":"n8n-nodes-base.telegram","typeVersion":1,"position":[520,1460]},{"parameters":{"conditions":{"string":[{"value1":"={{ $('Telegram trigger').item.json.message.text }}","value2":"/currentmemory"}]}},"id":"8fe9410a-a44c-4c4a-a3c3-fca38466b56c","name":"Check if current memory [TELEGRAM]","type":"n8n-nodes-base.if","typeVersion":1,"position":[0,1380]},{"parameters":{"conditions":{"string":[{"value1":"={{ $json.currentMemory }}","operation":"isEmpty"}]}},"id":"532c5bbf-dcf1-4d5a-a56d-799fa8a52204","name":"Check if record [REDIS]","type":"n8n-nodes-base.if","typeVersion":1,"position":[180,1980]},{"parameters":{"chatId":"={{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}","text":"The memory not set. Enter command /start to choose memory.","additionalFields":{}},"id":"8f063ea9-c432-4e63-b374-d32c94621d95","name":"Inform about empty record [TELEGRAM]","type":"n8n-nodes-base.telegram","typeVersion":1,"position":[440,1830]},{"parameters":{"method":"POST","url":"[URL_TO_YOUR_FLOWISE_CHATFLOW]","sendBody":true,"specifyBody":"json","jsonBody":"={\"question\": \"{{ $('Telegram trigger').item.json[\"message\"][\"text\"] }}\", \"overrideConfig\": {\"sessionId\": \"{{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}mslot1\" }}","options":{"response":{"response":{"responseFormat":"text"}}}},"id":"6c90549f-7eaa-4c5f-a5d1-8a09a3618db1","name":"Use M1 [FLOWISE/ZEP]","type":"n8n-nodes-base.httpRequest","typeVersion":4.1,"position":[720,2200]},{"parameters":{"method":"POST","url":"[URL_TO_YOUR_FLOWISE_CHATFLOW]","sendBody":true,"specifyBody":"json","jsonBody":"={\"question\": \"{{ $('Telegram trigger').item.json[\"message\"][\"text\"] }}\", \"overrideConfig\": {\"sessionId\": \"{{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}mslot2\" }}","options":{"response":{"response":{"responseFormat":"text"}}}},"id":"77e98656-b814-4164-b8df-dfec71d78fe4","name":"Use M2 [FLOWISE/ZEP]","type":"n8n-nodes-base.httpRequest","typeVersion":4.1,"position":[720,2380]},{"parameters":{"method":"POST","url":"[URL_TO_YOUR_FLOWISE_CHATFLOW]","sendBody":true,"specifyBody":"json","jsonBody":"={\"question\": \"{{ $('Telegram trigger').item.json[\"message\"][\"text\"] }}\", \"overrideConfig\": {\"sessionId\": \"{{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}mslot3\" }}","options":{"response":{"response":{"responseFormat":"text"}}}},"id":"cf95a1b2-80ef-4eaa-a693-6c283f67c8fa","name":"Use M3 [FLOWISE/ZEP]","type":"n8n-nodes-base.httpRequest","typeVersion":4.1,"position":[720,2560]},{"parameters":{"chatId":"={{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}","text":"={{ $json.data }}","additionalFields":{}},"id":"2874d999-d6e8-446c-93c7-3b779bb9e2a9","name":"Respond M1 [TELEGRAM]","type":"n8n-nodes-base.telegram","typeVersion":1,"position":[900,2200]},{"parameters":{"chatId":"={{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}","text":"={{ $json.data }}","additionalFields":{}},"id":"7c57af59-aac6-47bb-9aab-df9d4446c37e","name":"Respond M2 [TELEGRAM]","type":"n8n-nodes-base.telegram","typeVersion":1,"position":[900,2380]},{"parameters":{"chatId":"={{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}","text":"={{ $json.data }}","additionalFields":{}},"id":"a940c4e1-267c-4da6-8721-f9dc93181ac3","name":"Respond M3 [TELEGRAM]","type":"n8n-nodes-base.telegram","typeVersion":1,"position":[900,2560]},{"parameters":{"chatId":"={{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}","text":"An error occured. Please contact bot admin.","additionalFields":{}},"id":"532c9c2d-8c26-44eb-86ac-1099f918165e","name":"Send error [TELEGRAM]","type":"n8n-nodes-base.telegram","typeVersion":1,"position":[720,2780]},{"parameters":{"operation":"sendChatAction","chatId":"={{ $json.message.chat.id }}"},"id":"8fc6110d-9c8b-44ba-be79-3a9177672222","name":"Send typing action [TELEGRAM]","type":"n8n-nodes-base.telegram","typeVersion":1,"position":[-480,1600]},{"parameters":{"content":"## ⚠️ Note\n\n1. Complete video guide for this workflow is available [on my YouTube](https://www.youtube.com/watch?v=Dfbpt_i4-68). \n2. Remember to add your credentials and configure nodes (covered in the video guide).\n3. If you like this workflow, please subscribe to [my YouTube channel](https://www.youtube.com/@workfloows) and/or [my newsletter](https://workfloows.com/). I invite you also to buy my product [on Gumroad](https://workfloows.gumroad.com/).\n\n**Thank you for your support!**","height":267.3518783538228,"width":382.8182353336517},"id":"13ab273a-b7d0-4a70-83a2-23edb7c87216","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-720,980]},{"parameters":{"content":"## 🦜🔗 Flowise (LangChain)\n\n**This workflow requires installing [FlowiseAI](https://flowiseai.com/) and [Zep](https://www.getzep.com/) on your server.** \n\nInstallation guides and other data about FlowiseAI can be found [here](https://github.com/FlowiseAI/Flowise). Guides for installation of Zep are available in [official documentation](https://docs.getzep.com/deployment/).","height":266.6075757063218,"width":345.7880926620822},"id":"89f9599c-894d-4881-a904-cd5c9950f4e2","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-1080,980]},{"parameters":{"content":"## Trigger\nRemember to add credentials of your Telegram bot.","height":297.78936091241343,"width":182.4715262478496},"id":"e3339c70-6ba0-4ec0-a977-af6df1941905","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-720,1262]},{"parameters":{"content":"## Check if start\nThis node will check if user sends an initial ```/start``` message.","height":299.0166642010856,"width":182.4715262478496},"id":"8aa62638-90b1-4ead-8346-9e95a5c0c974","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-520,1261]},{"parameters":{"content":"## Initial response\nIn response to ```/start``` message, this node sends list of available memory sessions (M1, M2, M3 etc.).","height":400.882837160891,"width":182.4715262478496},"id":"db9f788d-fb94-4320-aa90-48adb58bf93a","name":"Sticky Note9","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-280,1058]},{"parameters":{"content":"## Check command\nNode checks if user sends command ```/currentmemory```.","height":345.2706568929251,"width":182.4715262478496},"id":"7917e2dc-a2b1-48d4-a4ad-31b8e0cebe8b","name":"Sticky Note10","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-40,1216]},{"parameters":{"content":"## Memory session info\nSequence gets current session from Redis database (```/m1```, ```/m2``` or ```/m3```) and returns information to the user.","height":295.4114607906109,"width":445.19113647927463},"id":"dfca2062-3143-4772-a94f-0c879fdafad4","name":"Sticky Note11","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[460,450]},{"parameters":{"content":"## Set memory session\nSequence sets/updates current session in Redis database according to input of the user (```/m1```, ```/m2``` or ```/m3```).","height":665.5201087808667,"width":445.19113647927463},"id":"d4c05426-8d8b-4965-8a5a-44adfb1cedd1","name":"Sticky Note12","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[460,760]},{"parameters":{"operation":"set","key":"={{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}","value":"/m1"},"id":"eb108951-e251-42be-aea2-a371d66a4ded","name":"Set memory session [REDIS] [1]","type":"n8n-nodes-base.redis","typeVersion":1,"position":[520,880]},{"parameters":{"operation":"set","key":"={{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}","value":"/m2"},"id":"afa16ab5-53ab-4332-a130-ec3de658d8cf","name":"Set memory session [REDIS] [2]","type":"n8n-nodes-base.redis","typeVersion":1,"position":[520,1060]},{"parameters":{"operation":"set","key":"={{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}","value":"/m3"},"id":"6e71ef24-94f9-4a35-9fd0-255ef92b01c9","name":"Set memory session [REDIS] [3]","type":"n8n-nodes-base.redis","typeVersion":1,"position":[520,1240]},{"parameters":{"dataType":"string","value1":"={{ $json.message.text }}","rules":{"rules":[{"value2":"/m1"},{"value2":"/m2","output":1},{"value2":"/m3","output":2}]},"fallbackOutput":3},"id":"d785536b-a231-4b18-8ce3-9735c375f397","name":"Switch memory sessions [TELEGRAM] [1]","type":"n8n-nodes-base.switch","typeVersion":1,"position":[240,1520]},{"parameters":{"dataType":"string","value1":"={{ $json.currentMemory }}","rules":{"rules":[{"value2":"/m1"},{"value2":"/m2","output":1},{"value2":"/m3","output":2}]},"fallbackOutput":3},"id":"f746fc43-9cf3-4e90-95d7-c34aa204b726","name":"Switch memory sessions [TELEGRAM] [2]","type":"n8n-nodes-base.switch","typeVersion":1,"position":[440,2140]},{"parameters":{"chatId":"={{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}","text":"The memory has been changed to M1.","additionalFields":{}},"id":"13a21bc1-f266-48ab-9379-f3bf5eb0b5bf","name":"Session confirmation [TELEGRAM] [1]","type":"n8n-nodes-base.telegram","typeVersion":1,"position":[720,880]},{"parameters":{"chatId":"={{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}","text":"The memory has been changed to M2.","additionalFields":{}},"id":"a466aae0-db9a-4b77-82f3-53615b05c438","name":"Session confirmation [TELEGRAM] [2]","type":"n8n-nodes-base.telegram","typeVersion":1,"position":[720,1060]},{"parameters":{"chatId":"={{ $('Telegram trigger').item.json[\"message\"][\"chat\"][\"id\"] }}","text":"The memory has been changed to M3.","additionalFields":{}},"id":"87965a1a-88e4-4cb5-bb10-7d9b7295a3d7","name":"Session confirmation [TELEGRAM] [3]","type":"n8n-nodes-base.telegram","typeVersion":1,"position":[720,1240]},{"parameters":{"content":"## Get memory session\nThe sequence gets memory session connected with chat ID from Redis database and checks if it is empty.","height":301.7070028125353,"width":405.1821718020519},"id":"896a1a21-9240-4a17-b03b-0eadd880c9e9","name":"Sticky Note13","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-60,1859]},{"parameters":{"content":"## Conversation\nAccording to current memory session (```/m1```, ```/m2``` or ```/m3```) the specific call to FlowiseAI is triggered. **Remember to replace placeholder ```[URL_TO_YOUR_FLOWISE_CHATFLOW]``` with your actual Flowise chatflow URL.** Feel free to modify format of ```sessionId``` parameter (I used combination of Telegram chat ID and suffix ```mslot1```, ```mslot2```, ```mslot3``` - your ID can look totally different depending on the use case).","height":756.3636654191122,"width":445.19113647927463},"id":"947b67c7-70a5-4291-8fd4-a6d7c2222803","name":"Sticky Note14","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[660,1992]}],"connections":{"Check if start":{"main":[[{"node":"Choose memory [TELEGRAM]","type":"main","index":0}],[{"node":"Check if command","type":"main","index":0}]]},"Check if command":{"main":[[{"node":"Check if current memory [TELEGRAM]","type":"main","index":0}],[{"node":"Get current memory [REDIS]","type":"main","index":0}]]},"Get current memory [REDIS]":{"main":[[{"node":"Check if record [REDIS]","type":"main","index":0}]]},"Telegram trigger":{"main":[[{"node":"Check if start","type":"main","index":0},{"node":"Send typing action [TELEGRAM]","type":"main","index":0}]]},"Check current memory [REDIS]":{"main":[[{"node":"Send memory info [TELEGRAM]","type":"main","index":0}]]},"Check if current memory [TELEGRAM]":{"main":[[{"node":"Check current memory [REDIS]","type":"main","index":0}],[{"node":"Switch memory sessions [TELEGRAM] [1]","type":"main","index":0}]]},"Check if record [REDIS]":{"main":[[{"node":"Inform about empty record [TELEGRAM]","type":"main","index":0}],[{"node":"Switch memory sessions [TELEGRAM] [2]","type":"main","index":0}]]},"Use M1 [FLOWISE/ZEP]":{"main":[[{"node":"Respond M1 [TELEGRAM]","type":"main","index":0}]]},"Use M2 [FLOWISE/ZEP]":{"main":[[{"node":"Respond M2 [TELEGRAM]","type":"main","index":0}]]},"Use M3 [FLOWISE/ZEP]":{"main":[[{"node":"Respond M3 [TELEGRAM]","type":"main","index":0}]]},"Set memory session [REDIS] [1]":{"main":[[{"node":"Session confirmation [TELEGRAM] [1]","type":"main","index":0}]]},"Set memory session [REDIS] [2]":{"main":[[{"node":"Session confirmation [TELEGRAM] [2]","type":"main","index":0}]]},"Set memory session [REDIS] [3]":{"main":[[{"node":"Session confirmation [TELEGRAM] [3]","type":"main","index":0}]]},"Switch memory sessions [TELEGRAM] [1]":{"main":[[{"node":"Set memory session [REDIS] [1]","type":"main","index":0}],[{"node":"Set memory session [REDIS] [2]","type":"main","index":0}],[{"node":"Set memory session [REDIS] [3]","type":"main","index":0}],[{"node":"Command not recognized [TELEGRAM]","type":"main","index":0}]]},"Switch memory sessions [TELEGRAM] [2]":{"main":[[{"node":"Use M1 [FLOWISE/ZEP]","type":"main","index":0}],[{"node":"Use M2 [FLOWISE/ZEP]","type":"main","index":0}],[{"node":"Use M3 [FLOWISE/ZEP]","type":"main","index":0}],[{"node":"Send error [TELEGRAM]","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":null,"versionId":"b4e59854-3a1f-4a1a-a529-8dab74ca14bf","triggerCount":0,"tags":[]}