Discussions

Ask a Question
Back to All

How to Limit Live Avatar to One Question or Block Responses via Script?

Hello,

I’m using the D-ID API to integrate a Live Avatar into my Flask application. I would like to limit the number of questions the avatar can respond to in a single session to just one. Currently, users can send multiple questions in the same session, which I’d like to block.

I’ve tried using Flask session variables (session["asked"]) to track whether a user has already asked a question, but this solution only works at the application level, not within the D-ID agent itself. I’m wondering if there’s a native way within the D-ID API to achieve this:

Limit the number of messages sent to the agent per session: For example, by configuring the chatId or another mechanism.
Block responses to additional questions after the first answer: Perhaps through a script or configuration within the D-ID API.
Has anyone faced a similar issue and found a good solution?

Additionally, are there any other best practices for controlling the number of interactions with an agent? I would appreciate any guidance or tips!

Here’s what I’m currently working with:

Current Setup:

Using the /talks endpoint to send user input to the agent.
Flask manages the frontend and backend logic.
No llm or knowledge base configuration has been added to the agent yet.
Questions:

Does the D-ID API provide a way to limit the number of messages in a session?
Is there a built-in method to block further questions after one response?
Can this be managed via a custom script or configuration at the agent level?
Thank you in advance for your help and suggestions!