Closed samarth12 closed 5 years ago
Hi @samarth12,
You are using an endpoint for your actions without specifying an endpoint config. Try creating an endpoints.yml
as in this part of the docs and passing it with the first command using --endpoints endpoints.yml
Hello @MetcalfeTom,
Thanks for pointing that out, I missed passing my action endpoints. But sadly it still doesn't solve the problem, it gives me a 404 while I run it using the following command and again it is working perfectly fine on the local cmdline.
python -m rasa_core.run -d models/dialogue -u models/nlu/default/current --port 5001 --credentials credentials.yml --endpoints endpoints.yml
Here is endpoints.yml
action_endpoint:
url: "http://localhost:5055/webhook/"
I get a "POST /webhook/ HTTP/1.1" 404 342 0.000529" on my action endpoint server. Below is the error I get when I make a post call through POSTMAN which should technically make an API call to run the action.
2018-12-27 02:29:47 ERROR rasa_core.actions.action - Failed to run custom action 'action_weather'. Action server responded with a non 200 status code of 404. Make sure your action server properly runs actions and returns a 200 once the action is executed. Error: 404 Client Error: NOT FOUND for url: http://localhost:5055/webhook/
2018-12-27 02:29:47 ERROR rasa_core.processor - Encountered an exception while running action 'action_weather'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.
127.0.0.1 - - [2018-12-27 02:29:47] "POST /webhooks/rest/webhook HTTP/1.1" 200 110 0.209247
This is the same error I get for my other action as well.
OK well we're one step closer!
Could you also try adding the --enable_api
flag to the rasa_core.run
command as in the docs here
Okay so I followed up and used the --enable_api
flag. I tried using the same command with my endpoints as in the docs and then I also tried adding the flag to the command I have been using for the RestInput. Here are the two commands I used
python -m rasa_core.r-enable_api -d models/dialogue -u models/nlu/default/current -o out.log --endpoints endpoints.yml
python -m rasa_core.run -d models/dialogue -u models/nlu/default/current --port 5001 --credentials credentials.yml --endpoints endpoints.yml --enable_api
When I try a POST on http://localhost:5002/webhooks/rest/webhook, I am again able to receive a response for the basic "greet" intent which doesn't use a custom action for the response. But I get the same error as before whenever it has to use a custom action. This is the same error I get for both the command above
2018-12-27 13:36:53 ERROR rasa_core.actions.action - Failed to run custom action 'wolfram_alpha'. Action server responded with a non 200 status code of 404. Make sure your action server properly runs actions and returns a 200 once the action is executed. Error: 404 Client Error: NOT FOUND for url: http://localhost:5055/webhook/
2018-12-27 13:36:53 ERROR rasa_core.processor - Encountered an exception while running action 'wolfram_alpha'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.
127.0.0.1 - - [2018-12-27 13:36:53] "POST /webhooks/rest/webhook HTTP/1.1" 200 142 0.061674
I am not sure why this is happening. Thank you @MetcalfeTom for being so responsive!
Could you post your logs from the action server? Since you are able to get responses then it narrows down the problem. Are you importing from rasa_core_sdk
in your actions.py
and not from rasa_core
?
Yes, I am importing from rasa_core_sdk
. I will post my logs below with all the possible details I can provide you.
Actions SDK just returns a 404 error whenever the APIs need to be called, the thing I do not get is that works perfectly fine on the cmd line.
INFO:__main__:Starting action endpoint server...
INFO:rasa_core_sdk.executor:Registered function for 'action_weather'.
INFO:rasa_core_sdk.executor:Registered function for 'wolfram_alpha'.
INFO:__main__:Action endpoint is up and running. on ('0.0.0.0', 5055)
127.0.0.1 - - [2019-01-01 12:00:27] "POST /webhook/ HTTP/1.1" 404 342 0.009915
127.0.0.1 - - [2019-01-01 12:00:53] "POST /webhook/ HTTP/1.1" 404 342 0.001687
Here are my localhost logs, this is the error Error: 404 Client Error: NOT FOUND for url: http://localhost:5055/webhook/
2019-01-01 12:00:27 ERROR rasa_core.actions.action - Failed to run custom action 'action_weather'. Action server responded with a non 200 status code of 404. Make sure your action server properly runs actions and returns a 200 once the action is executed. Error: 404 Client Error: NOT FOUND for url: http://localhost:5055/webhook/
2019-01-01 12:00:27 ERROR rasa_core.processor - Encountered an exception while running action 'action_weather'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.
127.0.0.1 - - [2019-01-01 12:00:27] "POST /webhooks/rest/webhook HTTP/1.1" 200 142 0.077290
2019-01-01 12:00:53 WARNING py.warnings - /anaconda3/lib/python3.6/site-packages/sklearn/preprocessing/label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.
if diff:
2019-01-01 12:00:53 ERROR rasa_core.actions.action - Failed to run custom action 'wolfram_alpha'. Action server responded with a non 200 status code of 404. Make sure your action server properly runs actions and returns a 200 once the action is executed. Error: 404 Client Error: NOT FOUND for url: http://localhost:5055/webhook/
2019-01-01 12:00:53 ERROR rasa_core.processor - Encountered an exception while running action 'wolfram_alpha'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.
127.0.0.1 - - [2019-01-01 12:00:53] "POST /webhooks/rest/webhook HTTP/1.1" 200 142 0.073290
You can see I tried calling both the APIs and get the same error. Also if I didn’t mention before, everything other than API calls is returning a response on postman as it should.
Here are more detailed logs. My first input is: “Hello my name is Mark”. I get a response back, my next input is: “Who is the president of US?” where it should call the Wolfram API. The same thing happens with weather API if I change my input to: “What is the weather in London?”
2019-01-01 12:18:44 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):
2019-01-01 12:18:57 DEBUG rasa_core.tracker_store - Creating a new tracker for id 'Rasa'.
2019-01-01 12:18:57 WARNING py.warnings - /anaconda3/lib/python3.6/site-packages/sklearn/preprocessing/label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.
if diff:
2019-01-01 12:18:57 DEBUG rasa_core.processor - Received user message 'Hello my name is Mark' with intent '{'name': 'greet', 'confidence': 0.5992243649211548}' and entities '[{'start': 17, 'end': 21, 'value': 'mark', 'entity': 'PERSON', 'confidence': 0.6440988744205052, 'extractor': 'ner_crf'}]'
2019-01-01 12:18:57 DEBUG rasa_core.processor - Logged UserUtterance - tracker now has 3 events
2019-01-01 12:18:57 DEBUG rasa_core.processor - Current slot values:
PERSON: mark
location: None
2019-01-01 12:18:57 DEBUG rasa_core.policies.memoization - Current tracker state [None, None, None, {}, {'entity_PERSON': 1.0, 'prev_action_listen': 1.0, 'intent_greet': 1.0, 'slot_PERSON_0': 1.0}]
2019-01-01 12:18:57 DEBUG rasa_core.policies.memoization - There is no memorised next action
2019-01-01 12:18:57 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_1_KerasPolicy
2019-01-01 12:18:57 DEBUG rasa_core.processor - Predicted next action 'utter_greet' with prob 0.30.
2019-01-01 12:18:57 DEBUG rasa_core.processor - Action 'utter_greet' ended with events '[]'
2019-01-01 12:18:57 DEBUG rasa_core.processor - Bot utterance 'BotUttered(text: Hello mark! How can I help?, data: {
"elements": null,
"buttons": null,
"attachment": null
})'
2019-01-01 12:18:57 DEBUG rasa_core.policies.memoization - Current tracker state [None, None, {}, {'entity_PERSON': 1.0, 'prev_action_listen': 1.0, 'intent_greet': 1.0, 'slot_PERSON_0': 1.0}, {'prev_utter_greet': 1.0, 'entity_PERSON': 1.0, 'intent_greet': 1.0, 'slot_PERSON_0': 1.0}]
2019-01-01 12:18:57 DEBUG rasa_core.policies.memoization - There is no memorised next action
2019-01-01 12:18:57 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_1_KerasPolicy
2019-01-01 12:18:57 DEBUG rasa_core.processor - Predicted next action 'action_listen' with prob 0.87.
2019-01-01 12:18:57 DEBUG rasa_core.processor - Action 'action_listen' ended with events '[]'
127.0.0.1 - - [2019-01-01 12:18:57] "POST /webhooks/rest/webhook HTTP/1.1" 200 203 0.257879
2019-01-01 12:19:51 DEBUG rasa_core.tracker_store - Recreating tracker for id 'Rasa'
2019-01-01 12:19:52 WARNING py.warnings - /anaconda3/lib/python3.6/site-packages/sklearn/preprocessing/label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.
if diff:
2019-01-01 12:19:52 DEBUG rasa_core.processor - Received user message 'Who is the president of US' with intent '{'name': 'information', 'confidence': 0.6909834200535575}' and entities '[]'
2019-01-01 12:19:52 DEBUG rasa_core.processor - Logged UserUtterance - tracker now has 7 events
2019-01-01 12:19:52 DEBUG rasa_core.processor - Current slot values:
PERSON: mark
location: None
2019-01-01 12:19:52 DEBUG rasa_core.policies.memoization - Current tracker state [None, {}, {'entity_PERSON': 1.0, 'prev_action_listen': 1.0, 'intent_greet': 1.0, 'slot_PERSON_0': 1.0}, {'prev_utter_greet': 1.0, 'entity_PERSON': 1.0, 'intent_greet': 1.0, 'slot_PERSON_0': 1.0}, {'intent_information': 1.0, 'prev_action_listen': 1.0, 'slot_PERSON_0': 1.0}]
2019-01-01 12:19:52 DEBUG rasa_core.policies.memoization - There is no memorised next action
2019-01-01 12:19:52 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_1_KerasPolicy
2019-01-01 12:19:52 DEBUG rasa_core.processor - Predicted next action 'wolfram_alpha' with prob 0.70.
2019-01-01 12:19:52 DEBUG rasa_core.actions.action - Calling action endpoint to run action 'wolfram_alpha'.
2019-01-01 12:19:52 ERROR rasa_core.actions.action - Failed to run custom action 'wolfram_alpha'. Action server responded with a non 200 status code of 404. Make sure your action server properly runs actions and returns a 200 once the action is executed. Error: 404 Client Error: NOT FOUND for url: http://localhost:5055/webhook/
2019-01-01 12:19:52 ERROR rasa_core.processor - Encountered an exception while running action 'wolfram_alpha'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.
2019-01-01 12:19:52 DEBUG rasa_core.processor - Failed to execute custom action.
Traceback (most recent call last):
File "/anaconda3/lib/python3.6/site-packages/rasa_core/actions/action.py", line 338, in run
response.raise_for_status()
File "/anaconda3/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: NOT FOUND for url: http://localhost:5055/webhook/
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/anaconda3/lib/python3.6/site-packages/rasa_core/processor.py", line 351, in _run_action
events = action.run(dispatcher, tracker, self.domain)
File "/anaconda3/lib/python3.6/site-packages/rasa_core/actions/action.py", line 358, in run
raise Exception("Failed to execute custom action.")
Exception: Failed to execute custom action.
2019-01-01 12:19:52 DEBUG rasa_core.processor - Action 'wolfram_alpha' ended with events '[]'
2019-01-01 12:19:52 DEBUG rasa_core.policies.memoization - Current tracker state [{}, {'entity_PERSON': 1.0, 'prev_action_listen': 1.0, 'intent_greet': 1.0, 'slot_PERSON_0': 1.0}, {'prev_utter_greet': 1.0, 'entity_PERSON': 1.0, 'intent_greet': 1.0, 'slot_PERSON_0': 1.0}, {'intent_information': 1.0, 'prev_action_listen': 1.0, 'slot_PERSON_0': 1.0}, {'intent_information': 1.0, 'prev_wolfram_alpha': 1.0, 'slot_PERSON_0': 1.0}]
2019-01-01 12:19:52 DEBUG rasa_core.policies.memoization - There is no memorised next action
2019-01-01 12:19:52 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_1_KerasPolicy
2019-01-01 12:19:52 DEBUG rasa_core.processor - Predicted next action 'action_listen' with prob 0.98.
2019-01-01 12:19:52 DEBUG rasa_core.processor - Action 'action_listen' ended with events '[]'
127.0.0.1 - - [2019-01-01 12:19:52] "POST /webhooks/rest/webhook HTTP/1.1" 200 142 0.094410
And I will also attach my custom actions file, it just making two API calls.
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet
class ActionWeather(Action):
def name(self):
return 'action_weather'
def run(self, dispatcher, tracker, domain):
from apixu.client import ApixuClient
api_key = '#your apixu key '
client = ApixuClient(api_key)
loc = tracker.get_slot('location')
current = client.getCurrentWeather(q=loc)
country = current['location']['country']
city = current['location']['name']
condition = current['current']['condition']['text']
temperature_c = current['current']['temp_c']
humidity = current['current']['humidity']
wind_mph = current['current']['wind_mph']
response = """It is currently {} in {} at the moment. The temperature is {} degrees, the humidity is {}% and the wind speed is {} mph.""".format(condition, city, temperature_c, humidity, wind_mph)
dispatcher.utter_message(response)
return [SlotSet('location',loc)]
class Wolfram(Action):
def name(self):
return 'wolfram_alpha'
def run(self, dispatcher, tracker, domain):
import wolframalpha
app_id = "wolfram_key"
input = tracker.latest_message["text"]
print(input)
client = wolframalpha.Client(app_id)
res = client.query(input)
answer = next(res.results).text
response = answer
dispatcher.utter_message(response)
return
Hi @samarth12, thanks for posting all this info.
I took your code, reproduced the bot and ran it with a REST input. It worked fine, which is unfortunate because it means I am no closer to resolving the issue.
Do you have any proxies set up on your machine or anything which might be interfering with your network traffic? I'd also like to see if your bot could run a custom action which didn't include another API call in it.
@MetcalfeTom I finally figured out the problem I was running into! It was very stupid and needed another eye to look into my errors. My endpoints.yml
file was redirecting towards url: "http://localhost:5055/webhook/"
which works fine with the cmd line. But apparently, the REST input calls to url: "http://localhost:5055/webhook"
.
Notice the "/" after webhook. But you might want to make that more generic by not allowing the cmd line actions to call to the actions server with a "/" at the end to avoid future confusion.
Thanks for all your help! Appreciate it!