Correctly Called Rasa NLU API in Command line and PostMan

Ellery Leung
Jan 15 · 3 min read
/root/my_project/rasa/
├── actions
│ ├── confirm_add_to_cart.py
│ └── recommendation.py
├── components
│ ├── __init__.py
│ └── stanford
│ ├── com_stanford_nlp.py
│ ├── __init__.py
├── config
├── log
│ ├── nlu_response
│ ├── rasa_core.log
│ ├── RasaNLU.log
│ ├── server.log
│ ├── stanford_nlp.log
├── models
│ ├── current
│ │ └── nlu
│ │ ├── checkpoint
│ │ ├── intent_classifier_tensorflow_embedding.ckpt.data-00000-of-00001
│ │ ├── intent_classifier_tensorflow_embedding.ckpt.index
│ │ ├── intent_classifier_tensorflow_embedding.ckpt.meta
│ │ ├── intent_classifier_tensorflow_embedding_encoded_all_intents.pkl
│ │ ├── intent_classifier_tensorflow_embedding_inv_intent_dict.pkl
│ │ ├── intent_featurizer_count_vectors.pkl
│ │ ├── metadata.json
│ │ └── training_data.json
│ ├── dialogue
│ │ ├── domain.json
│ │ ├── domain.yml
│ │ ├── policy_0_KerasPolicy
│ │ │ ├── featurizer.json
│ │ │ ├── keras_model.h5
│ │ │ └── keras_policy.json
│ │ └── policy_metadata.json
│ └── model_config_for_server.yml
├── project
│ ├── config_rasa_nlu_stanford.yml
│ ├── config_rasa_nlu_tf.yml
│ ├── credentials.yml
│ ├── data_nlu.md
│ ├── domain.yml
│ ├── endpoints.yml
│ ├── stories.md
│ └── training_policy.yml
├── RasaActionServer.log
├── rasa_core.log
├── startActionServer.sh
└── startNLU.sh
python3.6 \
-m rasa_nlu.server \
--port 5002 \
--write log/nlu_write.log \
--pre_load ["current"] \
--path models \
--response_log log/nlu_response \
-c project/config_rasa_nlu_tf.yml \
--cors * \
--token my_secret_token \
--debug \
--verbose

Points to note:

curl \
-X POST \
-H "Content-Type: application/json; charset=utf-8" \
http://192.168.0.1:5002/parse?token=my_secret_token \
--data '{"q": "hello", "model": "nlu", "project": "current"}' \
| python -m json.tool

Points to note:

How to do the same thing in Postman?

#1: When you append ?token=my_secret_token, in “Params” it will automatically add this line
#2 Set the header, It is also OK to use “Accept-Charset”
#3: The data part. I use “raw” and type the JSON string here. Using “form-data” and “x-www-form-urlencoded” did not work.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade