Getting Bot's Response back as JSON?

Is there a way to get the bot’s response back from the running Rasa Bot server as JSON?

I’m currently hitting the /model/parse endpoint with a POST request, but, as the docs say: “[/model/parse]…[p]redicts the intent and entities of the message posted to this endpoint. No messages will be stored to a conversation and no action will be run. This will just retrieve the NLU parse results.”

[source: Rasa Documentation ]

I suppose I’m looking for whatever it is that replaced the /parse endpoint from the last version of Rasa, before that endpoint was (apparently) deprecated. I tried checking the migration guide, but—again—no luck!

This is the response I’m currently getting, so everything looks fine:

{
“intent”:{
“name”:“greet”, “confidence”:0.9426363707 }, “entities”:[

], “intent_ranking”:[
{
“name”:“greet”, “confidence”:0.9426363707 }, {
“name”:“affirm”, “confidence”:0.0766754672 }, {
“name”:“mood_unhappy”, “confidence”:0.0 }, {
“name”:“mood_great”, “confidence”:0.0 }, {
“name”:“deny”, “confidence”:0.0 }, {
“name”:“goodbye”, “confidence”:0.0 } ], “text”:“hello” }

This is my request code:

app.get(‘/endpoint’, () => { var payload = { ‘text’: ‘hello’ }

request.post( { url: ‘http://localhost:5005/model/parse’, form: JSON.stringify(payload), headers: { “Content-Type”: “application/json”, } }, function (err, httpResponse, body) { console.log(Body: ${body}); } ); })

This is the command I’m using to start the Rasa bot server:

rasa run -m models --enable-api --log-file out.log

^^^ (It’s from the tutorial…)

I’ve tried the solutions mentioned in these links:

But most of these are outdated, and I’m getting errors about deprecation. I’m currently going through the other API endpoints, like the Tracker ones, but still no luck.

Any help would be greatly appreciated, thanks! Apologies if I haven’t provided enough background, I’m new here. Thanks again!

Best,

Martin

P.S. - In the Rasa shell, everything is working fine as well.

Hey @mepc36, can you try this steps:

Rest api implementation

Thank you SO much Jitesh, you’re a life-saver!

Really great article, I hope they pin it on a “FAQ” board somewhere for Rasa stack!

Re-posting it here to show my appreciation…I also tweeted it out!! Really can’t thank you enough, you’re the best.

Best, -Martin

1 Like

Hey @mepc36 thanks I am glad that it solved your issue :grinning_face_with_smiling_eyes:

1 Like