When I try to use the dispatcher.utter_message(“hello”) to send messages to the user from the ActionSessionStart, the error: AttributeError: ‘NoneType’ object has no attribute ‘send_response’ occurs
When a try to do the same using template I get this error: 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.
this is the code
class ActionSessionStart(Action):
def name(self):
return “action_session_start”
Hi there, i have the similar problem as well. Based from the Rasa documentation, we can override the default actions by manually adding it as a custom action in both actions.py and domain.yml. Yet, I get the same error AttributeError: ‘NoneType’ object has no attribute ‘send_response’. However, i do notice that once i start initiating a simple “Hi”, the supposedly first liner message variable will appear. But before i give any response, it will not show up as what i intended to. Can anyone share any opinion on this?
actions.py
class ActionSessionStarted(Action):
def name(self):
return "action_session_start"
async def run(self, dispatcher, tracker, domain):
events = [SessionStarted()]
message = 'Hello, I am a ChatBot'
dispatcher.utter_message(message)
events.append(ActionExecuted("action_listen"))
return events
I had the same problem, in my case was an indentation on domain.yml.
I had an intent with a trigger with the wrong indentation like below:
- insult:
triggers: utter_sorry
And the correct was:
- insult:
triggers: utter_sorry
Even if this isn’t your case I suggest look more carefully at the error and the location inside the RASA, in my case I was able to found looking at the source. The error message told me where to look:
File “c:\venv\lib\site-packages\rasa\core\domain.py”, line 288, in _transform_intent_properties_for_internal_use
properties.setdefault(USE_ENTITIES_KEY, True)
AttributeError: ‘NoneType’ object has no attribute ‘setdefault’
Do you have a working example for this?
Below is my actions.py file. I have added the class ActionSessionStart.
I have also included - action_session_start in my
domain.yml
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormAction
from rasa_sdk.events import SlotSet, SessionStarted, ActionExecuted, EventType
class ActionSessionStart(Action):
def name(self) -> Text:
return "action_session_start" # This name function returns the name of the custom action.Here is is action_session_start
@staticmethod
def fetch_slots(tracker: Tracker) -> List[EventType]:
"""Collect slots that contain the user's name and phone number."""
slots = []
for key in ("name", "email", "pincode", "mobnumber"):
value = tracker.get_slot(key)
if value is not None: # this is how to check if slot value is filled or not.
slots.append(SlotSet(key=key, value=value))
return slots
def apply_to(self, tracker: "DialogueStateTracker") -> None:
# noinspection PyProtectedMember
tracker._reset()
async def run(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[EventType]:
# the session should begin with a `session_started` event
events = [SessionStarted()]
#
# # any slots that should be carried over should come after the
# # `session_started` event
# events.extend(self.fetch_slots(tracker))
#
# # an `action_listen` should be added at the end as a user message follows
dispatcher.utter_message(template="utter_greet_ask")
events.append(ActionExecuted("action_listen"))
#
return events
But Still it dosn’t seem to start the conversation with utter_ask_greet
I ran the command rasa run actions -p 5002 in one terminal and rasa run
in another.
Using ngrok to connect to telegram.( ngrok is running in port 5005, so earlier I got error as action server can’t be started.)
All telegram configutations are done and set up the bot in telegram as well.
I just found a temporary workaround for telegram.
You can’t make a bot initiate a convo in telegram, has to start with a /start sent by the user.
So I just added the below to my domain.yml.
- start:
triggers: utter_bot_function
I tried removing the whole ActionSessionStart class and have the default action_session_start and it works the way I want. That’s a workaround for telegram.
But the issue of bot not reponding first in normal rasa run actions -p 5002 & rasa shell --debug command, is still not solved.
Here is my logs :