Custom action not sending messgae back to rasa

i write everything and everything runs fine but when i reach a custom action in stories.yml file it wont respond, i mean without any error the bot replay empty without ant message when i have one in the custom action, what could be the problem? anyone help?

from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher

class ActionHelloWorld(Action):
     def name(self) -> Text:
         return "action_hello_world"

     def run(self, dispatcher: CollectingDispatcher,
             tracker: Tracker,
             domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        
         x= tracker.get_intent_of_latest_message("aff_or_dny")
         text1=["yes","ya","ofcourse","sounds good"]
         text2=["no", "n","not really","not sure","no"]
         if x in text1:
            dispatcher.utter_message(text="well thanks for contacting us, see you next time")
         elif x in text2:
            dispatcher.utter_message(text="well till am build enough am sorry, see you then")

         return []

Do you have any errors in the action server log?

@Faiza4265 can you check whether you have uncommented

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

in your endpoints.yml file. After uncommenting and restarting the chatbot it might work.

i did uncomment that and run the action server but when i start chatting with the bot and it reaches the custom action conversation it replayes empty, it suppose to return one function which has the reposnse from python code u see but no replay of the bot

no error, the action server runs pretty well with one function u see from the python code

this is how the conversation is

Bot loaded. Type a message and press enter (use '/stop' to exit):
Your input ->  hi
Hey! How are you?
Your input ->  are you a bot
I am a bot, powered by Rasa and being customized by Faiza.
Did that help you?
Your input ->  no
Your input -> sorry i did not understand you

and this is how the action server is running

Base: DeclarativeMeta = declarative_base()
2023-02-08 08:38:08 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
2023-02-08 08:38:08 INFO     rasa_sdk.executor  - Registered function for 'action_hello_world'.
2023-02-08 08:38:08 INFO     rasa_sdk.endpoint  - Action endpoint is up and running on http://0.0.0.0:5055

the story.ymal file

- story: faiza path
  steps:
  - intent: greet
  - action: utter_greet
  - intent: faiza_greeting
  - action: utter_iamabot
  - action: utter_did_that_help
  - intent: aff_or_dny
  - action: action_hello_world
  

and this is the action.py file, which returns an empty value of x n dont know why


from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher

class ActionHelloWorld(Action):

    def name(self) -> Text:
        return "action_hello_world"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        #x= tracker.get_intent_of_latest_message("aff_or_dny")
        x= tracker.latest_message['intent'].get('aff_or_dny')
        print(x)
        text1=["yes","ya","ofcourse","sounds good"]
        text2=["no", "n","not really","not sure","no"]

        if x in text1:
           dispatcher.utter_message(text="well thanks for contacting us, see you next time")
        elif x in text2:
           dispatcher.utter_message(text="well till am build enough am sorry, see you then") 
        else:
            dispatcher.utter_message(text="sorry i did not understand you")

        return []

@Faiza4265 can you share the chatbot logs when you are executing it in the shell? Try running the chatbot with the command rasa shell --debug

look from what i encounter the value of x is not getting the value of intent , i try to print the value of x but returns none which then the if else condition replay with “sorry i dont understand” the debug file looks as follow the one u asked

(install_demo) C:\Users\Faiza Abdella\Documents\rasa_project>rasa shell --debug
C:\Anaconda\envs\install_demo\lib\site-packages\rasa\core\tracker_store.py:876: MovedIn20Warning: Deprecated API features detected! These feature(s) are not compatible with SQLAlchemy 2.0. To prevent incompatible upgrades prior to updating applications, ensure requirements files are pinned to "sqlalchemy<2.0". Set environment variable SQLALCHEMY_WARN_20=1 to show all deprecation warnings.  Set environment variable SQLALCHEMY_SILENCE_UBER_WARNING=1 to silence this message. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
  Base: DeclarativeMeta = declarative_base()
2023-02-08 11:52:12 DEBUG    h5py._conv  - Creating converter from 7 to 5
2023-02-08 11:52:12 DEBUG    h5py._conv  - Creating converter from 5 to 7
2023-02-08 11:52:12 DEBUG    h5py._conv  - Creating converter from 7 to 5
2023-02-08 11:52:12 DEBUG    h5py._conv  - Creating converter from 5 to 7
C:\Anaconda\envs\install_demo\lib\site-packages\future\standard_library\__init__.py:65: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
2023-02-08 11:52:15 DEBUG    urllib3.connectionpool  - Starting new HTTPS connection (1): api.segment.io:443
2023-02-08 11:52:17 DEBUG    urllib3.connectionpool  - https://api.segment.io:443 "POST /v1/track HTTP/1.1" 200 21
2023-02-08 11:52:17 DEBUG    rasa.cli.utils  - Parameter 'credentials' not set. Using default location 'credentials.yml' instead.
C:\Anaconda\envs\install_demo\lib\site-packages\sanic_cors\extension.py:39: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  SANIC_VERSION = LooseVersion(sanic_version)
2023-02-08 11:52:17 INFO     root  - Connecting to channel 'cmdline' which was specified by the '--connector' argument. Any other channels will be ignored. To connect to all given channels, omit the '--connector' argument.
2023-02-08 11:52:17 DEBUG    sanic.root  - Sanic-CORS: Configuring CORS with resources: {'/*': {'origins': [''], 'methods': 'DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT', 'allow_headers': ['.*'], 'expose_headers': 'filename', 'supports_credentials': True, 'max_age': None, 'send_wildcard': False, 'automatic_options': True, 'vary_header': True, 'resources': {'/*': {'origins': ''}}, 'intercept_exceptions': True, 'always_send': True}}
2023-02-08 11:52:17 DEBUG    rasa.core.utils  - Available web server routes:
/webhooks/rest                                     GET                            rasa_core_no_api.custom_webhook_CmdlineInput.health
/webhooks/rest/webhook                             POST                           rasa_core_no_api.custom_webhook_CmdlineInput.receive
/                                                  GET                            rasa_core_no_api.hello
2023-02-08 11:52:17 INFO     root  - Starting Rasa server on http://0.0.0.0:5005
2023-02-08 11:52:17 DEBUG    rasa.core.utils  - Using the default number of Sanic workers (1).
2023-02-08 11:52:18 DEBUG    urllib3.connectionpool  - Starting new HTTPS connection (1): api.segment.io:443
2023-02-08 11:52:19 DEBUG    urllib3.connectionpool  - https://api.segment.io:443 "POST /v1/track HTTP/1.1" 200 21
2023-02-08 11:52:19 DEBUG    rasa.core.tracker_store  - Connected to InMemoryTrackerStore.
2023-02-08 11:52:19 DEBUG    rasa.core.lock_store  - Connected to lock store 'InMemoryLockStore'.
2023-02-08 11:52:19 DEBUG    rasa.core.nlg.generator  - Instantiated NLG to 'TemplatedNaturalLanguageGenerator'.
2023-02-08 11:52:19 INFO     rasa.core.processor  - Loading model models\20230208-104123-violet-pixel.tar.gz...
2023-02-08 11:52:19 DEBUG    rasa.engine.storage.local_model_storage  - Extracted model to 'C:\Users\FAIZAA~1\AppData\Local\Temp\tmpvqu86p3h'.
2023-02-08 11:52:20 DEBUG    rasa.engine.graph  - Node 'nlu_message_converter' loading 'NLUMessageConverter.load' and kwargs: '{}'.
2023-02-08 11:52:20 DEBUG    rasa.engine.graph  - Node 'run_WhitespaceTokenizer0' loading 'WhitespaceTokenizer.load' and kwargs: '{}'.
2023-02-08 11:52:20 DEBUG    rasa.engine.graph  - Node 'run_RegexFeaturizer1' loading 'RegexFeaturizer.load' and kwargs: '{}'.
2023-02-08 11:52:20 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_RegexFeaturizer1' was requested for reading.
2023-02-08 11:52:20 DEBUG    rasa.engine.graph  - Node 'run_LexicalSyntacticFeaturizer2' loading 'LexicalSyntacticFeaturizer.load' and kwargs: '{}'.
2023-02-08 11:52:20 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_LexicalSyntacticFeaturizer2' was requested for reading.
2023-02-08 11:52:20 DEBUG    rasa.engine.graph  - Node 'run_CountVectorsFeaturizer3' loading 'CountVectorsFeaturizer.load' and kwargs: '{}'.
2023-02-08 11:52:20 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_CountVectorsFeaturizer3' was requested for reading.
2023-02-08 11:52:20 DEBUG    rasa.engine.graph  - Node 'run_CountVectorsFeaturizer4' loading 'CountVectorsFeaturizer.load' and kwargs: '{}'.
2023-02-08 11:52:20 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_CountVectorsFeaturizer4' was requested for reading.
2023-02-08 11:52:20 DEBUG    rasa.engine.graph  - Node 'run_DIETClassifier5' loading 'DIETClassifier.load' and kwargs: '{}'.
2023-02-08 11:52:20 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_DIETClassifier5' was requested for reading.
2023-02-08 11:52:20 DEBUG    rasa.utils.tensorflow.models  - Loading the model from C:\Users\FAIZAA~1\AppData\Local\Temp\tmpsytl6m1l\train_DIETClassifier5\DIETClassifier.tf_model with finetune_mode=False...
2023-02-08 11:52:20 DEBUG    rasa.nlu.classifiers.diet_classifier  - You specified 'DIET' to train entities, but no entities are present in the training data. Skipping training of entities.
2023-02-08 11:52:20 DEBUG    rasa.nlu.classifiers.diet_classifier  - Following metrics will be logged during training:
2023-02-08 11:52:20 DEBUG    rasa.nlu.classifiers.diet_classifier  -   t_loss (total loss)
2023-02-08 11:52:20 DEBUG    rasa.nlu.classifiers.diet_classifier  -   i_acc (intent acc)
2023-02-08 11:52:20 DEBUG    rasa.nlu.classifiers.diet_classifier  -   i_loss (intent loss)
2023-02-08 11:52:30 DEBUG    rasa.utils.tensorflow.models  - Finished loading the model.
2023-02-08 11:52:30 DEBUG    rasa.engine.graph  - Node 'run_EntitySynonymMapper6' loading 'EntitySynonymMapper.load' and kwargs: '{}'.
2023-02-08 11:52:30 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_EntitySynonymMapper6' was requested for reading.
2023-02-08 11:52:30 DEBUG    rasa.nlu.extractors.entity_synonyms  - Failed to load ABCMeta from model storage. Resource 'train_EntitySynonymMapper6' doesn't exist.
2023-02-08 11:52:30 DEBUG    rasa.engine.graph  - Node 'run_ResponseSelector7' loading 'ResponseSelector.load' and kwargs: '{}'.
2023-02-08 11:52:30 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_ResponseSelector7' was requested for reading.
2023-02-08 11:52:30 DEBUG    rasa.nlu.classifiers.diet_classifier  - Failed to load ABCMeta from model storage. Resource 'train_ResponseSelector7' doesn't exist.
2023-02-08 11:52:30 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_ResponseSelector7' was requested for reading.
2023-02-08 11:52:30 DEBUG    rasa.nlu.selectors.response_selector  - Failed to load ResponseSelector from model storage. Resource 'train_ResponseSelector7' doesn't exist.
2023-02-08 11:52:30 DEBUG    rasa.engine.graph  - Node 'run_FallbackClassifier8' loading 'FallbackClassifier.load' and kwargs: '{}'.
2023-02-08 11:52:30 DEBUG    rasa.engine.graph  - Node 'run_RegexMessageHandler' loading 'RegexMessageHandler.load' and kwargs: '{}'.
2023-02-08 11:52:30 DEBUG    rasa.engine.graph  - Node 'domain_provider' loading 'DomainProvider.load' and kwargs: '{}'.
2023-02-08 11:52:30 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'domain_provider' was requested for reading.
2023-02-08 11:52:30 DEBUG    rasa.engine.graph  - Node 'run_MemoizationPolicy0' loading 'MemoizationPolicy.load' and kwargs: '{}'.
2023-02-08 11:52:30 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_MemoizationPolicy0' was requested for reading.
2023-02-08 11:52:30 DEBUG    rasa.engine.graph  - Node 'run_RulePolicy1' loading 'RulePolicy.load' and kwargs: '{}'.
2023-02-08 11:52:30 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_RulePolicy1' was requested for reading.
2023-02-08 11:52:30 DEBUG    rasa.engine.graph  - Node 'run_UnexpecTEDIntentPolicy2' loading 'UnexpecTEDIntentPolicy.load' and kwargs: '{}'.
2023-02-08 11:52:30 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_UnexpecTEDIntentPolicy2' was requested for reading.
2023-02-08 11:52:30 DEBUG    rasa.utils.tensorflow.models  - Loading the model from C:\Users\FAIZAA~1\AppData\Local\Temp\tmpsytl6m1l\train_UnexpecTEDIntentPolicy2\unexpected_intent_policy.tf_model with finetune_mode=False...
C:\Anaconda\envs\install_demo\lib\site-packages\tensorflow\python\framework\indexed_slices.py:444: UserWarning: Converting sparse IndexedSlices(IndexedSlices(indices=Tensor("gradients/cond_grad/Identity_1:0", shape=(None,), dtype=int64), values=Tensor("gradients/cond_grad/Identity:0", shape=(None,), dtype=float32), dense_shape=Tensor("gradients/cond_grad/Identity_2:0", shape=(1,), dtype=int32))) to a dense Tensor of unknown shape. This may consume a large amount of memory.
  warnings.warn(
C:\Anaconda\envs\install_demo\lib\site-packages\tensorflow\python\framework\indexed_slices.py:444: UserWarning: Converting sparse IndexedSlices(IndexedSlices(indices=Tensor("gradients/cond_1_grad/Identity_1:0", shape=(None,), dtype=int64), values=Tensor("gradients/cond_1_grad/Identity:0", shape=(None,), dtype=float32), dense_shape=Tensor("gradients/cond_1_grad/Identity_2:0", shape=(1,), dtype=int32))) to a dense Tensor of unknown shape. This may consume a large amount of memory.
  warnings.warn(
2023-02-08 11:52:40 DEBUG    rasa.utils.tensorflow.models  - Finished loading the model.
2023-02-08 11:52:40 WARNING  rasa.shared.utils.common  - The UnexpecTED Intent Policy is currently experimental and might change or be removed in the future 🔬 Please share your feedback on it in the forum (https://forum.rasa.com) to help us make this feature ready for production.
2023-02-08 11:52:40 DEBUG    rasa.engine.graph  - Node 'run_TEDPolicy3' loading 'TEDPolicy.load' and kwargs: '{}'.
2023-02-08 11:52:40 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_TEDPolicy3' was requested for reading.
2023-02-08 11:52:40 DEBUG    rasa.utils.tensorflow.models  - Loading the model from C:\Users\FAIZAA~1\AppData\Local\Temp\tmpsytl6m1l\train_TEDPolicy3\ted_policy.tf_model with finetune_mode=False...
2023-02-08 11:52:50 DEBUG    rasa.utils.tensorflow.models  - Finished loading the model.
2023-02-08 11:52:50 DEBUG    rasa.engine.graph  - Node 'rule_only_data_provider' loading 'RuleOnlyDataProvider.load' and kwargs: '{}'.
2023-02-08 11:52:50 DEBUG    rasa.engine.storage.local_model_storage  - Resource 'train_RulePolicy1' was requested for reading.
2023-02-08 11:52:50 DEBUG    rasa.engine.graph  - Node 'select_prediction' loading 'DefaultPolicyPredictionEnsemble.load' and kwargs: '{}'.
2023-02-08 11:52:50 INFO     root  - Rasa server is up and running.
2023-02-08 11:52:50 INFO     root  - Enabling coroutine debugging. Loop id 1804572994816.
Bot loaded. Type a message and press enter (use '/stop' to exit):
Your input ->

the action server prints x value as none

C:\Anaconda\envs\install_demo\lib\site-packages\sanic_cors\extension.py:39: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  SANIC_VERSION = LooseVersion(sanic_version)
2023-02-08 11:44:52 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
2023-02-08 11:44:52 INFO     rasa_sdk.executor  - Registered function for 'action_hello_world'.
2023-02-08 11:44:52 INFO     rasa_sdk.endpoint  - Action endpoint is up and running on http://0.0.0.0:5055
None

@Faiza4265 this none means that your custom action is working. There seems to be an issue in your python logic.

yes and the issue is the x variable, i couldnt get the value of an intent using traker.latest_message, it gives me this

C:\Anaconda\envs\install_demo\lib\site-packages\sanic_cors\extension.py:39: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  SANIC_VERSION = LooseVersion(sanic_version)
2023-02-08 12:28:41 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
2023-02-08 12:28:41 INFO     rasa_sdk.executor  - Registered function for 'action_hello_world'.
2023-02-08 12:28:41 INFO     rasa_sdk.endpoint  - Action endpoint is up and running on http://0.0.0.0:5055
{'intent': {'name': 'aff_or_dny', 'confidence': 0.9999998807907104}, 'entities': [], 'text': 'no', 'message_id': '686c4edc600149779fffe2f2b80755f8', 'metadata': {}, 'text_tokens': [[0, 2]], 'intent_ranking': [{'name': 'aff_or_dny', 'confidence': 0.9999998807907104}, {'name': 'bot_challenge', 'confidence': 1.249477037390534e-07}, {'name': 'greet', 'confidence': 2.669148813083666e-08}, {'name': 'mood_unhappy', 'confidence': 1.886784417592935e-08}, {'name': 'goodbye', 'confidence': 8.427863740223529e-09}, {'name': 'mood_great', 'confidence': 1.6625885390642026e-10}], 'response_selector': {'all_retrieval_intents': [], 'default': {'response': {'responses': None, 'confidence': 0.0, 'intent_response_key': None, 'utter_action': 'utter_None'}, 'ranking': []}}}

is there a way i can access the text part and put it in x variable in action.py file?

problem solved. anyone who is facing to get the value of intent of latest message of user input in custom action you can use

x=tracker.latest_message.get('text')
1 Like