Custom action not found error

I am trying to execute custom action, but failing with below error:

(myrasa) C:\Users\SowmyaParvathi\myrasa\tests> python -m rasa_core.run -d models/dialogue -u models/current/nlu --endpoints endpoints.yml c:\users\sowmyaparvathi\appdata\local\programs\python\python36\Lib\runpy.py:125: RuntimeWarning: ‘rasa_core.run’ found in sys.modules after import of package ‘rasa_core’, but prior to execution of ‘rasa_core.run’; this may result in unpredictable behaviour warn(RuntimeWarning(msg)) 2019-07-25 14:23:46 INFO root - Rasa process starting 2019-07-25 14:23:47.075102: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 WARNING:tensorflow:From C:\Users\SowmyaParvathi\myrasa\lib\site-packages\tensorflow\python\training\saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version. Instructions for updating: Use standard file APIs to check for files with this prefix. 2019-07-25 14:23:47 WARNING tensorflow - From C:\Users\SowmyaParvathi\myrasa\lib\site-packages\tensorflow\python\training\saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version. Instructions for updating: Use standard file APIs to check for files with this prefix. INFO:tensorflow:Restoring parameters from models/current/nlu\component_5_EmbeddingIntentClassifier.ckpt 2019-07-25 14:23:47 INFO tensorflow - Restoring parameters from models/current/nlu\component_5_EmbeddingIntentClassifier.ckpt 2019-07-25 14:23:50 INFO apscheduler.scheduler - Scheduler started

WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0. For more information, please see:

WARNING:tensorflow:From C:\Users\SowmyaParvathi\myrasa\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version. Instructions for updating: Colocations handled automatically by placer. 2019-07-25 14:23:52 WARNING tensorflow - From C:\Users\SowmyaParvathi\myrasa\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version. Instructions for updating: Colocations handled automatically by placer. WARNING:tensorflow:From C:\Users\SowmyaParvathi\myrasa\lib\site-packages\tensorflow\python\keras\backend.py:4010: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version. Instructions for updating: Please use rate instead of keep_prob. Rate should be set to rate = 1 - keep_prob. 2019-07-25 14:23:52 WARNING tensorflow - From C:\Users\SowmyaParvathi\myrasa\lib\site-packages\tensorflow\python\keras\backend.py:4010: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version. Instructions for updating: Please use rate instead of keep_prob. Rate should be set to rate = 1 - keep_prob. WARNING:tensorflow:From C:\Users\SowmyaParvathi\myrasa\lib\site-packages\tensorflow\python\ops\math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.cast instead. 2019-07-25 14:23:52 WARNING tensorflow - From C:\Users\SowmyaParvathi\myrasa\lib\site-packages\tensorflow\python\ops\math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.cast instead. 2019-07-25 14:23:53 INFO root - Rasa Core server is up and running on http://localhost:5005 Bot loaded. Type a message and press enter (use ‘/stop’ to exit): Your input → hi Hey, How Can I help You 127.0.0.1 - - [2019-07-25 14:24:00] “POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1” 200 191 0.420958 Your input → list TERs 2019-07-25 14:24:08 ERROR rasa_core.actions.action - Failed to run custom action ‘action_ask_milestone’. Action server responded with a non 200 status code of 500. Make sure your action server properly runs actions and returns a 200 once the action is executed. Error: 500 Server Error: INTERNAL SERVER ERROR for url: http://localhost:5055/webhook 2019-07-25 14:24:08 ERROR rasa_core.processor - Encountered an exception while running action ‘action_ask_milestone’. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.

On other terminal, where action server is started:

(myrasa) C:\Users\SowmyaParvathi\myrasa\tests> python -m rasa_core_sdk.endpoint --actions actions 2019-07-25 14:22:44 INFO main - Starting action endpoint server… 2019-07-25 14:22:44 ERROR rasa_core_sdk.executor - Failed to register package ‘actions’. Traceback (most recent call last): File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\rasa_core_sdk\executor.py”, line 150, in register_package self._import_submodules(package) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\rasa_core_sdk\executor.py”, line 137, in import_submodules package = importlib.import_module(package) File "C:\Users\SowmyaParvathi\myrasa\lib\importlib_init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File “”, line 994, in _gcd_import File “”, line 971, in _find_and_load File “”, line 955, in _find_and_load_unlocked File “”, line 665, in _load_unlocked File “”, line 678, in exec_module File “”, line 219, in _call_with_frames_removed File “C:\Users\SowmyaParvathi\myrasa\tests\actions.py”, line 1, in from rasa_core_sdk.actions import Action ModuleNotFoundError: No module named ‘rasa_core_sdk.actions’ 2019-07-25 14:22:46 INFO main - Action endpoint is up and running. on (‘0.0.0.0’, 5055) [2019-07-25 14:22:57,690] ERROR in app: Exception on /webhook [POST] Traceback (most recent call last): File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 2446, in wsgi_app response = self.full_dispatch_request() File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask_cors\extension.py”, line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask_compat.py”, line 39, in reraise raise value File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 1949, in full_dispatch_request rv = self.dispatch_request() File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 1935, in dispatch_request return self.view_functionsrule.endpoint File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask_cors\decorator.py”, line 128, in wrapped_function resp = make_response(f(*args, **kwargs)) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\rasa_core_sdk\endpoint.py”, line 59, in webhook response = executor.run(action_call) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\rasa_core_sdk\executor.py”, line 177, in run “No registered Action found for name ‘{}’.”.format(action_name) Exception: No registered Action found for name ‘action_ask_milestone’. 2019-07-25 14:22:57 ERROR endpoint - Exception on /webhook [POST] Traceback (most recent call last): File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 2446, in wsgi_app response = self.full_dispatch_request() File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask_cors\extension.py”, line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask_compat.py”, line 39, in reraise raise value File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 1949, in full_dispatch_request rv = self.dispatch_request() File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 1935, in dispatch_request return self.view_functionsrule.endpoint File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask_cors\decorator.py”, line 128, in wrapped_function resp = make_response(f(*args, **kwargs)) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\rasa_core_sdk\endpoint.py”, line 59, in webhook response = executor.run(action_call) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\rasa_core_sdk\executor.py”, line 177, in run “No registered Action found for name ‘{}’.”.format(action_name) Exception: No registered Action found for name ‘action_ask_milestone’. 127.0.0.1 - - [2019-07-25 14:22:57] “POST /webhook HTTP/1.1” 500 411 0.046557 [2019-07-25 14:23:15,721] ERROR in app: Exception on /webhook [POST] Traceback (most recent call last): File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 2446, in wsgi_app response = self.full_dispatch_request() File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask_cors\extension.py”, line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask_compat.py”, line 39, in reraise raise value File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 1949, in full_dispatch_request rv = self.dispatch_request() File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask\app.py”, line 1935, in dispatch_request return self.view_functionsrule.endpoint File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\flask_cors\decorator.py”, line 128, in wrapped_function resp = make_response(f(*args, **kwargs)) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\rasa_core_sdk\endpoint.py”, line 59, in webhook response = executor.run(action_call) File “C:\Users\SowmyaParvathi\myrasa\lib\site-packages\rasa_core_sdk\executor.py”, line 177, in run “No registered Action found for name ‘{}’.”.format(action_name) Exception: No registered Action found for name ‘action_ask_milestone’.

Contents of endpoints.yml:

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

Contents of actions.py

from rasa_core_sdk.actions import Action from rasa_core.events import SlotSet

class ActionAskMilestone(Action): def name(self): return “action_ask_milestone”

def run(self,dispatcher,tracker,domain):

  loc = tracker.get_slot('milestone');
  print ("I am not getting called, Mention your milestone");      
  print ("I am not getting called, Mention your milestone");      
  dispatcher.utter_message("Going back");
  return [SlotSet('milestone',resp)]

Contents of domain.yml:

slots: milestone: type: text intents: - greet - get_info - good_bye

entities: - milestone

actions:

  • utter_greet
  • utter_ask_milestone
  • utter_ask_testplan_num
  • utter_list_info
  • action_ask_milestone

templates: utter_greet: - text: “Hey, How Can I help You” - text: “Hello, How can I help You” - text: “Hi, how can I help you!”

utter_ask_milestone:
    - text: "From which {milestone}?"
    - text: "Please mention Milestone"
    
utter_ask_testplan_num:
    - text: "From which Test Plan"
    
utter_list_info:
    - text: "Listing Info"

Contents of stories.md:

story 1

  • greet
    • utter_greet

story 2

  • get_info
    • action_ask_milestone
    • utter_list_info *get_info
      • action_ask_milestone

story 3

  • get_info
  • action_ask_milestone
  • utter_list_info

story 2

  • get_info
    • utter_ask_testplan_num
    • utter_list_info

Please help!

I also got this problem. Anyone can help?:joy:

You should be importing Action class like this in your actions.py:

from rasa_sdk import Action

Check if all your imports are correct or not. The error is showing up in your action server terminal output.

I imported some libs from rasa_sdk but still got the ‘custom action not found error’.

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormAction
from rasa_sdk.events import SlotSet, UserUtteranceReverted, ConversationPaused

The detailed errors look like as following.

I think I will need all the details. Can you ask another question in the forum with all the details and errors. That would make things clearer.

Thanks tonysinghmss. I have figured out this problem just now. I didn’t specify the actions.py file, so that the custom action server didn’t start the .py file.

hi @nicolasNi i get same error how did you specify the actions.py file?

The path of actions.py file is demo/actions.py

Then run the following command to run custom action with specified .py file.

rasa run actions --actions demo.actions

@nicolasNi i get this error

2019-07-27 02:58:40 ERROR rasa.core.processor - Encountered an exception while running action ‘action_get_answer’. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code. 2019-07-27 02:58:40 DEBUG rasa.core.processor - ‘dict’ object has no attribute ‘endswith’ Traceback (most recent call last): File “c:\users\dorsaf\anaconda3\envs\rasa1\lib\site-packages\rasa\core\processor.py”, line 439, in _run_action events = await action.run(output_channel, nlg, tracker, self.domain) File “c:\users\dorsaf\anaconda3\envs\rasa1\lib\site-packages\rasa\core\actions\action.py”, line 399, in run json=json_body, method=“post”, timeout=DEFAULT_REQUEST_TIMEOUT File “c:\users\dorsaf\anaconda3\envs\rasa1\lib\site-packages\rasa\utils\endpoints.py”, line 137, in request url = concat_url(self.url, subpath) File “c:\users\dorsaf\anaconda3\envs\rasa1\lib\site-packages\rasa\utils\endpoints.py”, line 49, in concat_url if base.endswith("/"): AttributeError: ‘dict’ object has no attribute ‘endswith’

did you define action by using list ?

did you run action on your server ?

did check your endpoints.py file ?

did you debug your code as visual and run it rasa ?

Hi,

I ran your above command, but I still get the same error. Any other insights?