0

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.

enter image description here

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
1
  • what do the logs for rasa shell --debug and rasa run actions --debug show when you start the conversation?
    – Melinda
    Commented Apr 14, 2020 at 20:01

1 Answer 1

1

Whatever input channel you're using needs to send the /start_session payload to trigger action_session_start. You can do this by just typing /start_session at the prompt. If you're testing this in rasa shell, you need to send the payload manually. Otherwise, it will start the session after the first message (which is what you're observing).

2
  • Thanks for your reply. Could you elaborate on How to send the "/start_session" payload ?? Commented Apr 24, 2020 at 12:58
  • updated my answer - just send it as a message at the shell prompt
    – Melinda
    Commented Apr 24, 2020 at 15:15

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.