Error with Custom Actions

Hi All,

As a preface, I have updated rasa x, rasa-sdk, and rasa to all of their latest versions as of 9/8/19.
I am attempting to use custom actions in rasa x, and I have scoured through multiple forum posts, particularly this one: Can't Get my Custom Action to Work Yet, I am still unable to resolve the custom action error.

I also looked through this one which has my exact error: Custom action not found error

Essentially, I have the same error of: Encountered an exception while running action 'action_get_hotel_link'. Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.

I have followed all of the steps (as far as I can tell) that were mentioned in that post, and ultimately, here are all my associated files:

Action.py:

from typing import Dict, Text, Any, List, Union, Optional

from rasa_sdk import Action, Tracker, ActionExecutionRejection
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormAction, REQUESTED_SLOT
from rasa_sdk.events import Restarted


class BookHotel (Action):
    def name(self):
        return 'action_get_hotel_link'
    
    def run(self, dispatcher, tracker, domain):
        
        sp_data = "this is a test"
        
        dispatcher.utter_message(sp_data)
        return []

domain.yml (necessary info)

actions:

- action_default_ask_affirmation

- action_default_fallback

- action_get_hotel_link

endpoints.yml

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

#core_endpoint: 
#  url: http://localhost:5005

Note I was trying with both the core lines uncommented and commented, should I leave it uncommented?

Error message

I ran rasa run actions --actions actions (and I also tried rasa run actions --actions testbot.actions but I got: ModuleNotFoundError: No module named ‘testbot’ error so I just did it without testbot)

Any insight would be greatly appreciated! I am at a loss after reading all of the forum posts on this error, so I am beginning to think that it is the incompatibility issue between the sdk and rasa versions or I am missing something blatantly obvious (which is very likely).

Thank you all so much!

I’m sorry if i’m asking a silly question but is your Action.py actually named ‘Action.py’ ? If yes can you try changing to ‘actions.py’ and see how it goes ?

Thank you for the reply. It is called “actions.py”, and I mistyped it in my post. Thanks!

First of all, thanks for providing so much revelant information! I’ve edited your comment to format code and console output with the three ticks (```) above and below for readibility.

It’s not an issue with the compatibility – we just hadn’t released a compatibility release for SDK yet since nothing changed (i.e. sdk 1.1.1 is compatible with rasa 1.2.x), however since you posted we did release sdk 1.2.0 if you want that error message to go away :slight_smile:

The action endpoint looks good, you want to keep it uncommented as it is. Core endpoint you don’t need.

The issue is that it’s registering some sort of action server but not your actual action. For reference, if it’s registered it correctly, this is what you should see upon starting the server:

rasa ❯ rasa run actions
2019-08-21 01:29:47 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
2019-08-21 01:29:47 INFO     rasa_sdk.executor  - Registered function for 'action_get_hotel_link'.
2019-08-21 01:29:47 INFO     rasa_sdk.endpoint  - Action endpoint is up and running. on ('0.0.0.0', 5055)

Can you share your project directory structure, as well as your working directory when you run your actions command, and what that command is? I want to make sure the correct path is being passed to the rasa run actions command. My guess is that it’s registering the commented out actions.py file from rasa init instead of the one you wrote, or something like that. I copied your code into my example bot and it registered the action correctly, so it’s no issue with your code, just something with the path.

1 Like

Thank you Ella! It was indeed a directory structure issue, and I reformatted it to put my actions.py in a demo folder and called it from there. Thanks for your help again!

1 Like

Coolio. No worries! Keep on truckin :rocket:

1 Like