Failed to run custom action. Action server responded with a non 200 status code of 500

I tried to execute a custom action while I got the following error message.

NotImplementedError: An action must implement its run method 2018-12-24 20:28:04 ERROR rasa_core.actions.action - Failed to run custom action ‘action_call_api’. 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 2018-12-24 20:28:04 ERROR rasa_core.processor - Encountered an exception while running action ‘action_call_api’. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code. 2018-12-24 20:28:04 DEBUG rasa_core.processor - Failed to execute custom action. Traceback (most recent call last): File “/usr/local/lib/python3.6/dist-packages/rasa_core/actions/action.py”, line 338, in run response.raise_for_status() File “/usr/local/lib/python3.6/dist-packages/requests/models.py”, line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 500 Server Error: INTERNAL SERVER ERROR for url: http://localhost:5055/webhook

My custom action is trying to extract information from the external api. The code is shown as follows:

actions.py

class ActionGetOpenAccInfo(Action):

def name(self):
    return "action_call_api"

def extract_from_json(url):  
    with urllib.request.urlopen (url) as req:
        r = req.read()
        result = json.loads(r.decode('utf-8'))
        result = result['result']['records'][0]['pa_hotline_tel']

    return

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

    url = 'https://api.xxxx.xxx/...' #external api

    required_field = 'hotline'
    result = extract_from_json(url)
    dispatcher.utter_message('the '+ required_field + ' is ' + result +'.\n')

    return

Run Command:

python3 -m rasa_core_sdk.endpoint --actions actions

python3 -m rasa_core.run --core models/dialogue --nlu models/current/nlu --debug --endpoints endpoints.yml

Found that this is just an coding error, the problem is solved.

Hi,

I am new to the RASA framework and getting a similar error. How did you solve yours?

python -m rasa_core_sdk.endpoint --actions actions (tells me action is registered) python -m rasa_core.run --enable_api -d models/dialogue -u models/nlu/default/current -o out.log --endpoints endpoints.yml (runs well till my make a call to custom action)

Error log: Rasa Core server is up and running on http://localhost:5005

Failed to run custom action ‘action_get_weather’. 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

Encountered an exception while running action ‘action_get_weather’. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.

—this is my code in actions.py– from future import absolute_import from future import division from future import print_function from future import unicode_literals

from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet

# https://pypi.org/project/weather-api/
from weather import Weather, Unit


class ActionGetWeather(Action):
    def name(self):
        return 'action_get_weather'

    def run(self, dispatcher, tracker, domain):
        weather = Weather(unit=Unit.CELSIUS)
        gpe = ('Auckland', tracker.get_slot('GPE'))[bool(tracker.get_slot('GPE'))]
        result = weather.lookup_by_location(gpe)
        if result:
            condition = result.condition
            city = result.location.city
            country = result.location.country
            dispatcher.utter_message('It\'s ' + condition.text + ' and ' + condition.temp + '°C in ' +
                                     city + ', ' + country + '.')
        else:
            dispatcher.utter_message('We did not find any weather information for ' + gpe + '. Search by a city name.')
        return

Problem solved. Thanks

Can you please tell us how did you solve it? I am encountering the same problem…

Can you please tell us how did you solve it? I am encountering the same problem…

python3 -m rasa_core_sdk.endpoint --actions actions

python3 -m rasa_core.run --core models/dialogue --nlu models/current/nlu --debug --endpoints endpoints.yml

These two commands should do the job for you. The main issue was with the weather api in the custom actions code. When you take that out everything works fine. Try to read on the yahoo weather api to get more info about how to use it. I think you need authentication details.

yes , me too facing same problem

i tried this command : python3 -m rasa_core_sdk.endpoint --actions actions . but i got an error . error i atached below … i am running the code in jupyter notebook