Custom action not working (Encountered an exception while running action 'action_custom'.)

Rasa version : Rasa 1.1.4

Python version : Python 3.7.3 (anaconda)

Operating system : windows

Issue : customs action not working

Error (including full traceback) :

2019-08-14 12:38:22 ERROR rasa.core.processor - Encountered an exception while running action 'action_custom'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.

Command or request that led to error :

i ran rasa interactive mode and called action_custom which is supposed to send back a simple response defined by utter_message. I tried using dispatcher.utter_template.

Content of configuration file (config.yml):


pipeline: 
  - name: "WhitespaceTokenizer"
  - name: "RegexFeaturizer"
  - name: "CRFEntityExtractor"
  - name: "EntitySynonymMapper"
  - name: "CountVectorsFeaturizer"
  - name: "EmbeddingIntentClassifier"
    intent_tokenization_flag: true
    intent_split_symbol: "+"

policies:
  - name: "KerasPolicy"
    epochs: 300
    featurizer:
    - name: MaxHistoryTrackerFeaturizer
      max_history: 5
      state_featurizer:
        - name: BinarySingleStateFeaturizer
  - name: "MemoizationPolicy"
    max_history: 5
  - name: "FallbackPolicy"
    nlu_threshold: 0.4
    core_threshold: 0.3
    fallback_action_name: "action_default_fallback"

Content of domain file (domain.yml):

intents:
  - answer_contact_details
  - answer_reports
  - answer_suffer_for
  - answer_time
  - greetings
  - treatment
  - bye
  - ask_cost

slots:
  treatment_name:
    type: text
  relation:
    type: text
  treatment_type:
    type: categorical
    values:
    - modern
    - ayurveda

entities:
  - treatment_name
  - treatment_type
  - relation

actions:
- action_custom
- utter_treatment_not_available
- utter_greetings
- utter_what_treatment
- utter_howlong_suffer
- utter_ask_reports
- utter_thank_for_reports
- utter_ask_contact_details
- utter_thanks_for_contact_details
- utter_you_receive_call
- utter_time
- utter_bye
- utter_default
- utter_message

templates:
  utter_greetings:
  - text: "Hi , I am AVA.Welcome to INDHEAL."
  utter_what_treatment:
  - text: "What treatment are you looking for?"
  utter_treatment_not_available:
  - text: "sorry, this treatment isn't available"
  utter_howlong_suffer:
  - text: "could you please tell me how long the problem has persisted?"
  utter_ask_reports:
  - text: "Okay. Do you have the following reports?"
  utter_ask_contact_details:
  - text: "Could you please share your contact details?"
  utter_thanks_for_contact_details:
  - text: "Thanks for sharing your contact details."
  utter_thank_for_reports:
  - text: "Thank you for sharing the reports."
  utter_time:
  - text: "Thank you for sharing your details. When would be a comfortable time to contact you?"
  utter_you_receive_call:
  - text: "you will receive a call from us. Thank you"
  utter_bye:
  - text: "Thank you for contacting INDHEAL! We will get in touch soon."
  utter_default:
  - text: "sorry, could u please rephrase that..."
  utter_message:
  - text: "successful actions connection!"

content of endpoints.yml:

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

content of actions.py:

from __future__ import unicode_literals
from rasa_core_sdk import Action
#from rasa_sdk.action import Action
from rasa_core_sdk.events import SlotSet
#import mysql.connector

'''class ActionMessage(Action):
	def name(self):
		return "action_message"

	def run(self,dispatcher,tracker,domain):
		response="hey here is your message"
		dispatcher.utter_message(response)
		return []'''

class ActionCustom(Action):
    def name(self):
        return "action_custom"
    
    def run(self,dispatcher,tracker,domain):
        dispatcher.utter_template("utter_message",tracker)
        return []

command used to run the server: python -m rasa_core_sdk.endpoint --actions actions (i havent used "action_custom in my stories but i was trying to see if it worked in rasa interactive mode and i was getting the error above.)

output of running " rasa interactive --debug":

Could someone please help me, I don’t understand where I am going wrong. Thank you

2 Likes

@sameera looks like there was some error in your custom action. Can you post the logs of action server here? Also, can you post a small snippet of your training data to make this reproducible. Thanks

@sameera Please change your endpoints.yml file to -

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

It should work then.

yes, this is what i have in my endpoints.yml file.

1 Like

@dakshvar22 action server log:

training example:

## happy_path1
* greetings
  - utter_greetings
  - utter_what_treatment
* treatment
  - utter_howlong_suffer
* answer_suffer_for
  - utter_ask_reports
* answer_reports
  - utter_thank_for_reports
  - utter_ask_contact_details
* answer_contact_details
  - utter_thanks_for_contact_details
  - utter_time
* answer_time
  - utter_you_receive_call
* bye
  - utter_bye

## happy_path2
* treatment
  - utter_howlong_suffer
* answer_suffer_for
  - utter_ask_reports
* answer_reports
  - utter_thank_for_reports
  - utter_ask_contact_details
* answer_contact_details
  - utter_thanks_for_contact_details
  - utter_time
* answer_time
  - utter_you_receive_call
* bye
  - utter_bye
1 Like

@sameera Are you sure you have the same endpoints.yml file because the snippet you posted in the original question does not have the first line action_endpoint:

1 Like

@dakshvar22 Yes I am sure.

2 Likes

@erohmensing Could you please look into it, I am sure that my endpoint file is correct. I don’t understand where I went wrong . I would really like to have some help on how to fix this. I have a custom actions file that would utter a template “utter_message” when “action_custom” is called. I haven’t used action_custom in my stories, I tried to run it in rasa interactive mode to check if it works and I was getting the above exception. Is it possible that not having action_custom in my stories is the problem?

1 Like

I have solved the issue. Thank you

1 Like

Hi @sameera , what was the problem? It would be great if you can post the solution here so that other users can benefit from it too. Thanks

1 Like

@dakshvar22 As you saw in my files, I couldn’t find what the problem was. I have cross checked my files with others who had this issue and were able to solve it, my files looked fine so I figured it might be an internal linking issue. I created another environment with python==3.6 and rasa , created a project in rasa and re-ran the project in the new environment, it worked fine. Making sure all the dependencies are properly installed is important :slight_smile:

1 Like

@sameera Cool. Glad you could make it work.

2 Likes