Call Duration Restriction
# support
z
Hi, lets say a user pays for 1 hour on ZeroBot I know I can set a limit to 1 hour with the maxDurationSeconds parameter. But what happens if the user with 1 hour opens the tab 10 times, would this give them access to 10 hours of calling? Is there any way I can stop the user from using beyond the given time?
v
message has been deleted
@ZeroBot.ai Hello! Great question. When a user pays for 1 hour on ZeroBot and you set the
maxDurationSeconds
parameter to limit the call duration, this indeed restricts a single session to 1 hour. However, if the user opens multiple tabs, each tab is typically treated as a separate session. To prevent a user from using beyond the given time across multiple sessions, you would need to implement a tracking system on your backend. This system would keep track of the total time the user has spent on calls and deduct it from their purchased time. Once the total allotted time is reached, you would then restrict the user from initiating new calls. This could involve: 1. Generating a unique token for each purchase that is associated with the time purchased. 2. Recording the start and end time of each call session for the user. 3. Calculating the total time used and comparing it with the purchased time. 4. Disabling the user's ability to initiate a call once their purchased time is used up. If you need assistance with implementing such a system or have any other questions, please let me know!
You can continue this conversation by mentioning me in the message.
z
i have a tracking system on the backend that stores the seconds of each call, it also deducts each phone call duration from the available time. can i dynamically update the
maxDurationSeconds
to the updated available time and keep all tabs in-sync?
@Vapi
v
@ZeroBot.ai Yes, you can dynamically update the
maxDurationSeconds
parameter with the updated available time to ensure that all tabs remain in sync with the user's remaining time. To achieve this, you would need to: 1. Ensure that your backend is aware of the total time the user has left at any given moment. 2. When a new call is initiated from any tab, query your backend for the current remaining time. 3. Set the
maxDurationSeconds
parameter for the new call based on the remaining time provided by your backend. 4. Use a mechanism like WebSockets or long polling to push updates to all open tabs if the available time changes (e.g., if a call ends and the remaining time is updated). By doing this, each new call initiated from any tab will have the correct
maxDurationSeconds
value that reflects the user's remaining time. Additionally, if you're using WebSockets or another real-time communication method, you can inform all active sessions to end the call if the user's total purchased time has been used up. If you need further assistance with setting this up or have any other questions, feel free to ask!
s
You can't update it dynamically.
Let me ask for the my team for this part.
z
Ah, ok, I've set up an SSE that updates the available time for now, would be awesome if I could stop the call once the user's time runs out
s
Currently, we don't have any way to do it. But, this is what you can do The cleanest way to implement this would be: Before starting the call, their backend checks if this user has quota or concurrent call. If yes, return a JWT for that assistantId. If not, block.
w
Hi, I hope it is fine that I jump in on this thread. Does the JWT solution solve the initial problem with a user potentially opening 10 tabs? If yes, how so? @Sahil
s
Can you please create a new thread along with your queries because this thread is solved.
6 Views