Where Can I give Entities in Amazon Lex ? Is Slot the other name for entity mentioned in Amazon Lex? - amazon-web-services

Every Bot works on NLP. So, Intent and Entities are must to create a bot. I found Intents in the Amazon Lex. but i didnt find entities. Slot is the other name for entity? Can anyone explain me what is intent and entity in detail with Lex?

Following explanation may help you understand the concepts Intent and Entity:
Intent is a task or an action a user want to perform, for example, I want to book a cab or want to order the food.
Book a cab and order the food are intents. These intents have the entities called cab(vehicle), food(pizza). Intents will tell you what user wants to do whereas entities will help you with how to do?
In Amazon lex, Slot is a section where you can mention the entity and the values for the entity.
Example:
Intent: Book a cab
This is a task a user wants to do.
Entity: Cab
Values for the entity is Micro, Mini, Prime.
You can check out this link for complete flow and more details.

Here are some helpful definitions that are used in chatbots and specifically Lex:
Dialog = the conversation between the bot and the user.
Utterance = input sent from the user to the bot.
Response = returned message from the bot to the user.
Intent = an organized group of utterances that helps the bot recognize what the user wants.
Slot = (also called "entity") a parameter within the utterance to provide more specific details to the intent.
Slot Type = an organized group of numbers, letters, words, or phrases that help the bot recognize the value to be passed as a parameter in a Slot.
Slot Value = the number, date, word, or phrase taken from the utterance and saved in a Slot.
Example:
User: I'd like to order a pizza.
The bot takes this user input and processes the utterance by comparing it with all of the intent utterances to best match the user input with the correct intent. The intent may have closely matched this utterance set up in the bot: "I want to order a {food}."
The bot recognizes the value of "pizza" within the utterance as matching a value in the Slot Type possibly named "foodTypes". The Lex bot then delivers this information to Lambda including User Input, Intent, Slots, and Slot Values.
The logic built into Lambda or other endpoint, handles the information to form a response. You should validate and parse the user input and slots yourself to improve the NLP accuracy and correct any mistakes. Then deliver a response back to Lex, which then delivers the response message to the user.
From this example, the information gathered could be this:
User Input = I'd like to order a pizza.
Intent Utterance = "I'd like to order a {food}."
Intent = pizzaOrderIntent
Slot Type = foodTypes
Slot = food
Slot Value = "pizza"

Related

Get only MQ9 messages that belong to a group "2" in C++

I am trying to use IBM MQ client 9 with C++. I would like to read only messages that has group id '2'. I have tried everything but it just does not work. Can someone assist please?
I tried to set groupId and flag to match on group.
MQGET
gmoptions.setMatchOptions(MQMO_MATCH_GROUP_ID);
MQBYTE24 bGroupId("2");
ImqBinary _groupId;
_groupId.set(bGroupId, sizeof(bGroupId));
message.setGroupId(_groupId);
q->get(message, gmoptions);
MQPUT
MQBYTE24 bGroupId("2");
ImqBinary _groupId;
_groupId.set(bGroupId, sizeof(bGroupId));
message.setGroupId(_groupId);
ImqPutMessageOptions pmo;
pmo.setOptions(MQPMO_LOGICAL_ORDER);
pmo.setRecordFields(MQPMRF_GROUP_ID);
q->put(message, pmo);
mqget should be able to get all the msgs with groupId "2" but it does not. Though it can read the msg as soon as I remove setMatchOptions.
Basically, I want to use Group Id as filter where server instance 1 will read msgs only in group1 and server instance 2 will read msgs only in group 2 and so on, instead of creating separate queues for each server instance.
May be following can help me if group id is only for batching instead of filtering though not sure how to do 'Selection using the MQSUB and MQOPEN function calls' in C++
https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.0.0/com.ibm.mq.dev.doc/q022990_.htm
Is there any C++ equivalent of MQSETMP ? I am unable to find any interface in ImqQueue or ImqObject that will let me set message property or selectionString.
I don't think you are going about this the right way.
IBM published a Java/MQ sample program to get messages in a group called GetGroup.java. You can find it here. You can use it as a model for your C++ program.
Basically, the code retrieves a message from the queue and then checks the messageFlags field if the message is part of a group.
if ((myMessage.messageFlags & CMQC.MQMF_MSG_IN_GROUP) == CMQC.MQMF_MSG_IN_GROUP)
If the message is part of the group then the code sets the matchOptions for matching on a group and retrieves all of the messages in the group.
Note: You will probably want to add logical order to the GMO options.
gmo.options |= CMQC.MQGMO_LOGICAL_ORDER;
Finally, what is this?
pmo.setRecordFields(MQPMRF_GROUP_ID);
That doesn't make any sense. You should be setting messageFlags field to MQMF_MSG_IN_GROUP.
You can use the concept of SELECTORS in IBM MQ. A message selector is a variable-length string used by an application to register its interest in only those messages that have properties that satisfy the Structured Query Language (SQL) query that the selection string represents.
A message selector is a concept that has been in the JMS specification for a long time. It
is a way of limiting the messages that are passed to an application to those that meet
certain criteria. Those criteria are based on the values of the message properties and only
the value of the message properties. It is important to understand that selection cannot be
based on any values of the message payload, only on the message property values.
In your case, the PUT application will have to put messages with populating the a certain topic string in MQMD or MQRFH2 header and using MQ Interface function calls, you should be able to pick the messages only with a certain value which in your case is GroupId value.
Below are few reference links to the concept:
https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q022990_.htm
http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/topic/com.ibm.iea.wmq_v7/wmq/7.0/MQI/iea_330_wmqv7_API_3_Selectors.pdf ==> Pdf gets downloaded
To understand Message Properties => https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_8.0.0/com.ibm.mq.dev.doc/q022920_.htm

How to create an intent with multiple slot values in its utterances in AWS Lex?

How do I create an intent which expects multiple consecutive slot values in its utterances which are set to expandable values? In the screenshot, the manufacturer model variant trio appears together in the utterances. Problem is the manufacturer and model slot types has possible two-three word values and variants could go up to five words. Lex is not able to understand the manufacturer utterances and straightaway detecting model slot type. How do I deal with this issue? Thanks.
intent utterance test chat screenshot slot data screenshot
You should greatly increase the values listed in your manufacture slotType so that it can better detect all the possibilities, especially since you need it to differentiate from the next slot.
Then also increase the variations of the intent utterances.
The error looks like the slotType is set to "Restrict to Slot values and Synonyms" so make sure you have it saved, built, and published with the setting "Expand Values" applied.
You should try to "teach" Lex as much as possible with all the expected variations of slotType values and utterances, but there will still be things that Lex will fail to catch. So I highly suggest using Lambda to parse the slot values, and sometimes the input itself so that you make sure the values are placed in the correct slots.

which slot type should I use for any data type or we say which can accept string type data in AWS lex

I have created a bot using aws-lex where I created a slot and slot-type is user defined and expand with user utterances, but this is not working as expected. This slot is not accepting all utterances we enter though test channel and re-prompting the slot question again.
Is there any way we can create a slot-type which can accept any string utterances? or any inbuilt slot-type is there which accepts all data types?
Any help would be appreciated.
If you have a requirement that you want specific type for example- Car types, then you can create your custom slot Types for example- CarTypes having values - SUV, MPV, Hatchback, etc.
Amazon currently supports various types of Slots for example,number, date, time, Airport country device etc.
But, there is nothing like string or a generic one as Amazon Slot type.
Hope this helps!
May be you can try to use the AMAZON_FIRST_NAME slot type, this kind of slot should accept almost your any-string
You can use AMAZON.AlphaNumeric, that supports alphabets, numbers and alphanumeric values
By default Amazon Lex does not have any slot type to accept any string.
However, you can create a slot without any value for the intent and uncheck the required checkbox. Then in Lambda initialization and validation hook, just grab the input of user from event['inputTranscript'] and assign that value to the slot.
Hope it helps.

How to give a specific intent response in Amazon Lex based on an earlier response?

I have an initial intent used to classify the user ie Intent1 "I Need help" with a 1 slot (Slot 1) asking "what type of user are you? " The options are "userType1", "UserType2" and UserType3".
following this, with Amazon connect I have a a GetUserInput with multiple inputs. i.e. "What do you need help with?", with lots of intents new intents e.g Intent 2 "Shoes", Intent 3 "socks" Intent 4 "sandals.
Within Intent 2, I want to give a specific text response, Based on the answer to Slot1. the intents are different?
You have to manage context of the conversation to be able to take actions based on previous responses.
https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html
Basically in the first intent, based on the slot value you have to store it in session attributes, in the next intent you will check the value and generate the response.
Do check the OrderFlowers Blueprint Lambda function and this link. Notice that once the user gives the slot value of FlowerType it sets the price as session attribute.
Hope it helps, let me know if you have further doubts

Why aren't the prompt doing the work it's supposed to achieve?

Working on a chatbot on Lex amazon, and have set Date,Time, location parameters i have set the prompt to ask when they're not supplied according to the slot type.
When i give a wrong or bad date values like sughdfusf or ice cream or such it asks for the value again , same with time but it isn't the case with location as it takes completely random values not defined in the slot type AMAZON.US_CITY .How can i fix it and why is it occurring?
Lex is thinking that sughdfusf is a city name, so it is allocating this to AMAZON.US_CITY.
You can either report this issue to amazon team and wait for them to fix it or you can use below workaround.
Untick the required checkbox from the slot
In the Lambda function, in DialogCodeHook, use some third party api to validate the city
name
Return ElicitSlot in case validation failed
Hope it helps, let me know if you have further doubts.