(simple) Message Limit Function
# 📖tutorials
w
Hi guys! Limiting the number of messages a user can send is one of the most asked requests within the community. It’s a good way of managing AI tokens and invocations! I wanted to build a bigger template that included this feature, but due to time constraints I won't be able to finish it for a while so decided to share this mini template so other people can benefit from it. Thank you @quick-musician-29561 as always for helping me with my project and designing this template (all credit should go to him🦾 👑 ). This is a simple template (a copy is attached) that limits the user 2 messages per hour. It utilizes user variables to identify the user and limit messages. To change the default limit, change the 'messagesLeft' variable's default value as shown in the image. The limit resets every hour! Please note that it will work properly only on a published version, in the emulator it will reset as soon as you refresh the conversation. As mentioned in the title, it's a simple template so you can make it much more powerful and applicable for various use cases. Please share with the community any tips or improvements that you have🙂
c
Thanks to @wide-oyster-38514 and @quick-musician-29561 ! You two are Botpress legends
q
I'm also going to check that tomorrow! Of all the ideas and projects we have created, built, and planned together, 10% is my work and 90% is yours 🫡
w
Too kind! It’s a template you designed, I just cleaned it up a little. The one in my template will be shared whenever I get some free time🙏
c
It's essential to acknowledge and credit those who deserve it!
j
Nice!
Good job man
your a legend
b
Help me please... I shared a code to limit the number of messages and below I am asking a question so that you can resume sending messages again. Can you help me with the question that is in this link: https://discord.com/channels/1108396290624213082/1209820029668036669/1209820029668036669 I need help learning how to delete rows from the "Data3Table" table. If the key "CLAVE12345" is used, I have to delete that record line where that key is or also add a "FLAG" field that if it is 1 the key "CLAVE12345" is enabled and if it is 0 it is disabled. What do you guys think is better? Yo compartí un código para limitar el número de mensajes y más abajo estoy haciendo una pregunta para que se pueda reanudar el volver a mandar mensaje. Me ayudan con la pregunta que esta en este enlace.
q
The example 🦸🏻‍♂️ @wide-oyster-38514 🫡 posted is really good and works well. It uses '2 messages per hour'. We have also built something similar, using '10 messages in 24 hours' for some parts of the chatbot (VIP or Expert area), while all other parts are always available for use. By building it this way, it resets at different times for every user. This is different from resetting the daily messages always at 00:00, for example. If someone uses 10 messages between 11:50 PM - 11:59 PM, they would have 10 new messages starting at 00:00 again. If they use the next 10 messages between 0:00 AM - 0:10 AM, they would have used a total of 20 messages in 20 minutes. However, with our setup, users can only use 10 messages in a 24-hour period because it records the time of each user's last 'message reset' and counts how many messages they have used in the last 24 hours. So, there are at least two different ways to build this (the other method uses CRON). But this was the solution we needed for our projects.
a
Hello, do you know what is the limit of messages that I can set? 🤓
a
intresting
q
We have made similar projects here too, for example, check out this https://discord.com/channels/1108396290624213082/1233611875003142205/1234366013840162916
4 Views