Intent access control for different users

Is it possible to have different access control for different intents in Rasa. I will deploy the Rasa chatbot in my web app and I don’t want that all the users to access all the intents, some users shouldn’t have access rights for some questions. Is this achievable in RASA?

Welcome to the community :slight_smile:

You cannot set permissions over intents, but you can choose how to respond or not via a Custom Action.

For example, you have a database with each’s user’s permissions in a database, with entries of the form (user_name, action_name).

class ActionTest(Action):
    def name(self) -> Text:
        return 'action_test'

    async def run(self, dispatcher, tracker, domain):
        user_name = tracker.get_slot('username')
        action_name = this.name()

        has_permission = len(Database.query(
            f'SELECT * FROM permissions WHERE user_name="{user_name}" and action_name="{action_name}"'
        ))

        if has_permission == 1:
            dispatcher.utter_message('This is a test')
        
        return []

Again, this is just an example - use whatever method inside the Action to find permissions.

If the user user_name has permission to access action_test after triggering intent_test, the bot will reply “This is a test”, otherwise it won’t reply.

Great! Thank you for your response :slight_smile:

1 Like