I am building a custom Alexa skill
In which I can ask the name of User and repeat it. (Working fine).
Now, the next part is to confirm the name of the user.
Alexa: "Please confirm your name!"<br>
User:"-"
Alexa: "Please confirm your name!"<br>
User: "No"
Alexa: "Please confirm your name!"<br>
**User: "Yes I confirm"**
End.
Now I am trying to achieve the above behaviour, as
Alexa should prompt "Please confirm your name!" on every 10 seconds until the user Responds
"Yes, I confirm".
I have checked the API documentation but not able to find any Intent related to this case.
Please share some info or solution.
Repromting every 10 seconds when the user doesn't responds, not sure if we can do.
But we can achieve the Yes/No part. One way of doing this is by using the state. Here in this example, I am using the node-cache module for state management.
Consider the below intent named "ConfirmationQuestionIntent". It sets the state to "confirm-name".
const ConfirmationQuestionIntentHandler = {
canHandle(handlerInput) {
return (
handlerInput.requestEnvelope.request.type === "IntentRequest" &&
handlerInput.requestEnvelope.request.intent.name === "ConfirmationQuestionIntent"
);
},
handle(handlerInput) {
const speechText = "Please confirm your name as 'John'.";
myCache.set('state','confirm-name');
return handlerInput.responseBuilder
.speak(speechText)
.reprompt(speechText)
.getResponse();
}
};
Now, enable/Add two BuiltIn intents, AMAZON.YesIntent and AMAZON.NoIntent.
Consider the AMAZON.NoIntent below,
In the handler function. it checks if there is any state with the name "confirm-name". If it is present, it responds with "Please confirm your name as 'John'." and if not then responds with the default response.
const NoBuiltInIntent = {
canHandle(handlerInput) {
return (
handlerInput.requestEnvelope.request.type === "IntentRequest" &&
handlerInput.requestEnvelope.request.intent.name === "AMAZON.NoIntent"
);
},
handle(handlerInput) {
const state = myCache.get("state");
let speechText = "I didn't get this!. Could you please rephrase.";
if(state === "confirm-name") speechText = "Please confirm your name as 'John'.";
return handlerInput.responseBuilder
.speak(speechText)
.reprompt(speechText)
.getResponse();
}
};
Consider the AMAZON.YesIntent below,
In the handle function, it checks if there is any state named "confirm-name". If it is, then it responds back with "Thanks for the confirmation" and deletes the state from the cache. If not then it asks the user to rephrase.
const YesBuiltInIntent = {
canHandle(handlerInput) {
return (
handlerInput.requestEnvelope.request.type === "IntentRequest" &&
handlerInput.requestEnvelope.request.intent.name === "AMAZON.YesIntent"
);
},
handle(handlerInput) {
const state = myCache.get("state");
let speechText = "I didn't get this!. Could you please rephrase.";
if(state === "confirm-name") speechText = "Thanks for the confirmation.";
myCache.del('state');
return handlerInput.responseBuilder
.speak(speechText)
.reprompt(speechText)
.getResponse();
}
};
So, you can use "State" to identify in which scenario the user is responding to and then provide the right response.
I am afraid it is not possible to make Alexa ask the question every 10 seconds untill the user confirm.
I suppose you are using confirmSlotDirective to confirm the name of the user.
confirmSlotDirective or simply any confirmation directive in Alexa works with words that only agree or disagree with the confirmation message. e.g. YES/NO
Solution:
1) If you have already asked for the name of the user (e.g. 'John'), do not ask it again. Simply make Alexa to say:
Alexa: "Your name is John, right?" Or "You said John? please confirm?"
User: can say Yes/No to confirm.
Note: Alexa only recognizes a limited set of international names.
2) Better way to get user's name is using Alexa's Customer Profile Api, so you won't have to worry about Alexa not able to recognize name let alone the confirmation of user's name.
Related
I am receiving notification payload as
[AnyHashable("jsonData"): {"packageName":"com.company.appName","appName":"AppName","orderId":"0","workflow":"PAGE_OWNER_STATUS_WORKFLOW"}, AnyHashable("aps"): {
alert = {
body = "You have received a new Order! ";
title = Orders;
};
sound = default;
},AnyHashable("google.c.a.e"): 1, AnyHashable("gcm.notification.jsonData"): {"packageName":"com.company.appName","appName":"AppName","orderId":"0","workflow":"PAGE_OWNER_STATUS_WORKFLOW"}, AnyHashable("title"): Orders, AnyHashable("google.c.sender.id"): 34781329473, AnyHashable("body"): You have received a new Order! , AnyHashable("sound"): phone_ringing.caf, AnyHashable("gcm.message_id"): 1597347128946557]
It does not add sound name in aps alert. Will it be done from backend?
We are using JAVA for Backend.
I believe the sound property has to be set as a property of the aps and not of the alert object, like you're receiving now and like it is specified in apple documentation. Apple example:
{
“aps” : {
“badge” : 9
“sound” : “bingbong.aiff”
},
“messageID” : “ABCDEFGHIJ”
}
You should specify the string "default" to play the default notification sound, otherwise a filename must be set and the file needs to exist on the app. These changes would have to be done on the server side.
Firebase developers, I used login with google in one of my application and successfully done.
Problem: I am getting Display Name and Email Id from Google but not getti get Phone Number. So I am taking that phone number from user in next activity.
Now If I want to update that phone number to current user of Firebase then what are the ways to do that.
I have found one method that is FirebaseAuth.getInstance().getCurrentUser().updatePhoneNumber() but didn't get any proper idea to use this.
If you have implemented this thing, help me.
Appreciated advance.
Thank you.
FirebaseUser's updatePhoneNumber() method:
Updates the phone number of the user.
And as you can see, it takes as an argument a PhoneAuthCredential object. So in order to update the phone number of the corresponding user, call updatePhoneNumber() method and pass the new phone credential object as an argument.
Important: this is a security sensitive operation that requires the user to have recently signed in. If this requirement isn't met, ask the user to authenticate again and later call reauthenticate(AuthCredential).
it took me a lot to find out how it could be done but here's how I did it
user firebase SDK recapcha
window.recaptchaVerifier = new fireabase.auth.RecaptchaVerifier('sign-in-button', {
size: 'invisible'
})
send SMS code
const phoneNumber = this.input.phone
const appVerifier = window.recaptchaVerifier
firebase.auth().currentUser.linkWithPhoneNumber(phoneNumber, appVerifier)
.then((confirmationResult) => {
window.confirmationResult = confirmationResult
// prompt user to entre code
...
})
.catch((error) => {
// reset rechatcha and try again
appVerifier.reset('sign-in-button')
alert(error.message)
})
Confirm the Code and link
const code = this.input.code
window.confirmationResult.confirm(code).then((result) => {
const credential = firebase.auth.PhoneAuthProvider.credential(window.confirmationResult.verificationId, code)
firebase.auth().currentUser.linkWithCredential(credential)
})
.then(() => {
// done
})
.catch((error) => {
alert(error.message)
// try again
})
Some github repo containing an implementation:
https://github.com/wardah9/QuestionsQate/blob/9224a6d2e00a9304566be063c2d611b76cc76fb8/app/src/main/java/com/questionqate/StudentProfile/UpdatedMobileAthuntication.java
You need to import and build an 'com.google.firebase.auth.PhoneAuthCredential'
To do that you need to ask your user to authenticate using their phone number using the 'com.google.firebase.auth.PhoneAuthProvider'.
Since you are using GoogleAuthProvider, you can update the user Phone Number 'by hand' using the method you posted and building the PhoneAuthCredential yourself or you need to intanciate a new PhoneAuthProvider and make the already authenticated user re-auth with his phone number (you need Phone Auth enabled in your providers at Firebase Console)
You can do this in React Native.
handlePhone=()=>{
const auth = firebase.auth();
const {phoneNumber} = this.state;
const self = this;
if(phoneNumber != ''){
try{
const snapshot = await auth.verifyPhoneNumber(`+92${phoneNumber}`).on('state_changed',
async (phoneAuthSnapshot) => {
switch(phoneAuthSnapshot.state){
case firebase.auth.PhoneAuthState.CODE_SENT:
self.setState({verificationSnapshot:phoneAuthSnapshot,showOTP:true})
}
})
}catch(error){
console.log(error);
this.showAlert('Try again later');
}
}else{
this.showAlert('Please enter phone number.');
}
}
handleVerifyOTP=()=>{
const {verificationCode, verificationSnapshot} = this.state;
console.log(verificationCode, verificationSnapshot)
const self = this;
try{
const credential = await firebase.auth.PhoneAuthProvider.credential(verificationSnapshot.verificationId, verificationCode);
console.log(credential)
const u = await firebase.auth().currentUser.updatePhoneNumber(credential);
console.log(u)
self.setState({showOTP:false,phoneNumberState:true});
Alert.alert('Number has been registered successfully')
}catch(error){
Alert.alert('Something went wrong');
console.log(error,"ERRR")
}
}
Add two input fields with buttons
One is for phone number
Other is for OTP
I am currently building a custom skill for Alexa in Java.
I want Alexa to set an appointment using an existing Exchange Server.
For the appointment I want Alexa to check wether a name, a date and a time are given by the user. I do so using if-statements like:
if(date.getValue() == null) {
return askResponse("Please give a date in order to create an appointment")
What happens is Alexa asks for the missing slot but when I answer the skill just quits. I don't know how to have Alexa recognize my response.
Code is as follows:
public SpeechletResponse getTerminResponse(Slot name, Slot date, Slot time, Session session, IntentRequest request) throws Exception {
if(time.getValue() == null) {
return askResponse("Please insert time");
} else if (date.getValue() == null) {
return askResponse("Please insert date");
} else if (name.getValue() == null) {
return askResponse("Please insert name");
} else {
try {
String[] datumArray = date.getValue().split("-");
String[] zeitArray = time.getValue().split(":");
Date startDate = new Date((Integer.parseInt(datumArray[0])-1900), (Integer.parseInt(datumArray[1])-1), (Integer.parseInt(datumArray[2])), (Integer.parseInt(zeitArray[0])), (Integer.parseInt(zeitArray[1])), 0);
Date endDate = new Date((Integer.parseInt(datumArray[0])-1900), (Integer.parseInt(datumArray[1])-1), (Integer.parseInt(datumArray[2])), (Integer.parseInt(zeitArray[0]))+1, (Integer.parseInt(zeitArray[1])), 0);
System.out.println(startDatum.toString());
System.out.println(endDatum.toString());
ExchangeHelper eh = new ExchangeHelper();
eh.createMeeting(name.getValue(), "Test", startDate, endDate);
return getTellSpeechletResponse("Appointment created successfully");
} catch (Exception e) {
System.out.println(e);
return askResponse("Failed to create appointment");
}
}
}
Here is my Interaction Model
Any help would be highly appreciated since I have been researching documentations and examples for days and I just can not get it to work.
Best regards
Can you give the code for getTellSpeechletResponse?
According to the picture you attached you are using the "new" Dialog model so that Amazon collect all the slots for you intent.
https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/dialog-interface-reference#directives
Most probably you forgot to send back the DelegateDirective (via speechletResponse.setDirectives(...)) to amazon to tell Alexa to take care for collecting the slot values. But this only can be answered if you send the code. I would also like to see an Dialog Java example by amazon but haven't found yet.
If you are using this dialog model you also don't need the if elses as alexa recognize itself which slots are missing. You have to mark this "Is this slot required to fulfill the intent" with yes in the interaction model. Than you also don't need to create own ask responses but just to give utterances in interaction model for your 4 slots.
This question already has an answer here:
Auto-generation of email with username and random password on creation of new user
(1 answer)
Closed 6 years ago.
How can we auto-generate a mail with the new user's password as soon as we click on the create user button in Alfresco New User page.
Do we need to create any webscript or action which can redirect to create user action and a corresponding mail will be generated automatically.
Please let me know how to create the link between Create User button and the mail to the new user.
Ultimately any thing in alfresco is node. User is also one type of node in alfresco.As per my perspective the best solution is to create a behavior and send an email.
Below is detail for implementation of behaviour in alfresco.
https://www.alfresco.com/blogs/lcabaceira/2015/04/07/alfresco-behaviours-and-policies/
This is one link for behaviour in alfresco.You will find multiple link for behaviour in alfresco.
Create the new rule:
on Repository > User Homes folder
when: Items are created or enter this folder
perform action: Execute script:
if (document.isContainer && document.displayPath == "/Company Home/User Homes") {
var owner = document.properties["cm:owner"];
var pNode = people.getPerson(owner);
if (pNode!=null && pNode.exists()){
var userName = pNode.properties.userName;
var email = pNode.properties.email;
var randPassword = Math.random().toString(36).substr(2, 30)+"-"+(Date.now());
people.setPassword(userName, randPassword);
logger.debug("Invitation mail: User "+userName+" password has been changed.");
var mail = actions.create("mail");
//mail.parameters.from = "noreply#customdomain";
mail.parameters.to = email;
mail.parameters.subject = "Welcome to the jungle, login: "+userName+", password: "+randPassword;
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/Invite Email Templates/invite_user_email.ftl");
var templateModel = new Array();
templateModel['newPassword'] = randPassword; // use ${newPassword} expression inside template
mail.parameters.template_model = templateModel;
mail.executeAsynchronously(document);
logger.debug("Invitation mail has been sent to "+email);
} else {
logger.warn("Invitation mail: User not found: "+owner);
}
} else {
logger.warn("Invitation mail: Document "+document.name+" / "+document.nodeRef+" is not a user home folder.");
}
You can use https://papercut.codeplex.com/ to test it, Alfresco configuration:
# smtp settings
mail.host=localhost
mail.port=25
mail.protocol=smtp
mail.smtp.auth=false
# mail.smtp.timeout=30000
# mail.smtp.debug=true
How to use facebook api taggable_friends by Open Graph tag friend.
my app use taggable_friends api i want to tag my friend in friends wall.
to use Mentioning friends or Tagging friends
https://developers.facebook.com/docs/opengraph/using-actions/v2.0#capabilities
And I use Open Graph doc Step by Step to try
but give me "You, or this app's Open Graph Test User, must have published this action at least once" how to setting?
https://developers.facebook.com/docs/apps/review/opengraph
On FB javascript sdk,
-* fb dashboard -> Open Graph
Create a story
List item make sure you enable the 'capabilities' features such as -tags, -user messages, -place, etc. in your action type.
-* in your js
1. call the js sdk
window.fbAsyncInit = function() {
FB.init({
appId : {YOUR_APP_ID} , // App ID
version: 'v2.0',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
xfbml : true // parse XFBML
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/sdk.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
}
3. Login into FB asking with these scopes
function Login()
{
FB.login(function(response) {
if (response.authResponse)
{
console.log(response.authResponse); // Get User Information.
} else
{
console.log('Authorization failed.');
}
},{scope: 'user_friends, publish_actions, status_update, read_stream, manage_friendlists'});// ' user_interests, user_likes, etc.. '
}
4. Get the logged user taggable_friends with a function such as:
var var friendsIDarray = [];
var user_friend_list;
function meTaggableFriends(){
FB.api(
"/me/taggable_friends",
function (response) {
if (response && !response.error) {
/* handle the result */
console.log(response)
for(var i=0; i<response.data.length; i++){
var data = response.data;
friendsIDarray.push(data[i].id);
}
user_friend_list = friendsIDarray.join();
}
}
);
5. Now, we have stored the token ids in user_friend_list for those friends we want to tag in our post
and we can use an Open Graph action like this in order to tag friends:
FB.api(
'me/{namespace}:{action}',
'post',
{
{object-type}:'http://example.com/object/', // make sure to have the apropiate og:type meta set
place:'https://example.com/place/', // open graph page with metas for location, id for a location page etc
tags: user_friend_list, // the tokens ids for those friens you wanna tag and you got on previous step
title: 'whatever',
message: 'like this, you tag friends #['+ONE_TOKEN_ID_FROM_TAGGABLE_FRIENDS+'] , #['+ONE_TOKEN_ID_FROM_TAGGABLE_FRIENDS+'] etc'
},
function(response) {
console.log(response)
}
);
you can find more information about it on:
https://developers.facebook.com/docs/opengraph/using-actions/v2.1
Hope you find it useful.
the error message "You, or this app's Open Graph Test User, must have published this action at least once" means: before you require this permission, you must call the api at least once.
I have occur this kind error before. when I require publish_actions permission, the facebook tell me this:
then I used my app call /me/feed api post a feed, then the error disappeared.
if you are the owner, developers or test users of the app, you can use these api before review approval. you can add roles for app in dashboard.