Agent Response guide
Issues
-
Did you download a release or pull from Master? Which release? -> downloaded 0.12.3 version
-
What operating system are you running? ->Ubuntu
-
Are you running locally or in the cloud? ->Locally
-
Which browser are you using? ->Chrome
Hi Guys ! I'm having a small trouble finishing small task using articulate. Maybe someone here will be able to help me.
So what i want to do is to ask question to articulate like.
- Are there any errors on counter1 or 2 or 3 or 4 ? Articulate connects to private Webhook API that contains this type of JSON: (In real life it contains much more counters)
[{
"counterName": "counter1",
"Result": "No Error detected",
"errors": []
}, {
"counterName": "counter2",
"Result": "No Error detected",
"errors": []
}, {
"counterName": "counter3",
"Result": "No Error detected",
"errors": []
}, {
"counterName": "counter4",
"Result": "Error detected",
"errors": ["some type of error"]
}]
My problem is that I am not so familiar with using Handlebars. Would there be anyone that could show me how would an Agent Response look like for this type of request ?
My Expectations:
User : Are there any errors on counter4 ? Bot : There are errors on counter4 and these are: "some type of error"
I am using Entities with counter names to allow articulate recognize which counter I am talking about.
Thanks in advance !
Kind Regards, Bart
@bkurowski I would look through the handlebar helpers available here: https://github.com/helpers/handlebars-helpers#array I think you're solution would be easier to accomplish if the counterName was the key for it's respective data rather than a value inside an object.
However I think you can get there with handlebar helpers and the array filter. Here's how I would try to get the correct answer.
-
Let's see what the entire web hook is returning. Remove all other agent responses on this intent and create one with
{{{JSONstringify webhookResponse}}}. That should show you the entire response. -
Remove the above response and add a new one. This time let's try to just return object in the array pertinent to counter2:
{{#filter webhookResponse "counter2" property="counterName"}}{{{JSONstringify this}}}{{/filter}}
try that and let me know if it works.
Hi @wrathagom thank you for your reply. Yes my plan is to use counterName now to find all the values I need.
-
When I have tried this
{{{JSONstringify webhookResponse}}}It gave me an output of.[{"counterName":"Counter1","Result":"No Errors detected","errors":[]},{"counterName":"Counter2","Result":"No Errors detected","errors":[]},{"counterName":"Counter3","Result":"No Errors detected","errors":[]},{"counterName":"Counter4","Result":"Errors detected","errors":["Sample Error 123"]}] -
When I have tried this
{{#filter webhookResponse "counter2" property="counterName"}}{{{JSONstringify this}}}{{/filter}}It gave me an output of.{"counterName":"counter2","Result":"No Errors detected","errors":[]}
It matches nicely, that is what i was expecting thank you.
Also would you be able to tell me how to pass on the context to the agent response just like below. In this example I am not using Text Prompt, and I am unsure how to pass context from the whole sentence the user is sending. When I am using text prompt i would use {{slots.[ENTITY].value}} not sure about full sentence, how can I pick the counter name from it and pass it on to Agent Response.
User: Are there any errors on "Counter3" ? Bot: These are errors on "Counter3"
You are a big help thank you,
Bart
When I apply {{#filter webhookResponse {{slots.Counters.value}} property="counterName"}}{{{JSONstringify this}}}{{/filter}}
It doesn't know what I am trying to pass to the agent response. I might be using wrong syntax.
I am just having a problem with building this type of syntax as it is new for me.
@bkurowski I was suggesting that you don't try to do the dynamic counter, but rather put exactly what I had provided in to see if we could pull out counter2.
If you want to try to jump straight to the dynamic counter then try this:
{{#filter webhookResponse slots.Counters.value property="counterName"}}{{{JSONstringify this}}}{{/filter}}
but again without seeing the output of the above two steps it will be hard for me to help you troubleshoot.
Oh I understand what you mean, It worked not being dynamic. I have listed the output of both of these just above. Unfortunately I can not show you screenshot with the actual data as it is confident and it does not depend on me. That is why I have pasted in the data I am "receiving" with just changed names. So it looks exactly as the original output. Visible below.
- When I have tried this {{{JSONstringify webhookResponse}}} It gave me an output of.
[{"counterName":"Counter1","Result":"No Errors detected","errors":[]},{"counterName":"Counter2","Result":"No Errors detected","errors":[]},{"counterName":"Counter3","Result":"No Errors detected","errors":[]},{"counterName":"Counter4","Result":"Errors detected","errors":["Sample Error 123"]}]
- When I have tried this {{#filter webhookResponse "counter2" property="counterName"}}{{{JSONstringify this}}}{{/filter}} It gave me an output of.
{"counterName":"counter2","Result":"No Errors detected","errors":[]}
Also to make it dynamic, I have just tried this before
{{#filter webhookResponse slots.Counters.value property="counterName"}}{{{JSONstringify this}}}{{/filter}}
It gives me an output of :
Sorry we’re not sure how to respond.
I have created my entity with several counter names so it recognizes it. And know what I am talking about.
Hope that it all makes sense. We can communicate by email if it is suitable for you so I can pass some more relative data for you.
Thanks and sorry for problems.
Bart
When you did the static counter2 did you capitalize Counter?
The name was copied exactly as it is given from JSON so it was exact as it meant to be. In my example all counters start with "pm" small letters. So i think it should not be a problem.
I'm worried that the slot.Counters.value isn't what it needs to be. Can you try a response that is just {{slots.Counters.value}} to see if it would match the JSON. Again it would have to be exact. Value gets forced to lowercase by Rasa, if you need it to be something else and an exact match you could use synonyms to format it correctly.
I have tried having only this {{slots.Counters.value}} to be agent response.
And it gave me exact counter name as I have specified in the message.
Input: Errors on counter counter2.
Output: counter2
So this works, but doesn't get passed on in this example for some reason.
{{#filter webhookResponse slots.Counters.value property="counterName"}}{{{JSONstringify this}}}{{/filter}}
I have also checked my "User Says" if i does not have any unwanted spaces. It does not contain any unwanted spaces too.
Or would this be a sign of the bot not being trained enough yet ? Maybe it needs more examples ? "User Says" ?
Thanks
Ok i have observed the problem. It gives me error as:
it doesn't know how to reply
because as you said rasa changes the whole capital letters in the name to lower case letters. So it gives me answer like that because it can not compare it and see it as it is not there.
I will test it now again and i will message you on the progress. Thank you.
okay, if that is the problem, then I would recommend using synonyms to format exactly as the data is stored. For example create the counter entity with exact values and synonyms for possible variants:
- Counter2 - counter2, Counter2, counter 2, Counter 2
- Counter3 - counter3, Counter3, counter 3, Counter 3
etc
Now i understand where the problem was. Thanks for pointing it out. Now it works dynamically using this :
{{#filter webhookResponse slots.Counters.value property="counterName"}}{{{JSONstringify this}}}{{/filter}}
The output of this looks like as follows:
{"counterName":"counter1","Result":"No Errors detected","errors":[]}
Would you be able to put me on the right tracks and tell me how can I strip out only "Result" out of that output ?
Example: User: Any errors on counter 1 ? Bot: Result
Thank you.
Try something like
On {{slots.Counters.original}} there were {{#filter webhookResponse slots.Counters.value property="counterName"}}{{this.Result}}{{/filter}}.
Since it looks like result is Title cased maybe you should do this as well:
On {{slots.Counters.original}} there were {{#filter webhookResponse slots.Counters.value property="counterName"}}{{lowercase this.Result}}{{/filter}}.
That is perfect thank you very much for your help ! Works exactly as I wanted it to work.
Kind Regards ! Bart
You're welcome. Feel free to create a new issue with any more troubles you may have.