Problem in coding a Welcome Message along with options

I read this answer on How to code a Welcome Message in RASA, accordingly, I did write a custom action but it is not displaying the message as soon as the session starts, instead, it replies after the user has sent a message. Below is my code for printing just the welcome message. I had put this in my “actions.py” file. Please help me to fix this problem.

The image below is an example of How I want my bot to start, It would start up with a general message and then it would give options which the user would be choosing. This is what I am trying to achieve ultimately.

from typing import Text, List, Dict, Any

from rasa_sdk import Action, Tracker
from rasa_sdk.events import SlotSet, SessionStarted, ActionExecuted, EventType
from rasa_sdk.executor import CollectingDispatcher


class ActionSessionStart(Action):
    def name(self) -> Text:
        return "action_session_start"

    @staticmethod
    def fetch_slots(dispatcher: CollectingDispatcher, tracker: Tracker) -> List[EventType]:
        """Collect slots that contain the user's name and phone number."""

        slots = []
        return slots		


    async def run(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[EventType]:

        # the session should begin with a `session_started` event
        dispatcher.utter_message("Hi, I am Aayush Bot !!!")
        events = [SessionStarted()]

        # any slots that should be carried over should come after the
        # `session_started` event
        events.extend(self.fetch_slots(dispatcher, tracker))

        # an `action_listen` should be added at the end as a user message follows
        events.append(ActionExecuted("action_listen"))

        return events

Hi Aayush,

This event will fire only when a new session is started. The default session timeout is 60 minutes so your sender_id would have to be idle for 60 minutes before the action_session_start is called. You can customize the timeout as described here.

You can also just generate different sender_id values for testing purposes.

Do you have log messages to confirm whether it is being called?

You also should confirm that action_session_start is defined in the actions: section of your domain.yml.

Greg

I suspect t

Thanks Sir for replying back !

I did edit the default session timeout to 1 minute yet in the RASA X it showed action_session_start only when I started the RASA X despite of showing after every 1 minute of inactivity.

Could you elaborate on How to generate different sender_id values for testing purposes ?
So far I know that I can share the RASA X link with different users for test purpose.

I don’t have log messages to confirm.

Yes, action_session_start is defined in the actions: section of my domain.yml .
I had followed this answer previously.

Please, guide me Sir.

I typically test using postman or curl and the Rasa REST endpoint (port 5005). For example:

curl --location --request POST 'http://localhost:5005/webhooks/rest/webhook' \
--data-raw '{
    "sender": "al",
    "message": "hi",
}'

Change the sender value between calls and it will start a new session.

Greg

Sir, I will revert back to you after trying out your suggestion.
Thanks.