How to use tracker data in a chat client?

Hey folks,

In a chat client I need to access detailed information from the tracker. I need to get the tracker results direclty after the bot send a response to some user input.

As far as I know there are several options to achieve that:

  1. Enable the rasa HTTP API via rasa run —enable-api and GET the conversation tracker from PATH_TO_HOST/conversations/{conversation_id}/tracker asap as I receive a response from the InputChanel

    • My Qustion: I am concerned of race conditions. Will the api call 'conversations/{conversation_id}/tracker` allways return the updated tracker or may it happen that the tracker is not yet updated?
  2. Use an EventBroker to store the information in some database.

    • My Question: I am again concerned of race conditions. As above I would query from the DB after I receive a response from the InputChanel. Will the answer always be updated already?
  3. Adjust the rasa.core.channels.channel.register method s.t each InputChannel may have access to the tracker or (from my point of view even better) directly to the agent. This would allow to develop custom InputHandlers even more easily. Here is all the code change that would be needed in the rasa stack (rasa version 1.6.0):

def register(...):
    async def handler(*args, **kwargs):
        await app.agent.handle_message(*args, **kwargs)
        return app.agent # The changed line of code
...

Do I miss any option, made a mistake and/or what do you think of the suggested rasa code change?

As long as you wait until the bot answered, the tracker should already be updated.

Use an EventBroker to store the information in some database. My Question: I am again concerned of race conditions. As above I would query from the DB after I receive a response from the InputChanel. Will the answer always be updated already?

The events are streamed as they appear. Between which components would you expect the race condition?

Adjust the rasa.core.channels.channel.register method s.t each InputChannel may have access to the tracker or (from my point of view even better) directly to the agent. This would allow to develop custom InputHandlers even more easily. Here is all the code change that would be needed in the rasa stack (rasa version 1.6.0):

Can you tell me a little bit more about your use case? Not sure if 3) is the right way.

You can write own your own channel or modify any channel you want and access the trackerstore through the request object, with request.app.agent.tracker_store

1 Like