Adding memory sessions to Telegram AI bot with FlowiseAI and Zep

2024 ж. 14 Мам.
4 387 Рет қаралды

In this tutorial I explain how to add external memory to the Telegram AI bot using FlowiseAI and Zep. With memory sessions you’re able to run multiple conversations with the same FlowiseAI chatflow and keep separate conversation histories.
Download the Telegram AI bot memory sessions workflow for n8n here: github.com/workfloows/workflo...
🤖 Other tutorials about building Telegram AI bot:
1. How to build Telegram AI bot with n8n and 🦜🔗 LangChain (FlowiseAI): • How to build Telegram ...
2. How to build voice Telegram AI bot with n8n, Whisper and ElevenLabs: workfloows.gumroad.com/l/tele...
In this tutorial I cover:
1. Installing Zep on VPS
2. Adjusting FlowiseAI chatflow to use Zep memory
3. Setting firewall rules to avoid connection errors with Zep
4. Using „sessionId” parameter of Zep memory in n8n
5. Advantages of using Redis as database for Telegram bots
Resources:
1. Deploying Zep using docker-compose: docs.getzep.com/deployment/qu...
2. Commands to add firewall rules: pastebin.com/raEwtqgq
3. Redis Cloud: redis.com/redis-enterprise-cl...
My other tutorials:
1. Web scraping data with n8n and Puppeteer: • Web scraping data with...
2. Generate PDFs in n8n with Gotenberg (for free!): • Generate PDFs in n8n w...
3. How to auto-backup n8n workflows to GitHub: • How to auto-backup n8n...
4. Using webhooks in n8n (parameters, responses and triggers): • Using webhooks in n8n ...
Create your n8n cloud account here (affiliate): app.n8n.cloud/register?ref=wo...
Subscribe my newsletter: workfloows.com/
Visit my Gumroad profile: workfloows.gumroad.com/
Follow me on Twitter/X: / workfloows
Follow Workfloows on LinkedIn: / workfloows
Screen recording software that I use (affiliate): www.screen.studio/@jmMwX
0:00 Demo (memory sessions in Telegram)
1:48 Step 1: Install Zep
2:56 Step 2: Configure FlowiseAI chatflow
4:37 Step 3: Configure firewall rules
5:30 Step 4: Test memory sessions
8:08 Step 5: Add Telegram credentials
8:49 Step 6: Add Redis credentials
11:07 Database speed comparison
12:25 Step 7: Configure n8n workflow
17:34 Final result
18:32 Build voice chatbot

Пікірлер
  • It's wonderful to find great Flowise content.

    @one810@one8109 ай бұрын
    • I’m glad you like it, thank you very much for your comment!

      @workfloows@workfloows9 ай бұрын
  • Very cool!

    @alexanderroodt5052@alexanderroodt50529 ай бұрын
    • Thank you very much!

      @workfloows@workfloows9 ай бұрын
  • Hey Oskar great video! Would you be able to make a video on coolify deploying multiple projects to work together like zep/flowise/n8n/etc? It's like an open source heroku/netlify alternative but makes deploying/managing docker containers easy on something like hetzner. Just stumbled across it yesterday.

    @figs3284@figs32849 ай бұрын
    • Hello, thanks for your comment! Usually, I use Digital Ocean for my projects and to be honest, I’m not that much familiar with Coolify (but I will definitely give it a try!). I always try to deeply understand the tech before making tutorial about it, so I will put it on my list, but it may take some time before I prepare a video.

      @workfloows@workfloows9 ай бұрын
    • @@workfloows Completely understandable! I figured it might interest you, and I'm pretty sure you can use it on any platform really, I just have only seen tutorials for hetzner. And it would be cool to see everything in a project using foss and connecting it all together, and the only thing not open, being open ai 😅 But it has one click setup for n8n, nocodb, postgreSQL, open source analytics, etc.

      @figs3284@figs32849 ай бұрын
    • Sounds really cool, thank you for recommendation!

      @workfloows@workfloows9 ай бұрын
  • Hey great video - im doing the zep install - how do you add the authentication keys JWT to the digital ocean vps?? Thx

    @musumo1908@musumo19087 ай бұрын
    • Hello, thanks for your kind comment! First, you need to generate a secret and put it into .env file (variable ZEP_AUTH_SECRET). Than, you need to create JWT token that is signed with the same secret, e.g. go to jwt.io, delete example payloads and in box „verify signature” replace „your-256-bit-secret” with your actual secret. In output, the tool should return the token that you can use for authentication in your app. I leave you also below a link to Zep documentation (chapter about authentication) that might be helpful. docs.getzep.com/deployment/auth/

      @workfloows@workfloows7 ай бұрын
  • HI oskar! so cool! Im unable to make it work tho, current memory is always invalid type or null :(

    @user-bn9kx3mo2x@user-bn9kx3mo2x6 күн бұрын
  • In this part 4:03 where did you get your base url from? Thanks, great vid btw

    @bryyytt@bryyytt8 ай бұрын
    • Thank you, I’m glad you like it! It’s IP address of my server and port on which I installed Zep.

      @workfloows@workfloows8 ай бұрын
  • Can we use Supabase instead of Redis? And if so, can I just change every redis node to supabase or should I change anything else?

    @pooriaarab@pooriaarab8 ай бұрын
    • Sure, you can use any database provider. Basically you will need to replace only Redis nodes, but most probably you will need to also update some of fields in other parts of workflow in order to pass correct parameters (output from Supabase may have different structure then output from Redis).

      @workfloows@workfloows8 ай бұрын
  • what software are you using in this video for workflow?

    @aces1up@aces1up9 ай бұрын
    • Hello, workflow is made with n8n (n8n.io).

      @workfloows@workfloows9 ай бұрын
  • Can use phone number as session to retrieve name automatically? Let say have lot user talking to the bot … how bot know each user talking to ? Or each trigger act as deference instance each time? Another question n8n can be good for saas business model ?

    @zakaria20062@zakaria200624 ай бұрын
    • Hi, thank you for your comment. This video shows building process of personal assistant/bot. If you want to make your bot available for other users, you need to specify unique session ID for each of them (it can be a phone number). Regarding your second question: overall, it’s possible to build SaaS functionalities using n8n, but it depends on what exactly you’re trying to build.

      @workfloows@workfloows4 ай бұрын
    • @@workfloowsthanks for clarification 😊

      @zakaria20062@zakaria200624 ай бұрын
  • @Oskar nice video. Is there any possibility to delete a memory content?

    @watchthebestonly@watchthebestonly9 ай бұрын
    • Hello, thank you for your kind comment. As far as I know, it should be possible to delete memory messages connected with specific session ID. You just need to make DELETE API call. I leave you below link to Zep documentation, where you can find endpoint schema and additional info on how to run this operation. docs.getzep.com/sdk/api/#delete Zep also runs soft-deletion and purging - more information about this process here: docs.getzep.com/deployment/data/

      @workfloows@workfloows9 ай бұрын
  • What is the purpose of Redis here - if we use the Zep setup on Render - does it automatically create a postgres datasbase for the messages?

    @stevenlevy8213@stevenlevy82137 ай бұрын
    • Hello, thank you for your comment. You can use any database you like - I preferred Redis because of extremely short response time, which is quite important for me by messaging.

      @workfloows@workfloows7 ай бұрын
    • thanks for the response - and great video@@workfloows

      @stevenlevy8213@stevenlevy82137 ай бұрын
    • Thank you very much!

      @workfloows@workfloows7 ай бұрын
  • What did you use to create this video out of curiosity? Very good tutorial!

    @andrewmartin2726@andrewmartin27265 ай бұрын
    • Hey, thanks for your comment and for kind feedback! For editing I use DaVinci Resolve and for screen recordings I use Screen Studio (affiliate): www.screen.studio/@jmMwX

      @workfloows@workfloows4 ай бұрын
  • how can I connect it but deployed also? Not just locally Does upstash redis work?

    @jadmalak1@jadmalak16 ай бұрын
    • Hello, thanks for your comment. I’m not sure I understand your question correctly, but to deploy this project you need to have n8n, Zep and Flowise installed on your server (I use Digital Ocean, but you can choose other cloud provider). In terms of Redis: you can use any host you want - just enter the correct database address when filling credentials in n8n.

      @workfloows@workfloows6 ай бұрын
  • Hi! Do you develop custom chat bots?

    @Anzhelika-ei3nq@Anzhelika-ei3nq8 ай бұрын
    • Hello, yes but it depends on scope of works and my current availability - feel free to email me to let me know some details of your project: workfloows@gmail.com. I will do my best to respond to you asap. Cheers!

      @workfloows@workfloows8 ай бұрын
  • So is this the best way to create multi-user ai chatbot apps using Telegram as the frontend and Flowise for the AI tools? Each user can now have their own unique experience with a single Flowise chain and/or agent?

    @jeffb6305@jeffb630514 күн бұрын
    • Hey, thanks for your comment. Not sure if this is the best way, but definitely users can have their own experience because of separate memory sessions. Since n8n introduced AI nodes some time ago, you can also try building such a chat bot only with n8n and skip Flowise (it should be even easier and less-complex solution).

      @workfloows@workfloows13 күн бұрын
  • Is session id a combination of chat-Id and user-Id if we are making the bot for multiple users? if so how can we do that?

    @baharhonarmandian9998@baharhonarmandian99988 ай бұрын
    • If you want to make a bot for multiple users (each user has one memory session) you can use only one parameter (chat ID). In that case all database nodes (Redis) from this tutorial will not be necessary, because user will not switch between memory sessions.

      @workfloows@workfloows8 ай бұрын
    • Thank you for responding. I'm making a telegram bot using your tutorial that has multiple personalities like /boy, /girl, and /family. In n8n, how can I know what personality the user has selected like /boy, /girl, /family...and separate the flows based on that? because right now there is one telegram trigger that detects all messages. Using an if node we can check to see if they used a command, but how do we know that they have "entered" that personality and how can they exit it? e.g. if they type /boy, all message triggers will go through the /boy flow. If they type, /girl, it will go through /girl flow@@workfloows

      @baharhonarmandian9998@baharhonarmandian99988 ай бұрын
    • @@baharhonarmandian9998 Well, in that case one user uses several memory sessions (so my previous response does not apply here). Basically, I assume in your project one personality should be one memory session (in order not to mix conversation histories with particular personalities). So you can replace names of memory sessions (in my tutorial /m1, /m2 and /m3) with your personalities (remember to update Telegram commands and all conditional nodes). Of course, workflow branches should route to Flowise chatflows, which have configurations of specific personalities ready.

      @workfloows@workfloows8 ай бұрын
  • Hello, thanks for watching my video! If you want to build Telegram AI voice bot and support my work at the same time, I highly invite you to check my tutorial available on Gumroad: workfloows.gumroad.com/l/telegram-ai-voice-bot

    @workfloows@workfloows8 ай бұрын
  • can you get this to work while also using a vector store? My bot uses vectors and when I try this method, the vector seems to overwrite the memory and it doesn't recall any of the conversation

    @bucksid8@bucksid86 ай бұрын
    • Hello, thanks for your comment. I have one tutorial which covers this topic in production - if everything goes well, it will be available in current or in the upcoming week.

      @workfloows@workfloows6 ай бұрын
    • @@workfloows Great. I think that most of the time we need a vector store. I'm waiting your video :-)

      @gazier20@gazier206 ай бұрын
    • @@workfloows Awesome! Subscribed so I won't miss it. Thanks!

      @bucksid8@bucksid86 ай бұрын
    • ​@@bucksid8Have you tried using a the vector store retriever tool?

      @dante_1273@dante_12736 ай бұрын
KZhead