How to connect RASA NLP to our web application

Hi, I have created one RASA NLU. I need to call this NLU from one of my web application How can i do that?

Previously I used LUIS as an NLP engine, For that we have APPID and APPSECRET. We configured those two in my web application. So that i can communicate with the LUIS. In a same way How can i connect RASA NLU to my web application?

1 Like

This could help you

hey @sunil210568 you run this command

python -m rasa_nlu.server --path projects --cors “*”

and then you can call the api using this command

localhost:5000/parse?project=my_project&model=model_XXXXXX

Hi @JiteshGaikwad so --path project should be the path to my nlu model right? and when you say my_project and model=XX what do you mean

@JiteshGaikwad So I ran my bot nlu on AWS server and rasn with python -m rasa_nlu.server --path ./models/deafult/nlu(my path) and then what should wrte in postman? http//:my_ip:5000/parse?.. how can i check the nlu is running or not?

@Akshit Try:

localhost:5000/parse?q=<query>&project=<projectname>&model=<modelname>

localhost:5000/parse?q=hi&project=default&model=nlu

2 Likes

it’s working now! Thanks @Kavita can you help me with 1 more thing! it’s kinda related to running bot on another server.

Will try.

So I have uploaded my Bot on an AWS server and i’m making API call from my local pc with amazon IP. Now i’m running rasa_core.run --enable_api -d models/dialogue -u models/deafult/nlu --endpoints endpoints.yml. And i’m getting the results in my postman based on the queries I pass.

So Now i’m posting request like this…

http://my-amazon-ip:5005/conversations/56/respond?query=“Hi”..and getting a response like:

[ { “recipient_id”: “56”, “text”: “Hi! How can I help you?” }]

so I’m getting the answer, But Now i want to send something with question as well. Like an user_id or maybe company_id. So how should i take that value and save it in rasa. for eg, if someone is giving me a get request of respond and passing Query along with some other parameters so how should I save this parameter in rasa? as a tracker or maybe a variable?

Does RASA recognise the ID as an entity? If it does you can try access the output dictionary and save the value you need

from rasa_nlu.model import Interpreter
interpreter = Interpreter.load("<model path>")

message = "hi"
result = interpreter.parse(message)

you can try this if it may help.

which Id? i passed this:

http://my_ip:5005/conversations/56/respond?query=“hi”&user_id=27&company_id=16

and i’m getting this in console:

[2018-12-13 07:44:32] “GET /conversations/56/respond?query=%22hi%22&user_id=27&company_id=16 HTTP/1.1” 200 173 0.144330

Company ID or User ID you want to save.

Do you want to parse something like : “get me the details of <company_id>” ???

I’m passing user_id and company _id along with the query in the get request. I want to save this user_id and company_id to my rasa_bot memory. How can i do that/

try this if using markdown to train your model:

## intent:name
- My name is [Juste](name)  <!--- Square brackets contain the value of entity while the text in parentheses is a label of the entity -->
- I am [Josh](name)

And if using Json:

{
      "text": "Give me the details of Customer 1324654",
      "intent": "<Details>",
      "entities": [
        {
          "entity": "<UserID or CustomerID>",
          "startPos": 33,
          "endPos": 40
        }
      ]
    }

Give a few examples of the ID like this. Rasa will start understanding it as an entity then.

https://rasahq.github.io/rasa-nlu-trainer/

GUI Trainer for RASA

hey @Akshit as far as what i can understand from your statement, i think you want to make a log of each user’s request and response along with their id, so you can use Tracker Stores

1 Like

hey @Akshit another thing just to notify you, the api call which you are making

http://my-amazon-ip:5005/conversations/56/respond?query=“Hi”

is deprecated, try running the new api usig rest channel by provding the credentials.yml file :

credentials.yml file : credenitails

and run the api by using the following command :

python -m rasa_core.run --enable_api -d models/dialogue -u models/nlu --cors “*” -o out.log --endpoints endpoints.yml --credentials credentials.yml

and then you test it in postman: http://localhost:5005/webhooks/rest/webhook

query parameters(body):

{ “sender”: “user123”, “message”: “hi” }

Hope this helps !! :wink:

1 Like

Hey, @JiteshGaikwad Can you please tell me how to make a call to rasa_nlu server. I only want intents and their confidence levels and the entities. Don’t need a reply back.

hey @Kavita you can run the nlu server using the command :

python -m rasa_nlu.server -c nlu_config.yml --path projects/

i had stored my model in default folder

and i am making the api call to my nlu server using :

http://localhost:5000/parse?q=hello&amp;project=default&amp;model=nlu

i hope this helps you !!! :slight_smile: