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