Can I limit the user's questions or time on my cha...
# 🤝help
p
To manage the Ai spend and our data base, I would like to have the option to limit the questions asked by the users to a certain number, or have a timeout to their session. This could be eliminated for subscribed users. Any ideas on how to do that and limitations if deployed on the web or on whatsapp?
q
Both an inactivity timeout and repetition limit (i,e. limiting the number of questions) are easily done via the bot settings (see screenshot). To make the repetition limit dynamic based on whether the user is a subscriber is a little more involved. I would think adding some code to check the user type (subscribed or not) and the number of repetitions, and then diverting the workflow/response accordingly, would be the way forward. https://cdn.discordapp.com/attachments/1221807651470577774/1221825472552243210/image.png?ex=6613fca5&is=660187a5&hm=50b686d5879e60550aa125106e88fbe43b9f0b260bb37439bf4fed7e7d274ba7&
f
You can also add a table, with user id and number of messages sent and last time a message was sent by them.
Everytime they send a message you increase the "number of messages"
Somewhere at the beginning of the flow, check for the number of messages sent by the user, then show an error in case they passed the limits
p
Awesome! Thank you soo much everyone. This is a great guide @quick-musician-29561 !
b
Hi! Is there a way to disable or change repetition limit to unlimited?
q
The example AA posted is really good and works well. I believe 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.
p
How would building this be different if we implement a "key" feature and depending on it you would have a different amount of credits? I am implementing this solution so it would be great if you have any guidance on iterations based on it.
@quick-musician-29561 It says that there is an ai task running, is that the same as ai transition or is there an ai task in the bot you sent? https://cdn.discordapp.com/attachments/1221807651470577774/1222543638970499122/Screenshot_2024-03-27_at_3.51.28_PM.png?ex=6616997d&is=6604247d&hm=f9303f97ebc963d311a27ea18b3a247043d912b6f65704790c0b286624c8b3ad&
69 Views