Send custom message in action_session_start

Hi everyone,

what is the best way to send a message with the session_start Action. I want this action to allways be send in the very beginning of every conversation. I tried this code snipped:

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

    async def run(
        self, dispatcher, tracker: Tracker, domain: Dict[Text, Any]
    ) -> List[Dict[Text, Any]]:
        dispatcher.utter_message(response="utter_session_start")
        # the session should begin with a `session_started` event and an `action_listen`
        # as a user message follows
        return [SessionStarted(), ActionExecuted("action_listen")]

This does not work in rasa interactive or in the interactive “Talk to your bot” of Rasa X.

I get the following error message:

Encountered an exception while running action 'action_session_start'.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.
Traceback (most recent call last):
  File "/opt/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 869, in _run_action
    events = await action.run(
  File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 750, in run
    bot_messages: List[Event] = await self._utter_responses(
  File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 699, in _utter_responses
    generated_response, tracker, output_channel.name(), **response
AttributeError: 'NoneType' object has no attribute 'name'

Do you have any ideas what this originates from?

Thank you in advance,

Sören

Hi! :smiley:

Everything working fine here. Maybe some Python syntax problem.

My action.py

from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.events import SessionStarted, ActionExecuted


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

    async def run(
      self, dispatcher, tracker: Tracker, domain: Dict[Text, Any]
    ) -> List[Dict[Text, Any]]:
        dispatcher.utter_message(response="utter_iamabot")
        return [SessionStarted(), ActionExecuted("action_listen")]

My domain.yml

version: "3.0"

intents:
  - greet
  - goodbye
  - affirm
  - deny
  - mood_great
  - mood_unhappy
  - bot_challenge

responses:
  utter_greet:
  - text: "Hey! How are you?"

  utter_cheer_up:
  - text: "Here is something to cheer you up:"
    image: "https://i.imgur.com/nGF1K8f.jpg"

  utter_did_that_help:
  - text: "Did that help you?"

  utter_happy:
  - text: "Great, carry on!"

  utter_goodbye:
  - text: "Bye"

  utter_iamabot:
  - text: "I am a bot, powered by Rasa."

actions:
- action_session_start

session_config:
  session_expiration_time: 60
  carry_over_slots_to_new_session: true

Hi @itsjhonny,

What channel are you using? It also works fine e.g. on WhatsApp. But on rasa interactive I get the error.

Hi @soerenetler

I tested using rasa shell and rasa run actions commands

Hi everyone,

I am having the same problem here. Works fine with rasa shell, rasa run actions as well as the channels I configured. It does not with rasa interactive, though!

Any idea?

Hello,

same issue here. Works fine with rasa shell & rasa run actions, but error occurs with rasa interactive & rasa run actions.

My action_session_start calls dispatcher.utter_message(response="utter_welcome") and then starts a form via return [FollowupAction("information_form")]

Rasa Version : 3.6.4 Minimum Compatible Version: 3.5.0 Rasa SDK Version : 3.6.1 Python Version : 3.8.17 Operating System : Linux-6.2.0-26-generic-x86_64-with-glibc2.35

2023-08-28 11:03:33 ERROR    rasa.core.processor  - Encountered an exception while running action 'action_session_start'.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.
Traceback (most recent call last):
  File "/home/frischholz/Schreibtisch/Projekte/chatbot/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 960, in _run_action
    events = await action.run(
  File "/home/frischholz/Schreibtisch/Projekte/chatbot/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 794, in run
    bot_messages = await self._utter_responses(
  File "/home/frischholz/Schreibtisch/Projekte/chatbot/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 728, in _utter_responses
    generated_response, tracker, output_channel.name(), **response
AttributeError: 'NoneType' object has no attribute 'name'