How to setup keyword detection matching for intents in Lex? - amazon-web-services

I want my bot to match the intent Help whenever user types /help followed by anything. eg /help i am unable to switch on laptop.
Here, the latter part can be anything, of any length.
I have given two slots - keyword and query.
In keyword slot I have given '/help' and for query slot I gave many random examples but even then when i test it for something new, it fails to match any intent.
Any idea how to achieve this?

Lex is a conversational engine and - in my experience - ignores all punctuation as it is not able to be spoken.
You may have to replace /help with a phrase like help me with ..., how can I ....
If you are using your own front end (as opposed to FB integration) you can consider adding an intermediary that will catch /help messages and forward the remaining on to a Lex bot that specifically handles help requests.

Related

REGEXP_MATCH multiple words in a string using CASE statement in Google DataStudio

I am using Google Datastudio to make a CASE statement to take a multi-words string and split it out into categories. I was asked to use REGEXP_MATCH (nothing else, I know contains function would be easier).
I need a solution to match the following words:
HouseBrochure
home brochure
HomeBrochure
house brochure
Bathroom brochure
Bathroombrochure
FloorBrochure
floor brochure
To complicate matters, these words come in via a website request system, meaning people can request a house, bathroom and floor brochure in one request. When such requests reach my server, it compiles into a list(string) which looks like this:
# (with the pipes included)
HouseBrochure|Bathroom brochure|floor brochure
This is just an example of 1 request, there are many variations and multiple requests that come through (I've also only included a few of these brochures, there are many more)
I need to separate out all the house brochures, all the bathroom brochures and all the floor brochures etc, so I can count how many requests have been made for each brochure.
Being new to Regex, I have a basic understanding but nowhere near advanced.
My current attempt in Data studio looks like this:
CASE
WHEN REGEXP_MATCH(Event Label,'^.*(HouseBrochure.*|home brochure.*|HomeBrochure.*|house brochure.*).*$') THEN 'Home Brochure'
END
This is just for the home brochure, yet it's not working, can someone help?
Also, as an FYI Datastudio uses REG2
My approach would be:
convert everything to lower case (avoid messing with upper/lower case differences)
Use regex to replace variations with base form:
e.g.
(house|home)\s*brochure
replace with
HomeBrochure
Test here.
Do some counting as needed, using just the base keywords.

Amazon lex matching Intents which are not similar at all

I have created an intent in lex called MinimumAgeIntent.
MinimumAgeIntent has 2 utterances:
1. what is the age limit
2. what is the minimum age a patient needs to be to partake in the study
When I type in the question "where is the capital of turkey" it is matching the minimum age intent. Why is this? What is going on it doesn't make any sense.
In the first picture you can see that it is returning the response as if it matches the minimum age intent.
In the second picture you can see the lambda logs which shows the intent in the request.
Lex maps intent not just for the utterances given, but instead it takes those as an example and try to match for similar user inputs. In your case this might have happened because of the utterances you have given for MinimumAgeIntent and other intents. When Lex try to map the intent based on the user input, it sees MinimumAgeIntent as the closest match.
Somethings which you can try
Use non-conflicting utterances for intents. And add different varieties of it such that it covers the user intention in general. Add at least 5 to 10 utterances for each intent.
Use slots appropriately and validate its value on your code.
Lex always gives the inputTranscript so you can validate it on your code. May be not the best idea, but still you can check for mandatory words (prefer validating slots), In your case "age" for MinimumAgeIntent. And respond back with an appropriate response.
Add another intent like InvalidUserInput and add common user inputs that the bot wont support and respond with a proper error message. Be very careful with this, do not do this unless you know what you are doing and there is no other way.

How to define a Lex slot type(custom /built in ) that will accept any given value?

I have slot name "remark". I need a slot type which takes any value given by user to this field.
Amazon support staff have responded to similar questions in this way:
From aws dev forum:
The recommended approach for capturing free form text through a slot is to create a custom slot type, and provide enough representative sample/training data as slot values. This will allow Lex to learn from these samples, and recognize a much larger set.
So in your slot value samples, you should add single words, multiple words, and even whole sentences if that is what you expect. This lets Lex know and learn the wide range of data to fill the slot with.
The more sample values you give, the better Lex should be.
I have had the same problem, and firstly I tried to proviode wide range of training data but whenever I typed something new it never got captured correctly in the Lex.
So I created a slot without any value and unchecked the required checkbox (important). Then I enabled Lambda initialization and validation hook so that it goes to DialogCodeHook.
In the backend code, in DialogCodeHook, I grabbed the input of user from event['inputTranscript'] and assigned that value to the slot.
Hope it helps.
I have been working on lex platform for more than a year now. As per my understanding, it is not possible to capture free text as a slot. The approach to add more training data only to handle free text will make the slot (as thus the intent) greedy and have an negative impact on the overall performance of the bot.
The best alternative (in case of custom channel only) is to make use of session attributes to pass free text from the chat interface and pass a pre defined text (one of the values from slot) as input to lex; write logic in lambda to capture the free text from session attributes.
Let me know if you need more clarity.
You can use the AMAZON.AlphaNumeric inbuilt slot type

National Weather Service (NWS) Valid Time Event Code (VTEC) Parser Regular Expression (Regex)

The National Weather Service (NWS) embeds machine readable components in its text bulletins and syndicated format feeds, called Valid Time Event Code (VTEC).
More information on VTEC http://www.nws.noaa.gov/os/vtec/
Example of Text Bulletins: http://www.nws.noaa.gov/view/national.php?prodtype=allwarnings
I am developing a parser to interpret a sequence of VTECs embedded within an NWS bulletin and have a regular expression to capture the logic, that I am happy to share, see below, but not 100% sure if I am doing this right.
Specifically,
1. Is there any specification on how many VTECs may be embedded in any one NWS message (or its update)? Usually seeing just one, but if there are multiple, what is the hierarchy, if any - does the last one cancel the previous? Or, do all the VTECs have the same weight?
2. If a Hydrological or H-VTEC is issued, is it always immediately following a P-VTEC?
3. Is there a "parent-child" relationship, in the XML document sense, between an H-VTEC element and P-VTEC element?
4. Can the VTEC be used as a unique identifier for a message or its update? If not, what would be the "primary key" in the database sense? Could perhaps a hash of the VTEC along with bulletin update date be used? Or is any other combination of fields recommended?
The following regular expression is able to pick up the VTEC, assuming any number of P-VTECs may be released and if there is an H-VTEC it will always be preceded by a "parent" P-VTEC.
[/][OTEX][.](NEW|CON|EXT|EXA|EXB|UPG|CAN|EXP|COR|ROU)[.][\w]{4}[.][A-Z][A-Z][.][WAYSFON][.][0-9]{4}[.][0-9]{6}[T][0-9]{4}[Z][-][0-9]{6}[T][0-9]{4}[Z][/]([^/]*[/][\w]{5}[.][[N0-3U]][.][A-Z][A-Z][.][0-9]{6}[T][0-9]{4}[Z][.][0-9]{6}[T][0-9]{4}[Z][.][0-9]{6}[T][0-9]{4}[Z][.](NO|NR|UU|OO)[/])?
The VTEC is described in more detail at: http://www.nws.noaa.gov/directives/sym/pd01017003curr.pdf
In case the link expires, this may be found also by drilling down as follows:
NWS directives. http://www.nws.noaa.gov/directives/
(Click on) Operations and Services.
(Scroll Down) Dissemination.
After reading the document, answers to #2 and #3 are a resounding YES. H-VTEC will always be supplemental to an immediately preceding P-VTEC. Regarding #1, multiple P-VTECs are possible and the logic is probably more complex than regex can weed out. Regarding #4, the answer is almost certainly NO, mainly because VTEC could be missing in an NWS bulletin, so does not classify as a primary key.
So the regex needed to parse out a VTEC string, thanks to Suamere, is most likely:
/[OTEX]\.(NEW|CON|EXT|EXA|EXB|UPG|CAN|EXP|COR|ROU)\.\w{4}\.[A-Z]{2}\.[WAYSFON]\.\d{4}\.\d{6}T\d{4}Z-\d{6}T\d{4}Z/([^/]*/\w{5}\.[N0-3U]\.[A-Z]{2}\.\d{6}T\d{4}Z\.\d{6}T\d{4}Z\.\d{6}T\d{4}Z\.(NO|NR|UU|OO)/)?

Hash anchor tag causing errors in URL

On very rate occasions, my error log is showing the following error:
"You specified a Fuseaction of registrationaction#close which is not defined in Circuit public."
The full link is:"http://myUrl/index.cfm?do=public.registrationAction#close"
As you can see, the has merely points to an anchor (close) on the page.
This code is working 99% of the time, but on the odd occasion, Coldfusion / Fusebox throws this error out.
Why is this happening?
Could it be related to the device accessing my page somehow? Like a cell phone or Apple product that for some reason does handle hashes the way I am expecting it to?
Could it be javascript / JQuery being disabled?
Any guidance would be appreciated
Thanks
I used to see stuff like that. Older versions of Internet Explorer were not handling the hashtag properly when there were URL parameters. The best solution I could come up with was kludgey at best, but basically it forced the anchor tag to separate from the URL parameter.
http://myUrl/index.cfm?do=public.registrationAction&#close
I'm not sure there is a simple answer to this. We get odd exceptions all the time on our site for all sorts of reasons. Sometimes it's people not using the site the way you expect and sometimes it stuff like you mention such as user-agent edge cases etc.
Basically you need to start to gather evidence and see what comes up that's unusual with these requests.
So to start: do you catch exceptions in you application? If so dumping all scopes (CGI/CLIENT/FORM/URL/SESSION) in an email along with the full exception and emailing them to a custom emails address (such as errors#yourdomain.com) will give you a reference you can square up to your error times and this might give you a hint as to the real issue.
Hope that helps some!