Dispatcher.utter_message not working in Rasa SDK version 1.7

Hi all,

I am trying to build a chatbot using Rasa and I am using the following packages:

rasa-core==0.14.5 rasa-core-sdk==0.14.0 rasa-nlu==0.15.1 rasa-sdk==1.7.0

My custom action file code is:

class ApiAction(Action):
    def name(self):
        return "action_retrieve_news"

    def run(self, dispatcher, tracker, domain):
#         print ("Reached action_retrieve_news")
#         topic = tracker.get_slot('topic')
        response = {"text":"News are Blah Blah Blah"}
        dispatcher.utter_message(text="News are Blah Blah Blah")
        return []

And my endpoint is

  url: "http://localhost:5055/webhook"

I am running the server using the following commands:

python -m rasa_sdk --actions actions
python -m rasa_core.run -d models/dialogue -u models/nlu/default/chat --endpoints endpoints.yml --debug

The issue is dispatcher is not returning any response. I am not seeing the text “News are Blah Blah Blah”. Can anyone please help me with that?

This is the debug logs I am seeing when the custom action is triggered:

2020-02-12 19:36:50 DEBUG rasa_core.policies.memoization - Current tracker state [{‘entity_topic’: 1.0, ‘prev_action_retrieve_news’: 1.0, ‘slot_topic_0’: 1.0, ‘intent_ask_news_with_topic’: 1.0}, {‘prev_utter_continue_conversation’: 1.0, ‘entity_topic’: 1.0, ‘slot_topic_0’: 1.0, ‘intent_ask_news_with_topic’: 1.0}, {‘intent_agree’: 1.0, ‘prev_action_listen’: 1.0, ‘slot_topic_0’: 1.0}, {‘intent_agree’: 1.0, ‘prev_utter_ask_topic’: 1.0, ‘slot_topic_0’: 1.0}, {‘entity_topic’: 1.0, ‘prev_action_listen’: 1.0, ‘slot_topic_0’: 1.0, ‘intent_ask_news_with_topic’: 1.0}]

2020-02-12 19:36:50 DEBUG rasa_core.policies.memoization - There is no memorised next action

2020-02-12 19:36:50 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_0_KerasPolicy

2020-02-12 19:36:50 DEBUG rasa_core.processor - Predicted next action ‘action_retrieve_news’ with prob 0.82.

2020-02-12 19:36:50 DEBUG rasa_core.actions.action - Calling action endpoint to run action ‘action_retrieve_news’.

2020-02-12 19:36:50 DEBUG rasa_core.processor - Action ‘action_retrieve_news’ ended with events ‘[]’

You are using some old and new packages. We replaced rasa-core and rasa-nlu with a package called rasa. I would recommend to install rasa (Installation) and try again together with rasa-sdk. You can remove the other packages (pip uninstall rasa-core rasa-nlu rasa-core-sdk).

I think you don’t need to modify any code (at lease the action looks good), however you should use different commands to start the bot:

# Start the action server via
rasa run actions
# Run Rasa via
rasa run --debug

Also you should retrain your model before starting Rasa via rasa train. Does that help?

1 Like

Thank you very much. That did help me :slight_smile:

I have one more question. Can we make API call in custom action to load data from external API’s like Twitter updates or Google news?


Yes, you can do API calls inside your custom actions.