I am developing an Alexa skill with a required slot "name" for which I have added a prompt of "What is your name".
The utterances for the intent are:
1. note my name
2. note my name as {name}
For both the utterances, I get the prompt what is your name.
Utterances for your intent should be something like these :
note my name
My name is {name}
note my name as {name}
Prompts for your slot "name"
Please tell me your name
What is your name?
Do you even have a name?
Utterances for your slot "name"
{name}
My name is {name}
It is {name}
Even though you are using AMAZON.US_FIRST_NAME, it would be wise to provide some slot values for the slot "name".
For example:
Slot value samples for the slot "name"
joe
sam
Martha
Gopal
If still AMAZON.FallBackIntent is called, then please show me your complete code.
Related
I have a Salesforce object, lets say Contact.
If I try to set the Name field by using code:
Contact testAccount = new Contact();
testAccount.Name ='TestAccountContact';
insert testAccount;
It gives an error:
Line: 2, Column: 20
Field is not writeable: Contact.Name
By navigating the object through Salesforce I find that Name is a combination of FirstName, LastName.
How can I determine if the field is writeable and if not get the componenets of that field that together represent it. In this case FirstName and LastName cconcatenated makes up Name.
Contact/Lead/User Name is special field which Salesforce composes in runtime depending on what's in the data and who's looking. Source fields can be:
Salutation (Mr, Mrs...)
FirstName
MiddleName (if you have them enabled)
LastName
Suffix (if you have them enabled)
"Who's looking"? There are cultures that use "LastName FirstName", commonly referred to as CJK (Chinese,Japanese,Korean) but also Hungarian for example. This is defined by user's locale.
To check if field can be written to on insert use "describe" calls, specifically isCreateable.
System.debug(Schema.sObjectType.Contact.fields.Name.isCreateable()); // false
For practical purposes - try to not to use Contact.Name too much in Apex or reports for example. You'll forget this quirk and 2 years later will get a "funny" bug report that for some user report that goes Name equals to John Doe doesn't return any results for certain user and you'll go all "works for me".
I have two intents that use the same slot types. However, if the input is a random string, Alexa automatically identifies an intent in its JSON request even though it is not part of the utterances. For example, in the example below, if the user input was 'bla bla bla', GetAccountBalance is identified as the intent with no slot value even though it is not part of provided utterances.
What is the way to error-check for these cases and what is the best practice to avoid cases like this when developing the intent schema? Is there a way to create an intent that can handle all random inputs?
Example Schema:
{
"intents": [
{
"intent": "GetAccountBalance",
"slots": [
{
"name": "AccountType",
"type": "ACCOUNT_TYPE"
}
]
},
{
"intent": "GetAccountNumber",
"slots": [
{
"name": "AccountType",
"type": "ACCOUNT_TYPE"
}
]
}
]
}
Utterances:
GetAccountBalance what is my account balance for {AccountType} Account
GetAccountBalance what is my balance for {AccountType} Account
GetAccountBalance what is the balance for my {AccountType} Account
GetAccountBalance what is {AccountType} account balance
GetAccountBalance what is my account balance
GetAccountBalance what is account balance
GetAccountBalance what is the account balance
GetAccountBalance what is account balance
GetAccountNumber what is my account number for {AccountType} Account
GetAccountNumber what is my number for {AccountType} Account
GetAccountNumber what is the number for my {AccountType} Account
GetAccountNumber what is {AccountType} account number
GetAccountNumber what is my account number
GetAccountNumber what is account number
GetAccountNumber what is the account number
GetAccountNumber what is account number
There is one hack to resolve this problem:
If no any match found(random string) Amazon always take intent with highest no of utterances.
So I created one intent 'DidNotUnderstand' and add as many random utterances as I can (Be moderate enough) in result if no any match found alexa will call 'DidNotUnderstand' intent.
Please refer first reply from below link:
https://forums.developer.amazon.com/questions/4856/intent-triggering-without-utterance-match.html
When developing an Alexa skill, Alexa will always pick an intent to fire even if the user speaks pure gibberish. As far as I'm aware, there isn't a way to set a default / catch-all intent.
In terms of error handling, the following passage from the docs is really important.
Note that a custom slot type is not the equivalent of an enumeration. Values outside the list are still returned if recognised by the spoken language understanding system. Although input to a custom slot type is weighted towards the values in the list, it is not constrained to just the items on the list. Your code still needs to include validation and error checking when using slot values.
The link above also has a few follow up links which dive further into the topic error handling.
As per the documentation:
The AMAZON.FallbackIntent (available in English (US) only) is triggered when the user's spoken input does not match any of the other intents in the skill. AMAZON.FallbackIntent is matched to an automatically-generated out-of-domain model.
Code snippet:
'AMAZON.FallbackIntent': function (intent, session, response) {
response.ask("Optimus Prime didn't get that one....","");
}
A slot with SearchQuery slot type may help you.but it would need some extra phrases with it.like
Fname->where Fname is a slot of type Amazon.SearchQuery
my name is {Fname}
it will work for the example
my name is bffblselsk
my name is snfdslnel
etc...
visit Amazon.SearchQuery Slot for more referrences....
The main question is in the title of the topic.
Let's say i have an entity called for example : "room"
Every room has an "Unique number",is on a certain "floor" and has a number of "beds"(Those are clearly attributes).
If i want to know if a room is also "for smokers or not" and if it has the "space for an additional bed or not", can i consider those as attributes with just a "yes" or "no" value?
Thank you.
Certainly. An attribute is defined as a mapping from an entity set (e.g. rooms) to a value set (e.g. yes/no, numbers, names, etc).
What I am looking to do is Make it the "Account" name field require a unique name.
Basically If one of my reps tries to create an account, and that account all ready exists it tells them no that account all ready exists.
Salesforce tells me this funicality is not build into sales force. Any help or dirrection would we wonderfull.
Make a new text field, call it Name__c. Mark it as unique, length... probably 80, same as Name field length.
Create new Workflow rule with condition ISNEW() || ISCHANGED(Name) || ISBLANK(Name__c) and the action should be a field update that simply has Name in the formula that determines new value.
Remember to activate the workflow and to fill in the newly created field because it will be blank for all your existing accounts!
Your call if you want to show the field on page layouts (it's quite "technical" so could be hidden). If you do - it's a good idea to make it readonly!
You can use this validation:
AND(CONTAINS(VLOOKUP( $ObjectType.Account.Fields.Name , $ObjectType.Account.Fields.Name, Name), Name), OR(ISNEW(), ISCHANGED(Name)) )
Salesforce offers duplication management for this purpose.
You just set up Matching Rules and Duplicate Rules for your Account object in Setup > Administration Setup > Data.com Administration > Duplicate Management.
Link: https://help.salesforce.com/apex/HTViewHelpDoc?id=duplicate_prevention_map_of_tasks.htm&language=en_US
You could write a trigger to prevent duplicates. It'd be a "before insert" trigger that queried for existing accounts with the same name. If an Account name already exists, you'd call addError() on the new Account record, preventing the insert from continuing.
Have you searched the AppExchange for solutions? Might want to check out something like DupeCatcher
You could always make a custom field to contain the account name (something like "Business Name") and then ensure that's required and unique.
You'd need to do some basic Data Loader gymnastics to move your account names to the new field, and come up with a strategy for populating the existing Name field for accounts.
AND(VLOOKUP($ObjectType.Object_Name.Fields.Name, $ObjectType.Object_Name.Fields.Name, Name) = Name, OR(ISNEW(), ISCHANGED(Name)))
Is there any way to programmatically get the current user's email address?
I know the email is usually user#hostname but is there any I can get the email?
I know how to get the username and the hostname so I can build it myself, but I want to be sure that I get the email address even when the email is not user#hostname.
Code in C is appreciated.
Thanks
There is no such standard mapping of user account to email address - at least not for ordinary /etc/passwd derived accounts. Consider that a user might not even have an email address.
Nobody's mentioned the GECOS fields in the /etc/passwd file.
You'll notice that the fifth field in your entry in /etc/passwd is either blank, or a comma-separated list the first element of which is your full name. Originally in Bell Labs (before the days of email) the GECOS fields were:
User's full name (or application name, if the account is for a
program)
Building and room number or contact person
Office telephone
number
Any other contact information (pager number, fax, etc.)
Some Linux distributions store the user's default email address in the 4th GECOS field, and if your system doesn't do this by default, you can set it up yourself. Ordinary users without superuser privilege can edit their GECOS fields using the command line command chfn. To access this field, you can then do
grep ${USER}: /etc/passwd | awk -F\: '{print $5}' | awk -F\, '{print $4}'
or whatever floats your boat in your language of choice (No, I am NOT going to write C. This is the twenty-first century!).
There is no standard mapping of user accounts to RFC822 (i.e. user#domain) email addresses. Generally, a default setup of typical mail transfer agents will accept local mail to addresses without a domain and deliver it to the user account of the same name. But even that can't be relied on, as you may not even have an MTA.
The UNIX way of doing this is to send email through the local mail-transfer-agent - simply invoking /usr/bin/mail is enough. The system administrator is responsible for configuring the local MTA to make sure email works properly.
If you want to send email to the local user, just send it to their username - if they read their email somewhere other than locally, the MTA should be configured to forward it to them.
If you just want to use the right "from" email address when sending email on behalf of a local user, so they get replies in the right place - again, just use their username. The MTA should be configured to do the right translation.
This way of doing things is good, because it means that this configuration only has to be done in one place (the MTA), rather than having to manually configure every single application on the box that sends or recieves email.
Just to complement Simon's answer and given I don't have enough reputation to make a comment on it, GECOS stands for General Comprehensive Operating System aka General Electric Comprehensive Operating Supervisor and the most portable way I found to get the user GECOS field (As it might not be defined in your /etc/passwd file directly depending on your system's configuration) is the following:
getent passwd <USERNAME> | awk -F ':' '{print $5}'
It depends how the user is stored. In a simple passwd file there's no email address, only a username. But you can have additional information with other authentication method like LDAP or SQL.
Prompt the user for their email. If you have no guarantee that the email is user#hostname, then how else do you expect to determine what their email is other than asking them?
You can't get the actual email address in any standard way. I would try to send the mail to just username. Chanses that it will end up on the correct domain are actually not that bad ...
Check in the terminal you're using, that is :
root#peter-laptop#
for root users it is shown before the # sign, that is
root#peter-laptop or peter#peter-laptop# for user peter
Try to get to /var/mail/ and there you should have a file for each user that has (not all users have to have it) an email address. And you can indeed read the mail from those files.
Then you can redirect the mail to anywhere else with the sendmail tool.