How to call Rasa 1.0 via RESTful API?

Hi,

I just checked out the latest Rasa 1.0 and trained with the test training data came with the repo. But the Rasa 1.0 doesn’t recognize the following conversations URI which does work in pre-1.0 release.

$ python -m rasa run -m ./models --endpoints ./projects/endpoints.yml --port 5001 --log-file ./logs/rasa.log -vv /apps/ml-engine/local/lib/python3.6/dist-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters 2019-05-21 17:10:57 DEBUG rasa.model - Extracted model to ‘/tmp/tmpwqlgizmw’. No chat connector configured, falling back to the REST input channel. To connect your bot to another channel, read the docs here: https://rasa.com/docs/rasa/user-guide/messaging-and-voice-channels 2019-05-21 17:10:57 DEBUG rasa.core.utils - Available web server routes: /webhooks/rest GET custom_webhook_RestInput.health /webhooks/rest/webhook POST custom_webhook_RestInput.receive 2019-05-21 17:10:57 INFO root - Starting Rasa Core server on http://localhost:5001 2019-05-21 17:10:57 INFO root - Enabling coroutine debugging. Loop id 87280088. 2019-05-21 17:10:57 DEBUG rasa.model - Extracted model to ‘/tmp/tmptx7h5etk’. 2019-05-21 17:11:10 INFO rasa.nlu.components - Added ‘SpacyNLP’ to component cache. Key ‘SpacyNLP-en’. 2019-05-21 17:11:10 DEBUG rasa.model - Extracted model to ‘/tmp/tmp9eo6pm6z’. [2019-05-21 17:11:11 -0700] [15928] [ERROR] Exception occurred while handling uri: ‘http://zeus-OMG-164.dev.pfops.com/conversations/default/respond’ Traceback (most recent call last): File “/apps/ml-engine/local/lib/python3.6/dist-packages/sanic-19.3.1-py3.6.egg/sanic/app.py”, line 893, in handle_request handler, args, kwargs, uri = self.router.get(request) File “/apps/ml-engine/local/lib/python3.6/dist-packages/sanic-19.3.1-py3.6.egg/sanic/router.py”, line 407, in get return self._get(request.path, request.method, “”) File “/apps/ml-engine/local/lib/python3.6/dist-packages/sanic-19.3.1-py3.6.egg/sanic/router.py”, line 469, in _get raise NotFound(“Requested URL {} not found”.format(url)) sanic.exceptions.NotFound: Requested URL /conversations/default/respond not found [2019-05-21 20:17:43 -0700] [15928] [ERROR] Exception occurred while handling uri: ‘http://zeus-OMG-164.dev.pfops.com/conversations/default/respond’ Traceback (most recent call last): File “/apps/ml-engine/local/lib/python3.6/dist-packages/sanic-19.3.1-py3.6.egg/sanic/app.py”, line 893, in handle_request handler, args, kwargs, uri = self.router.get(request) File “/apps/ml-engine/local/lib/python3.6/dist-packages/sanic-19.3.1-py3.6.egg/sanic/router.py”, line 407, in get return self._get(request.path, request.method, “”) File “/apps/ml-engine/local/lib/python3.6/dist-packages/sanic-19.3.1-py3.6.egg/sanic/router.py”, line 469, in _get raise NotFound(“Requested URL {} not found”.format(url)) sanic.exceptions.NotFound: Requested URL /conversations/default/respond not found

Has the conversations endpoint changed in Rasa 1.0? If yes, what are the valid endpoints in 1.0?

Please help Thanks

Hi! All of the server endpoints are documented here https://rasa.com/docs/rasa/api/http-api

look at the ‘Tracker’ section. hope that helps!

Hi Alan,

Thanks for pointing me to the documentation of the new endpoints. But it doesn’t work in a quick test as below. Did I miss something on the configuration?

$ python -m rasa run -m ./models --endpoints ./projects/endpoints.yml --port 5001 --log-file ./logs/rasa.log -vv /apps/ml-engine/local/lib/python3.6/dist-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters 2019-05-22 08:28:12 DEBUG rasa.model - Extracted model to ‘/tmp/tmpxfhp17so’. No chat connector configured, falling back to the REST input channel. To connect your bot to another channel, read the docs here: https://rasa.com/docs/rasa/user-guide/messaging-and-voice-channels 2019-05-22 08:28:12 DEBUG rasa.core.utils - Available web server routes: /webhooks/rest GET custom_webhook_RestInput.health /webhooks/rest/webhook POST custom_webhook_RestInput.receive 2019-05-22 08:28:12 INFO root - Starting Rasa Core server on http://localhost:5001 2019-05-22 08:28:12 INFO root - Enabling coroutine debugging. Loop id 88728536. 2019-05-22 08:28:12 DEBUG rasa.model - Extracted model to ‘/tmp/tmp2hqhoemh’. 2019-05-22 08:28:26 INFO rasa.nlu.components - Added ‘SpacyNLP’ to component cache. Key ‘SpacyNLP-en’. 2019-05-22 08:28:26 DEBUG rasa.model - Extracted model to ‘/tmp/tmpxjlmqubc’. [2019-05-22 08:29:50 -0700] [16795] [ERROR] Exception occurred while handling uri: ‘http://zeus-OMG-164.dev.pfops.com/model/parse’ Traceback (most recent call last): File “/apps/ml-engine/local/lib/python3.6/dist-packages/sanic-19.3.1-py3.6.egg/sanic/app.py”, line 893, in handle_request handler, args, kwargs, uri = self.router.get(request) File “/apps/ml-engine/local/lib/python3.6/dist-packages/sanic-19.3.1-py3.6.egg/sanic/router.py”, line 407, in get return self._get(request.path, request.method, “”) File “/apps/ml-engine/local/lib/python3.6/dist-packages/sanic-19.3.1-py3.6.egg/sanic/router.py”, line 469, in _get raise NotFound(“Requested URL {} not found”.format(url)) sanic.exceptions.NotFound: Requested URL /model/parse not found

I guess, you need to enable the API via the parameter --enable-api. Can you please try the following:

python -m rasa run -m ./models --endpoints ./projects/endpoints.yml --port 5001 --log-file ./logs/rasa.log -vv --enable-api

If you do not enable the API, the server does not know about any of the endpoint mentioned here https://rasa.com/docs/rasa/api/http-api.

1 Like

Also encountered the “Error: Requested URL /conversations/xxx/tracker not found” when I try to tracker conversations using http-api. I am using rasa docker with docker-compose, and it works with suggestion of @Tanja My docker-compose.yml is like,

     rasa:
        image: rasa/rasa:1.0.1-full
        ports:
          - 5005:5005
        volumes:
          - ./rasa_app:/app
        command:
          - run
          - --enable-api

Continuing the discussion from How to call Rasa 1.0 via RESTful API?:

I can get the response back now. But Rasa 1.0 server doesn’t show any of such activity on console log (see below). I used to see the activity in debug mode when running pre-1.0 release. Please let me know how to show all activities on 1.0 console.

$ python -m rasa run -m ./models --endpoints ./projects/endpoints.yml --enable-api --port 5001 -vv /apps/ml-engine/local/lib/python3.6/dist-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters 2019-05-23 10:05:20 DEBUG rasa.model - Extracted model to ‘/tmp/tmp9yy0clgy’. No chat connector configured, falling back to the REST input channel. To connect your bot to another channel, read the docs here: https://rasa.com/docs/rasa/user-guide/messaging-and-voice-channels 2019-05-23 10:05:21 DEBUG rasa.core.utils - Available web server routes: /conversations/<conversation_id>/messages POST add_message /conversations/<conversation_id>/tracker/events POST append_event /webhooks/rest GET custom_webhook_RestInput.health /webhooks/rest/webhook POST custom_webhook_RestInput.receive /model/test/intents POST evaluate_intents /model/test/stories POST evaluate_stories /conversations/<conversation_id>/execute POST execute_action /domain GET get_domain / GET hello /model PUT load_model /model/parse POST parse /conversations/<conversation_id>/predict POST predict /conversations/<conversation_id>/tracker/events PUT replace_events /conversations/<conversation_id>/story GET retrieve_story /conversations/<conversation_id>/tracker GET retrieve_tracker /status GET status /model/predict POST tracker_predict /model/train POST train /model DELETE unload_model /version GET version 2019-05-23 10:05:21 INFO root - Starting Rasa Core server on http://localhost:5001 2019-05-23 10:05:21 INFO root - Enabling coroutine debugging. Loop id 77009080. 2019-05-23 10:05:21 DEBUG rasa.model - Extracted model to ‘/tmp/tmp9jx4onap’. 2019-05-23 10:05:36 INFO rasa.nlu.components - Added ‘SpacyNLP’ to component cache. Key ‘SpacyNLP-en’. 2019-05-23 10:05:36 DEBUG rasa.model - Extracted model to ‘/tmp/tmpgaj9ivqc’.

Here’s my curl command:

$ curl http://localhost:5001/model/parse -d ‘{“text”:“I want to grab lunch”}’

{“intent”:{“name”:“restaurant_search”,“confidence”:0.7300545989},“entities”:[],“intent_ranking”:[{“name”:“restaurant_search”,“confidence”:0.7300545989},{“name”:“goodbye”,“confidence”:0.133238208},{“name”:“greet”,“confidence”:0.0733681635},{“name”:“affirm”,“confidence”:0.0633390296}],“text”:“I want to grab lunch”}

Summary

This text will be hidden

The /model/parse API in 1.0 only predicts the intent. But I’d like to pass user message to an API and return the utterance including the execution of action if applicable. What’s 1.0 API equivalent to /conversations/default/respond API in pre-1.0 release?

Thanks

Hi jhsu,

You could solve your problem by using the argument --credentials and joining a credential file as the following :

# This file contains the credentials for the voice & chat platforms
# which your bot is using.
# https://rasa.com/docs/rasa/user-guide/messaging-and-voice-channels/

rest:
#  # you don't need to provide anything here - this channel doesn't
#  # require any credentials

You can then as the previous version of rasa use the rest API :

localhost:5005/webhooks/rest/webhook

and POST a json file as follow :

{
	"message":"goodbye",
	"sender": "default"
}
1 Like

Hi asokolow,

It’s not working for me. Did I miss something? Really appreciate your help.

$ curl http://localhost:5001/model/parse -d ‘{“message”:“goodbye”,“sender”,“default”}’

{“version”:“1.0.0”,“status”:“failure”,“message”:“An unexpected error occurred. Error: Failed when parsing body as json”,“reason”:“ParsingError”,“details”:{},“help”:null,“code”:500}

Here’s the console error:

2019-05-24 07:27:00 DEBUG rasa.server - Traceback (most recent call last): File “/apps/ml-engine/local/lib/python3.6/dist-packages/sanic-19.3.1-py3.6.egg/sanic/request.py”, line 149, in load_json self.parsed_json = loads(self.body) ValueError: No ‘:’ found when decoding object value

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “/apps/ml-engine/rasa/rasa/server.py”, line 773, in parse data = emulator.normalise_request_json(request.json) File “/apps/ml-engine/local/lib/python3.6/dist-packages/sanic-19.3.1-py3.6.egg/sanic/request.py”, line 143, in json self.load_json() File “/apps/ml-engine/local/lib/python3.6/dist-packages/sanic-19.3.1-py3.6.egg/sanic/request.py”, line 153, in load_json raise InvalidUsage(“Failed when parsing body as json”) sanic.exceptions.InvalidUsage: Failed when parsing body as json

hey @jhsu the error is due to the the request body of the above api make sure you are passing the request body in JSON format for you reference:

Be carefull it will call the NLU only and the NLU is working with the format ‘{“text”:“hello”}’

if you want the complet pipeline (nlu + core), you will have to use the rest/webhook path mentioned by @JiteshGaikwad

I got 404.

$ curl http://localhost:5005/webhooks/rest/webhook -d ‘{“sender”:“default”,“message”:“goodbye”}’

404 Not Found

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

Here’s the action server console log:

$ python -m rasa run actions --actions actions -p 5005 -vv

/apps/ml-engine/local/lib/python3.6/dist-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.

from ._conv import register_converters as _register_converters

2019-05-24 10:27:01 INFO rasa_sdk.endpoint - Starting action endpoint server…

2019-05-24 10:27:01 INFO rasa_sdk.executor - Registered function for ‘action_search_restaurants’.

2019-05-24 10:27:01 INFO rasa_sdk.executor - Registered function for ‘action_suggest’.

2019-05-24 10:27:01 INFO rasa_sdk.endpoint - Action endpoint is up and running. on (‘0.0.0.0’, 5005)

127.0.0.1 - - [2019-05-24 10:27:17] “POST /webhooks/rest/webhook HTTP/1.1” 404 342 0.003160

I figured out where my problem is. I was calling wrong server. I should still call the Core server instead of action server. Here’s a good test which returns utterance.

$ curl http://localhost:5001/webhooks/rest/webhook -d ‘{“sender”:“default”,“message”:“I want to grab lunch”}’

[{“recipient_id”:“default”,“text”:“how can I help you?”}]

And here’s the Core console output. Thanks everyone for helping me. You guys are awesome.

2019-05-24 10:40:49 DEBUG rasa.core.agent - Created a new lock for conversation ‘default’

2019-05-24 10:40:49 DEBUG rasa.core.tracker_store - Recreating tracker for id ‘default’

2019-05-24 10:40:49 DEBUG rasa.core.processor - Received user message ‘I want to grab lunch’ with intent ‘{‘name’: ‘I want to grab lunch’, ‘confidence’: 1.0}’ and entities ‘[]’

2019-05-24 10:40:49 DEBUG rasa.core.processor - Logged UserUtterance - tracker now has 2 events

2019-05-24 10:40:49 DEBUG rasa.core.featurizers - Feature ‘intent_I want to grab lunch’ (value: ‘1.0’) could not be found in feature map. Make sure you added all intents and entities to the domain

2019-05-24 10:40:49 DEBUG rasa.core.policies.memoization - Current tracker state [None, None, None, {}, {‘intent_I want to grab lunch’: 1.0, ‘prev_action_listen’: 1.0}]

2019-05-24 10:40:49 DEBUG rasa.core.policies.memoization - There is no memorised next action

2019-05-24 10:40:49 DEBUG rasa.core.policies.ensemble - Predicted next action using policy_0_RestaurantPolicy

2019-05-24 10:40:49 DEBUG rasa.core.processor - Predicted next action ‘utter_ask_howcanhelp’ with confidence 0.16.

2019-05-24 10:40:49 DEBUG rasa.core.processor - Action ‘utter_ask_howcanhelp’ ended with events ‘[‘BotUttered(text: how can I help you?, data: {“elements”: null, “quick_replies”: null, “buttons”: null, “attachment”: null, “image”: null, “custom”: null}, metadata: {})’]’

2019-05-24 10:40:49 DEBUG rasa.core.featurizers - Feature ‘intent_I want to grab lunch’ (value: ‘1.0’) could not be found in feature map. Make sure you added all intents and entities to the domain

2019-05-24 10:40:49 DEBUG rasa.core.featurizers - Feature ‘intent_I want to grab lunch’ (value: ‘1.0’) could not be found in feature map. Make sure you added all intents and entities to the domain

2019-05-24 10:40:49 DEBUG rasa.core.policies.memoization - Current tracker state [None, None, {}, {‘intent_I want to grab lunch’: 1.0, ‘prev_action_listen’: 1.0}, {‘intent_I want to grab lunch’: 1.0, ‘prev_utter_ask_howcanhelp’: 1.0}]

2019-05-24 10:40:49 DEBUG rasa.core.policies.memoization - There is no memorised next action

2019-05-24 10:40:49 DEBUG rasa.core.policies.mapping_policy - There is no mapped action for the predicted intent, ‘I want to grab lunch’.

2019-05-24 10:40:49 DEBUG rasa.core.policies.ensemble - Predicted next action using policy_0_RestaurantPolicy

2019-05-24 10:40:49 DEBUG rasa.core.processor - Predicted next action ‘action_listen’ with confidence 0.58.

2019-05-24 10:40:49 DEBUG rasa.core.processor - Action ‘action_listen’ ended with events ‘[]’

2019-05-24 10:40:49 DEBUG rasa.core.agent - Deleted lock for conversation ‘default’ (unused)

Sorry, more question.

I’m testing the restaurant_search intent came with the 1.0 repo. The bot doesn’t seem to understand the location and keeps asking me “where?”. Is this restaurant_search test data complete and ready for testing, or it’s just incomplete sample pieces to show how the bot works? Thanks

$ curl http://localhost:5001/webhooks/rest/webhook -d ‘{“sender”:“default”,“message”:“I am looking a restaurant in 29432”}’

[{“recipient_id”:“default”,“text”:“I’m on it”},{“recipient_id”:“default”,“text”:“what kind of cuisine would you like?”}]

$ curl http://localhost:5001/webhooks/rest/webhook -d ‘{“sender”:“default”,“message”:“chinese”}’

[{“recipient_id”:“default”,“text”:“I’m on it”},{“recipient_id”:“default”,“text”:“where?”}]

$ curl http://localhost:5001/webhooks/rest/webhook -d ‘{“sender”:“default”,“message”:“in 90210”}’

[{“recipient_id”:“default”,“text”:“I’m on it”},{“recipient_id”:“default”,“text”:“where?”}]

$ curl http://localhost:5001/webhooks/rest/webhook -d ‘{“sender”:“default”,“message”:“in San Francisco”}’

[{“recipient_id”:“default”,“text”:“I’m on it”},{“recipient_id”:“default”,“text”:“where?”}]

$ curl http://localhost:5001/webhooks/rest/webhook -d ‘{“sender”:“default”,“message”:“in the north of town”}’

[{“recipient_id”:“default”,“text”:“I’m on it”},{“recipient_id”:“default”,“text”:“where?”}]

$ curl http://localhost:5001/webhooks/rest/webhook -d ‘{“sender”:“default”,“message”:“in 29432”}’

[{“recipient_id”:“default”,“text”:“I’m on it”},{“recipient_id”:“default”,“text”:“where?”}]

Hi,

I still think something is not right when testing Rasa 1.0 with test data from the repo. In following example, the bot doesn’t interpret intent correctly. Instead of “restaurant_search” intent, the bot interprets it as “I am searching for a dinner spot” intent which of course doesn’t exist.

Here’s the demo-rasa.md came with 1.0 repo:

intent:restaurant_search

  • i’m looking for a place to eat
  • I want to grab lunch
  • I am searching for a dinner spot (skip the rest)

Shouldn’t bot interpret this user message “I am searching for a dinner spot” as “restaurant_search” intent? Has anyone tested 1.0 with demo data from repo successfully? I need to see the successful test case using data out of the 1.0 release before I’d start creating my own training data. Please help.

Here’s the Core console log:

2019-05-24 17:36:07 DEBUG rasa.core.agent - Created a new lock for conversation ‘default’

2019-05-24 17:36:07 DEBUG rasa.core.tracker_store - Recreating tracker for id ‘default’

2019-05-24 17:36:07 DEBUG rasa.core.processor - Received user message ‘I am searching for a dinner spot’ with intent ‘{‘name’: ‘I am searching for a dinner spot’, ‘confidence’: 1.0}’ and entities ‘[]’

2019-05-24 17:36:07 DEBUG rasa.core.processor - Logged UserUtterance - tracker now has 6 events

2019-05-24 17:36:07 DEBUG rasa.core.featurizers - Feature ‘intent_I am looking a restaurant in 29432’ (value: ‘1.0’) could not be found in feature map. Make sure you added all intents and entities to the domain

2019-05-24 17:36:07 DEBUG rasa.core.featurizers - Feature ‘intent_I am looking a restaurant in 29432’ (value: ‘1.0’) could not be found in feature map. Make sure you added all intents and entities to the domain

2019-05-24 17:36:07 DEBUG rasa.core.featurizers - Feature ‘intent_I am searching for a dinner spot’ (value: ‘1.0’) could not be found in feature map. Make sure you added all intents and entities to the domain

2019-05-24 17:36:07 DEBUG rasa.core.policies.memoization - Current tracker state [None, {}, {‘prev_action_listen’: 1.0, ‘intent_I am looking a restaurant in 29432’: 1.0}, {‘prev_utter_ask_howcanhelp’: 1.0, ‘intent_I am looking a restaurant in 29432’: 1.0}, {‘prev_action_listen’: 1.0, ‘intent_I am searching for a dinner spot’: 1.0}]

2019-05-24 17:36:07 DEBUG rasa.core.policies.memoization - There is no memorised next action

2019-05-24 17:36:07 DEBUG rasa.core.policies.ensemble - Predicted next action using policy_0_RestaurantPolicy

2019-05-24 17:36:07 DEBUG rasa.core.processor - Predicted next action ‘utter_on_it’ with confidence 0.65.

Finally figured out my problem. In Rasa 1.0, I need to train both NLU and Core together instead of separately as in pre-1.0. Once I train both together, it does interpret correct intent. Please mention such tips in your 1.0 documentation.

2 Likes

Can anyone confirm if this is really the case that you MUST train the NLU & Core together? This is a big change and I don’t find any documentation regarding this.

(post withdrawn by author, will be automatically deleted in 8 hours unless flagged)

1 Like

I have the same issue. did any one got it solved

@athenasaurav you can use ngrok for port forwarding such that it generate a global link which can be accessed then you can hit http://********.ngrok.io/webhooks/rest/webhook for responce