Is there a way to execute an action the first time user send message?

Hello,

I’m looking for a way to execute an action the first time users start talking to the bot. Like at the very start of a talking session. Basically when an user (employee in this case) send the first message to the bot, i want to take the sender_id, make a query to the database and get some necessary information then set them to the corresponding slots, so that the bot can use those information from then on.

Desired:
    User: First message (from any intent)
    Bot: action_set_up (get information from DB and assign them to the slots)
    Bot: Response to message (may or may not use the information)

Now i can think of a way to achieve this, but it is not efficient: Using MappingPolicy to map action_set_up to all of the intents.

I wonder if there is a better and more efficient way to do this. Any help would be appreciated. Thank you.

We used a workaround for that (in our own chat UI). We automatically send a user message on start so that we could perform our custom action first.

If there’s another way, Id be interested

Oh i understand. It does make more sense to actively tell the bot to set up when a user login than waiting for the user’s first message. Thank you for your answer.

You can also do that without making the user send a message on its behalf (because you artificially increase your bot’s usage and so mess up analytics/conversation log).

At user login, you can make a query to your DB and get the necessary information from your own chat UI. After that, trigger a SlotSet event in your tracker and set the desired slots with your information. There are 2 possibilities for that :

By this way no fictional message would be sent and you will have all your slots ready for your user’s first message.

1 Like