Display one button in entity node

Hi,

I am trying to capture user response using entity node which needs to have one option. Here I am trying to take different paths based on user response. Please let me know how to achieve this. If we cannot do it using entity node. Please suggest other options too.

Hi @baguntur,

You can make conditional transitions based on user input for the entity node.
Please refer the following link for more details:

https://developer.kore.ai/docs/bots/bot-builder-tool/dialog-task/nodes-transitions/#Component_Transitions

Regards,
Yoga Ramya.

Hi @baguntur,

I understand that you are trying to restrict user input by picking one, from the options bot displays. Depending upon the type of input you would like to make conditional transitions.

Solution:

  1. For the entity node choose type as List of items (enumerated)
  2. Enumerate the options by choosing appropriate display value, value and synonyms
  3. In the ‘Display List Of Values’ - choose ‘Yes’ radio button to show channel specific std formatting.

FYI:

https://developer.kore.ai/docs/bots/bot-builder-tool/dialog-task/entity-types/#enum

Regards,
Karthik

Hi Karthik,

Scenario - I have an entity in the dialog task. The entity value might be N/A or something else. I am trying to ask the user like :Please enter entity1 if applicable else click N/A" . I am trying to populate that N/A as a button. Based on user input I am populating a context variable. Since list type of entity at least needs to have 2 items that approach doesn’t work for us. Please suggest a way to do this.

Hi Babitha,

Okay.

Use ‘string’ as entity type and in ‘web/mobile client’ channel specific bot response put the below code in the java script section .

Hope this suffices your requirement, as user can provide any input if applicable or simply click “N/A” button if not. Also you can make conditional transition in case of ‘N/A’.

var info = [“N/A”];
var message = {
“type”: “template”,
“payload”: {
“template_type”: “button”,
“text”: “Please enter if applicable else click N/A”,
“buttons”: []
}
};
for (i = 0; i < info.length; i++) {
// if the button is to send back text to platform
var button = {
“type”: “postback”,
“title”: info[i],
“payload”: info[i]
};

message.payload.buttons.push(button);

}
print(JSON.stringify(message));

1 Like

A list entity can have just one choice - just ignore the warning :wink:
And if you want to avoid that, then set the choices up dynamically.

1 Like

Hi Karthik,

This solution only works for string type of entities. I am having a Date entity, use can enter Date or click NA if not applicable. This doesn’t work in such cases. Please suggest an alternative.

If you want an utterance that is not an entity value to be handled then define the entity as optional.
You can either use another entity to look for those NA options, or attach subintents to the first entity, or use traits to identify NA and transition from the first entity based on the presence of that trait.

You can always loop back to the first entity if you decide that you really need to have a value after all.

Hi Andy,
The user utterance is an entity value for sure and is mandatory field.The user must either enter a Date or “NA”(synonyms should apply too).This needs to be in one single entity node.

In which case, look into using an composite entity with two subentities of a date and a LoV (or custom entity with a concept as an expression).
The composite pattern should be [@dateentity @naentity] (or whatever names you use).

Thank you Andy. I am expecting only one value from the user either Date or NA. I had two entity nodes Date and NA which i have set them as hidden and then a third composite entity. I used the pattern [@Date @NA] and it doesn’t work. Please let me know if i am missing anything.

It is not quite clear from your description, but the subentity nodes should not be part of the flow.
e.g.
intent --> composite --> message

The subentities can be painted elsewhere on the flow as unconnected nodes or not. Once they have been created then that are part of the bot even if an instance of them doesn’t appear on any flow.

Hi Andy,

I tried that route but did not work. it says value i entered is not recognized.Capture

So the issue here is an input of “n/a” and how the NL engine processes it. Generally words are tokenized on punctuation elements like “/” (there are exceptions like dates 8/3/2020), which leaves “n /a”. That gets spell corrected into “n ya”, and then that gets normalized into “n you” :slight_smile:

Now there are couple of things you can do.

  1. Create a concept, say ~my_additional_words (the name is not important, but keep it distinct to avoid clashes) and add “n/a” to it. This then makes “n/a” a known word and the tokenizer and spell correction process won’t change the input.
  2. Use a different payload in the button, e.g. “not applicable” and add that to the list of synonyms on the LoV. You really need to add this, along with others, anyway because this is conversation and the user could always type/say something different and not press the button.

Andy, I only mentioned to enter “N/A”. but the value that entity accepts is “NA”. It doesn’t work.

OK, let’s walk through the steps.

The prompt for the composite entity generates a button, and when the user clicks on it, then the payload string is sent to the bot platform. All this does is save the user typing, so the same utterance can be sent if the user typed the same thing or something different.

So for the payload to be interpreted in a List of Items entity then it must exist as a synonym for a choice. You only need one choice (so ignore any warnings that bot builder might display - it is overly cautious!). Now as I described in my previous message, a payload of “n/a” doesn’t quite appear as that to the entity and how you can mitigate it. One or all of those tactics will work.

I can see on the message node that you are just trying to output context.entities.Entity0005. This is the composite entity and so this is a JSON object - all composites are objects even if only one subentity is actually identified. So you may want to expand this to context.entities.Entity0005.EnterNA, or use script to print(JSON.stringify(context.entities))

Hi Andy,

I tried out that way but the Bot still cannot recognize the value. I believe the button to be displayed is from one of sub-entities with Lov type. I don’t see a button my bot then.

No, the only purpose of the sub entities is to define the types of data to look for. Their prompts are not used.

So the prompt code to display the buttons should be on the composite entity.

Can you please post the details (i.e. values and synonyms) for the LoV subentity.

Hi Andy,

The “EnterDate” entity has type of Date, “EnterNA” enitity is Lov and name,value,synonym is “NA”

Pattern used in composite entity is [@EnterDate @EnterNA]

So if the only synonym for the LoV is “NA” then that is the only thing it will understand.
If the payload of the button is “n/a” then there will not be a match.

Therefore you need to either change the payload of the button to be something that will match one of the LoV’s synonyms, or add synonyms to the LoV to match the payload. Or both.