Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rest api throws 404 error while running custom actions #4179

Closed
swamat opened this issue Aug 6, 2019 · 6 comments
Closed

Rest api throws 404 error while running custom actions #4179

swamat opened this issue Aug 6, 2019 · 6 comments
Labels
type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@swamat
Copy link

swamat commented Aug 6, 2019

Rasa version:1.2.0

Rasa X version (if used & relevant):

Python version:3.7

Operating system (windows, osx, ...):windows 10

Issue: Rest api throws 404 error while running custom actions
While running the custom actions server using rasa run actions
I am getting below error

Error (including full traceback):

c:\programdata\anaconda3\lib\site-packages\rasa_core_sdk\__init__.py:12: UserWarning: The 'rasa_core_sdk' package has been renamed. You should change your imports to use 'rasa_sdk' instead.
  UserWarning,
2019-08-06 15:00:21 INFO     rasa_sdk.executor  - Registered function for 'action_weather'.
2019-08-06 15:00:21 INFO     rasa_sdk.endpoint  - Action endpoint is up and running. on ('0.0.0.0', 5055)
127.0.0.1 - - [2019-08-06 15:00:50] "POST /webhook/ HTTP/1.1" 404 341 0.001992

Command or request that led to error:

In a new terminal gave the command **rasa shell --endpoints endpoints.yml**
While calling the url it fails with 404 error
Endpoints.yml:

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

Content of configuration file (config.yml) (if relevant):

pipeline: "pretrained_embeddings_spacy"


policies:
  - name: MemoizationPolicy
  - name: KerasPolicy
    epochs: 200

Content of domain file (domain.yml) (if relevant):

---
actions:
- action_weather
- utter_ask_location
- utter_goodbye
- utter_greet
entities:
- location
intents:
- inform
- greet
- goodbye
slots:
  location:
    type: text
templates:
  utter_ask_location:
  - text: In what location?
  utter_goodbye:
  - text: Talk to you later.
  - text: Bye bye :(
  utter_greet:
  - text: Hello! How can I help?

Please help in resolving this issue.

@swamat swamat added the type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors. label Aug 6, 2019
@sara-tagger
Copy link
Collaborator

Thanks for the issue, @erohmensing will get back to you about it soon!

You may find help in the docs and the forum, too 🤗

@erohmensing
Copy link
Contributor

Can you run both rasa shell and your action server in --debug mode? That might give us some more information about what's going on. Are you running rasa on a different port than usual?

What is the request you are sending via the rest API when this happens?

@swamat
Copy link
Author

swamat commented Aug 8, 2019

@erohmensing PFB output in debug mode

2019-08-08 15:31:03 DEBUG    rasa.model  - Extracted model to 'C:\Users\GA049E~1.MAH\AppData\Local\Temp\tmphvvpxefh'.
2019-08-08 15:31:03 DEBUG    rasa.model  - Extracted model to 'C:\Users\GA049E~1.MAH\AppData\Local\Temp\tmpjnx5aet0'.
2019-08-08 15:31:05 DEBUG    sanic.root  - CORS: Configuring CORS with resources: {'/*': {'origins': [''], 'methods': 'DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT', 'allow_headers': ['.*'], 'expose_headers': None, 'supports_credentials': False, 'max_age': None, 'send_wildcard': False, 'automatic_options': True, 'vary_header': True, 'resources': {'/*': {'origins': ''}}, 'intercept_exceptions': True, 'always_send': True}}
2019-08-08 15:31:05 DEBUG    rasa.core.utils  - Available web server routes:
/webhooks/rest                                     GET                            custom_webhook_CmdlineInput.health
/webhooks/rest/webhook                             POST                           custom_webhook_CmdlineInput.receive
/                                                  GET                            hello
2019-08-08 15:31:05 INFO     root  - Starting Rasa server on http://localhost:5005
2019-08-08 15:31:05 INFO     root  - Enabling coroutine debugging. Loop id 1585529495680.
2019-08-08 15:31:05 DEBUG    rasa.model  - Extracted model to 'C:\Users\GA049E~1.MAH\AppData\Local\Temp\tmpl2oeoaiy'.
2019-08-08 15:31:06 INFO     rasa.nlu.components  - Added 'SpacyNLP' to component cache. Key 'SpacyNLP-en'.
2019-08-08 15:31:06 DEBUG    rasa.core.tracker_store  - Connected to InMemoryTrackerStore.
2019-08-08 15:31:06 DEBUG    rasa.model  - Extracted model to 'C:\Users\GA049E~1.MAH\AppData\Local\Temp\tmpn9g867dh'.
2019-08-08 15:31:06 DEBUG    pykwalify.compat  - Using yaml library: c:\programdata\anaconda3\lib\site-packages\ruamel\yaml\__init__.py
Bot loaded. Type a message and press enter (use '/stop' to exit):
Your input ->  what's the tempearture in paris
2019-08-08 15:31:23 DEBUG    rasa.core.agent  - Created a new lock for conversation 'default'
2019-08-08 15:31:23 DEBUG    rasa.core.tracker_store  - Creating a new tracker for id 'default'.
2019-08-08 15:31:23 DEBUG    rasa.core.processor  - Received user message 'what's the tempearture in paris' with intent '{'name': 'inform', 'confidence': 0.9324595779908065}' and entities '[{'start': 26, 'end': 31, 'value': 'paris', 'entity': 'location', 'confidence': 0.8682732815159189, 'extractor': 'CRFEntityExtractor'}]'
2019-08-08 15:31:23 DEBUG    rasa.core.processor  - Current slot values:
        location: paris
2019-08-08 15:31:23 DEBUG    rasa.core.processor  - Logged UserUtterance - tracker now has 3 events
2019-08-08 15:31:23 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, None, None, {}, {'entity_location': 1.0, 'intent_inform': 1.0, 'prev_action_listen': 1.0, 'slot_location_0': 1.0}]
2019-08-08 15:31:23 DEBUG    rasa.core.policies.memoization  - There is no memorised next action
2019-08-08 15:31:23 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_1_KerasPolicy
2019-08-08 15:31:23 DEBUG    rasa.core.processor  - Predicted next action 'action_weather' with confidence 0.32.
2019-08-08 15:31:23 DEBUG    rasa.core.actions.action  - Calling action endpoint to run action 'action_weather'.
2019-08-08 15:31:23 DEBUG    rasa.utils.endpoints  - The URL 'http://localhost:5055/webhook/' has a trailing slash. Please make sure the target server supports trailing slashes for this endpoint.
2019-08-08 15:31:24 ERROR    rasa.core.processor  - Encountered an exception while running action 'action_weather'. Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.
2019-08-08 15:31:24 DEBUG    rasa.core.processor  - Failed to execute custom action.
Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\site-packages\rasa\core\actions\action.py", line 399, in run
    json=json_body, method="post", timeout=DEFAULT_REQUEST_TIMEOUT
  File "c:\programdata\anaconda3\lib\site-packages\rasa\utils\endpoints.py", line 148, in request
    resp.status, resp.reason, await resp.content.read()
rasa.utils.endpoints.ClientResponseError: 404, NOT FOUND, body='b'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n<title>404 Not Found</title>\n<h1>Not Found</h1>\n<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>\n''

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\site-packages\rasa\core\processor.py", line 446, in _run_action
    events = await action.run(output_channel, nlg, tracker, self.domain)
  File "c:\programdata\anaconda3\lib\site-packages\rasa\core\actions\action.py", line 421, in run
    raise Exception("Failed to execute custom action.") from e
Exception: Failed to execute custom action.
2019-08-08 15:31:24 DEBUG    rasa.core.processor  - Action 'action_weather' ended with events '[]'
2019-08-08 15:31:24 DEBUG    rasa.core.processor  - Current slot values:
        location: paris
2019-08-08 15:31:24 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, None, {}, {'entity_location': 1.0, 'intent_inform': 1.0, 'prev_action_listen': 1.0, 'slot_location_0': 1.0}, {'entity_location': 1.0, 'intent_inform': 1.0, 'prev_action_weather': 1.0, 'slot_location_0': 1.0}]
2019-08-08 15:31:24 DEBUG    rasa.core.policies.memoization  - There is no memorised next action
2019-08-08 15:31:24 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_1_KerasPolicy
2019-08-08 15:31:24 DEBUG    rasa.core.processor  - Predicted next action 'action_listen' with confidence 0.79.
2019-08-08 15:31:24 DEBUG    rasa.core.processor  - Action 'action_listen' ended with events '[]'
2019-08-08 15:31:24 DEBUG    rasa.core.agent  - Deleted lock for conversation 'default' (unused)

@erohmensing
Copy link
Contributor

And the debug logs of your action server?

@swamat
Copy link
Author

swamat commented Aug 9, 2019

@erohmensing I removed the '/' after webhook in endpoints.yml
action_endpoint:
url: "http://localhost:5055/webhook"

After the change i am getting below error from actions:
(base) C:\Users\g.a.mahalingam\Documents\weather>rasa run actions --debug
2019-08-09 11:27:26 INFO rasa_sdk.endpoint - Starting action endpoint server...
c:\programdata\anaconda3\lib\site-packages\rasa_core_sdk_init_.py:12: UserWarning: The 'rasa_core_sdk' package has been renamed. You should change your imports to use 'rasa_sdk' instead.
UserWarning,
2019-08-09 11:27:26 INFO rasa_sdk.executor - Registered function for 'action_weather'.
2019-08-09 11:27:26 INFO rasa_sdk.endpoint - Action endpoint is up and running. on ('0.0.0.0', 5055)
2019-08-09 11:27:46 WARNING rasa_sdk.endpoint - Your versions of rasa and rasa_sdk might not be compatible. You are currently running rasa version 1.2.0 and rasa_sdk version 1.1.1.
To ensure compatibility use the same version for both, modulo the last number, i.e. using version A.B.x the numbers A and B should be identical for both rasa and rasa_sdk.
2019-08-09 11:27:46 DEBUG rasa_sdk.executor - Received request to run 'action_weather'
2019-08-09 11:27:46 ERROR rasa_sdk.endpoint - Exception on /webhook [POST]
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\site-packages\flask\app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "c:\programdata\anaconda3\lib\site-packages\flask\app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "c:\programdata\anaconda3\lib\site-packages\flask_cors\extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "c:\programdata\anaconda3\lib\site-packages\flask\app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "c:\programdata\anaconda3\lib\site-packages\flask_compat.py", line 39, in reraise
raise value
File "c:\programdata\anaconda3\lib\site-packages\flask\app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "c:\programdata\anaconda3\lib\site-packages\flask\app.py", line 1935, in dispatch_request
return self.view_functionsrule.endpoint
File "c:\programdata\anaconda3\lib\site-packages\flask_cors\decorator.py", line 128, in wrapped_function
resp = make_response(f(*args, **kwargs))
File "c:\programdata\anaconda3\lib\site-packages\rasa_sdk\endpoint.py", line 59, in webhook
response = executor.run(action_call)
File "c:\programdata\anaconda3\lib\site-packages\rasa_sdk\executor.py", line 254, in run
events = action(dispatcher, tracker, domain)
File "C:\Users\g.a.mahalingam\Documents\weather\actions.py", line 18, in run
current = client.getcurrent(q=loc)
AttributeError: 'ApixuClient' object has no attribute 'getcurrent'
127.0.0.1 - - [2019-08-09 11:27:46] "POST /webhook HTTP/1.1" 500 411 0.016955

@swamat
Copy link
Author

swamat commented Aug 9, 2019

@erohmensing Changed actions.py to use client.current instead of client.getcurrent. It is working fine now. Thanks

@swamat swamat closed this as completed Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

No branches or pull requests

3 participants