Bot freezes after running custom action, does not respond

Hello I’m trying to get the bot to run this very simple custom action,

from typing import Any, Text, Dict, List

from rasa_sdk import Action, Tracker

from rasa_sdk.executor import CollectingDispatcher

class Math(Action):

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

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
    
    mathVar = (tracker.latest_message)['text']
    mathVar = ''.join(char for char in mathVar if char not in 'abcdefghijklmnopqrstuvwxyz')
    mathVarCalculate = eval(mathVar)
    dispatcher.utter_message(mathVarCalculate)

from what i can tell the action itself is executed as i should but when the bot is supposed to say the answer through dispatcher.utter_message it say nothing keeps working for a while and then gives me this error message,

Task exception was never retrieved

future: <Task finished coro=<RestInput.on_message_wrapper() done, defined at /Users/filipw/Documents/ConvoAi/anaconda3/lib/python3.7/site-packages/rasa/core/channels/channel.py:386> exception=AttributeError("‘int’ object has no attribute ‘split’")>

Does anyone know why?

Hi @ZwodoPaZ

please add:

return []

at the end of the run function and see if it works then!

Regards

Thanks! I tried but still the same problem sadly

If i run the bot in debug mode it seems to believe that it has said something.

Action ‘action_math’ ended with events ‘[‘BotUttered(text: 13, data: {“elements”: null, “quick_replies”: null, “buttons”: null, “attachment”: null, “image”: null, “custom”: null}, metadata: {})’]’

But it has not said a word.

I solved it!! The uttered message has to be a string

Hi @ZwodoPaZ

of course sigh. I should have actually read the error message :smiley:

Regards