-
Notifications
You must be signed in to change notification settings - Fork 330
Using Rasa UI as Middleware
Paul Aschmann edited this page Mar 27, 2018
·
6 revisions
Using Rasa UI as a middleware layer to call the Rasa NLU server can provide some benefits, like logging, intent enrichment and metrics.
As mentioned in the readme, instead of calling Rasa NLU directly e.g. http://localhost:5000/parse?q=hello%20there rather call: http://localhost:5001/api/v2/rasa/parse?q=hello%20there
In order to use Rasa UI in this scenario, you would need to first get a Authorization token by following the steps:
- Open Rasa UI and the agent, take note of the Agent name, and the secret key
- Use a tool like postman to do a POST to: http://localhost:5001/api/v2/authclient with x-www-form-urlencoded agent_name: Agent Name, and client_secret_key: xxx as your body. This should return a bearer token.
- Include this token with all subsequent calls to the parse URL as a Authorization header (e.g. Bearer oi1u290us9218)
Example request using Node.js + Request:
var request = require("request");
var options = { method: 'POST',
url: 'http://localhost:5001/api/v2/rasa/parse',
headers:
{ 'Postman-Token': 'fc7b3022-70c4-bdf8-5eff-425c0d7b55b1',
'Cache-Control': 'no-cache',
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MjA0Nzk3NjJ9.nSCzx1V-bS_S77G8uICZgFJub_5q4sukByiq6f_sgY4',
'Content-Type': 'application/json' },
body:
{ q: 'resturants in new york',
project: 'Dining Out',
model: 'model_20180307-131724' },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});