Making custom slots using Regex in amazon Lex - amazon-lex

I want to make custom slots that accepts any and all entries as long as those entries follow a certain regex pattern, eg:any number of alphabets or numbers but without a space in between. Can anyone tell me if there is a way in amazon lex to achieve it?
Also, if I want to take a certain type of data, say, email ids, but want to give the user option to give any number of email ids (more than one), what is the way to do that.
I am new to Amazon Lex and any suggestions would be appreciated.

Make a slot in Lex console in your intent but do not tick as required, and give any type as slot type.
Now in lambda code, first set the slot to null and then parse the inputText using regex and assign the correct value to the slot.
This way both of your problems will be addressed.
Hope it helps. Let us know if you run in any problems.

Related

Question about using API to retrieve cell data

I’m wondering if someone could help me figure out a little issue I’m having. I’m trying to create an iOS shortcut to retrieve specific cell data from a Google Sheets document, and I’m really close, however, I’m hitting this snafu.
For my example, the data entered into the specific cell is: “0+ 5” (without the quotes).
I’m using the following URL to grab the data (with my string ID and API keys X’d out):
https://sheets.googleapis.com/v4/spreadsheets/XXXXXXXXXX/values/Sheet1!D#?key=XXXXXXXXXXXXXXXXX
(Also, the # character after “Sheet1!D” is purposeful….I have shortcuts configured to replace that character with a number I input when running the shortcut)
Anyway, the result I’m getting is:
{"range":"Sheet1!D99","majorDimension":"ROWS","values":[["0+ 5"]]}
Notice the “0+ 5” near the end, which is the data entered in the specific cell.
I know I can mess around with Regex to to have the shortcut specifically match that part of the text, but I’m assuming there’s a way to format the API URL so that it only gives me the data entered — in this case, only
0+ 5
and not all of the other info….am I correct in that assumption? If so, I’d rather go that route and have the shortcut be a bit less convoluted.
Thanks!
Server's response is in JSON format, meaning, you can use action Get Dictionary From Input and next use action Get Dictionary Value. Type in values for the key.
Check this image:
Hope this helps.

Amazon Lex - receive spoken spelled out word, what slot type should I use?

Goal
User should spell out their name one letter at a time, for example: "s a r a h" / "ess ay are ay aych".
Lex should understand and convert it to text together: "sarah"
What I've tried
I'm using Amazon Connect (IVR/phone, user speaks into the phone to spell their name) which is using Lex to listen and convert to text.
I've tried a "AlphaNumeric" slot but it rarely works. I've also tried custom slots for all letters e.g. "a.", "b." - also rarely works.
Has anyone dealt with this? Any direction/experience would be appreciated re. handling spoken (not typed/chat bot) letter-by-letter input using Lex and preferably also Connect.
Other research I've done
https://forums.developer.amazon.com/questions/9331/letter-of-the-alphabet-slot-type.html - this author apparently took the custom letter slot approach, but doesn't really confirm if it worked overall. I've tried this and it's not working, but maybe I'm missing something important.
https://forums.aws.amazon.com/thread.jspa?threadID=261741 - AWS support thread which isn't very helpful
If you click the + next to Slot types you'll have the option to Extend slot type. If you click this you can create a new slot type with a regular expression based on your use case. For a first name that might be [a-z]{2,25}. I think the max length for these is 30, so [a-z]{1,40} would fail.

Extract Salesforce record Id from URL with Zapier Push

I need a way to extract the Salesforce record ID from a URL using Zapier Push. How can I find the first 3 characters in a string that match the start of the Id like 006 and then return a set number of characters after that?
The url is formatted as such:
https://useindio.lightning.force.com/lightning/r/Opportunity/006f400000AiVufAAF/view
David here, from the Zapier Platform team. Good question!
Whenever you want to extract data from a string and you know the exact format the string will be in, Regular Expressions are the answer.
Assuming you want to grab anything after 006 (and you know it'll always be there), you could use the regex 006(\w{15}) (more info), which will find the 15 characters after that. If you know the surrounding url will always be the same, you could easily grab the whole ID by anchoring via Opportunity and view: \/Opportunity\/(.*)\/view (more info).
Either way, there's info about setting up a formatter zap here, or you could do it in code (JS Example, Python Example).
​Let me know if you've got any other questions!

Validate User Inputted Text is Family-Friendly

I'm working on an iOS app that involves user input, and I'd like to keep it kid-friendly. One of the main features of the app is that user inputted titles and phrases can be shown to everyone who uses the app.
When a user creates a new title I want to verify that it is safe-for-work. My initial thought was just to have a list of all profane words and verify that none of them exist in the title:
for bad_word in list_of_bad_words:
if bad_word in user_inputted_title:
// Complain to user!
// Title is okay.
I imagine that there must be libraries or best practices for doing this. People could easily substitute numbers for letters, and I'm sure there are sequences of SFW words that create inappropriate phrases.
Can anyone suggest a better way of doing this? Specifically, if there are any Swift tools that would be awesome!
There are some cocoapods for this:
https://github.com/IslandOfDoom/IODProfanityFilter
https://github.com/MaxKramer/SCRProfanityChecker
I haven't used either of these personally, but I hope these can be a good starting point. The first one replaces any profanity with asterisks, and the second can give you the range of the profanity so you can replace it with your own filler. Good luck.

biopython qblast function no data returned

I'm trying to blast an 8-mer (string of length 8) against the NCBI database. However, whenever I use qblast, it comes up empty with respect to matches. This is my code:
from Bio.Blast.NCBIWWW import qblast
import Bio.Blast.NCBIXML as parser
a = qblast('blastp','nr','GGMPSGCS')
b = parser.read(a)
print b.alignments`
Whenever I do this, it just prints the empty list []. Why is this happening? Can anyone shine a light on it?
I can get a match using the NCBI online BLAST tool, and I can even get a match if I use a longer kmer like "SSRVQDGMGLYTARRVR". It just happens that all the 8-mers I search come up empty.
From the FAQ at http://biopython.org/DIST/docs/tutorial/Tutorial.html
Why doesn’t Bio.Blast.NCBIWWW.qblast() give the same results as the NCBI BLAST website?
You need to specify the same options – the NCBI often adjust the default settings on the >website, and they do not match the QBLAST defaults anymore. Check things like the gap >penalties and expectation threshold.
Check that qblast is using the same defaults, if not sure, make them explicit. I wouldn't be surprised if it's doing some sort of "read to short" filtering step.
As in this answer, you have to fine-tuning the qblast to override the defaults. The WWW frontend of NCBI-BLAST automatically adjusts your parameters to match the short (8 bp) sequences, but if you do it through Biopython API you have to do it manually.

Resources