call method automatically after alexa finished speaking - alexa-skills-kit

I have a question, it is possible that it can be called again method that was executed in a handlerIntent? When you come back and finish talking? I need to rerun:
const response = await logic.consultaService (1,1,1100);
after finishing the call
Without the user having to say the command again
I require an automatic action until the user says stop
return handlerInput.responseBuilder
.speak (speechText)
.reprompt ('tss')
.getResponse ();
thank you.
Code:
const CustomServiceIntent = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'CustomServiceIntent';
},
async handle(handlerInput) {
try {
await logic.callDirectiveService(handlerInput,"espera");
} catch (error) {
console.log("Progressive error : " + error);
}
const response = await logic.consultaServicio(1,1,1100);
let speechText="";
if(response) {
const results = response;
results.forEach(function (elemento, indice, array) {
speechText += " El " + " " + " siguiente " +" "+ " niƱo " + " "+ " en "+" " + " salir es " + " " +" . " + elemento.nombre + " . " ;
});
}
return handlerInput.responseBuilder
.speak(speechText)
.reprompt('tss')
.getResponse();
}
};

may I suggest you use Dialog Management to solve this?, if the idea is that the user says "stop" or something you can do that with Dialog Management handling the status. Give it a thought I think that might work. Seems to me that what you want to achieve can be realized using that Dialog Management feature.
I hope it helps otherwise lets give it a thought.

Related

Exception on getting location in UWP

I have a Xamarin.Forms application, which uses Xamarin.Essentials and Plugin.Permissions plugin.
permissionStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);
In UWP, It throws an Exception
"Server execution failed".
Any ideas what can cause it, and how this can be solved?
According to your code, I guess that you want to request and check location permission, if yes, you can take a look the following code to request location permission.
try
{
var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);
if (status != PermissionStatus.Granted)
{
if(await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location))
{
await DisplayAlert("Need location", "Gunna need that location", "OK");
}
var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Location);
status = results[Permission.Location];
}
if (status == PermissionStatus.Granted)
{
var results = await CrossGeolocator.Current.GetPositionAsync(TimeSpan.FromSeconds(10));
LabelGeolocation.Text = "Lat: " + results.Latitude + " Long: " + results.Longitude;
}
else if(status != PermissionStatus.Unknown)
{
await DisplayAlert("Location Denied", "Can not continue, try again.", "OK");
}
}
catch (Exception ex)
{
LabelGeolocation.Text = "Error: " + ex;
}
Please check Location in package.appxmanifest before.

Unity Firebase database GetValueAsync() returning null

This started to happen after I updated from 5.0.0 to 5.2.1, but it also happens on 5.1.0, before it was enough with:
if (task.Result.Exist){}
But now I have to do:
if (task.Result != null && task.Result.Exist){}
because somehow task.Result may be null, is that okay?
I tested with this piece of code:
DatabaseRoot.Child("users").Child(userId).GetValueAsync().ContinueWith((task) =>
{
if (task.IsFaulted)
{
Debug.LogError("Firebase task error: " + task.Exception.Message);
}
else if (task.IsCompleted)
{
Debug.Log("Task completed.");
try
{
Debug.Log("Result " + (task.Result == null));
Debug.Log("Result " + task.Result.Exists);
Debug.Log("Result " + task.Result.Value);
}
catch (Exception e)
{
Debug.Log(e.Message);
}
}
});
It works well (as it used to be) if I return to the 5.0.0, but I need some of the patches in the newer versions.

Unable to delete entry in Firebase database using remove

I'm trying to remove an entry from my Firebase database, but am not able to delete it.
Here's my database structure:
Here's what I've tried:
let subRefs = firebase.database().ref('subscriptions/' + userId).once('value').then(function(snapshot){
let objs = snapshot.val();
for (let key in objs){
if (objs[key].uid == memberId){
console.log('found'); // I see this in the console
//remove the subscription
let ref = firebase.database().ref('subscription/' + userId + '/' + key);
ref.remove().then(function() {
console.log("Remove succeeded");
}).catch(function(error) {
console.log("Remove failed");
});
}
}
});
I've also tried the following approach as suggested here in the docs, but that didn't work either.
let update = {};
update['subscription/' + userId + '/' + key] = null;
firebase.database().ref().update(update).then(function(){
console.log('remove success');
}).catch(function(err){
console.log('remove failed');
});
In both cases, I see the "remove success" log, but when I check the database, it's not actually deleted.

Querying another easy table for push notification message

I have two easy tables configured in my Azure App backend:
Services with Id and ServiceName properties
ServiceDetails with Id, ServiceID and ServiceDetailDate properties
Whenever a new ServiceDetails entry is inserted, I want to send a message to my users via Push Notifications containing information about ServiceDetailDate and ServiceName.
So my question is how can I query another table to obtain information from it? In this case the ServiceID (from ServiceDetails table) is known, so I want to get the ServiceName from Services. Which code should I add to extract the ServiceName from the serviceInfo object (in the payload message) to my script to fulfill this request?
Actually I'm not sure about the query and serviceInfo instructions, so if I'm wrong with the code, don't hesitate to point me in the right direction.
var azureMobileApps = require('azure-mobile-apps'),
promises = require('azure-mobile-apps/src/utilities/promises'),
logger = require('azure-mobile-apps/src/logger'),
queries = require('azure-mobile-apps/src/query');
var table = azureMobileApps.table();
table.insert(function (context) {
var query = queries.create('Services');
var serviceInfo = query.where({'Id': context.item.ServiceID});
var payload = '{"messageParam": "Your service -service name- has been added on ' + context.item.ServiceDetailDate + '" }';
return context.execute()
.then(function (results) {
if (context.push) {
context.push.send(null, payload, function (error) {
if (error) {
logger.error('Error while sending push notification: ', error);
} else {
logger.info('Push notification sent successfully!');
}
});
}
return results;
})
.catch(function (error) {
logger.error('Error while running context.execute: ', error);
});
});
module.exports = table;
Thanks for your help.
You can use the following code to query another easy table in ServiceDetails.js.
table.insert(function (context) {
return context.tables('Services')
.where({ Id: context.item.ServiceID })
.select('ServiceName')
.read()
.then(function (data) {
var message = 'Your service ' + data[0].ServiceName + ' has been added on ' + context.item.ServiceDetailDate;
var payload = '{"messageParam": "' + message + '"}';
return context.execute().then(function (results) {
//..
});
});
});

verification email with accounts-google,accounts-facebook

I have the running app which sends verification emails in case of email/account name creation but it does not send verification email if I login with google/facebook; it is probably due to email address which is in services.google.email; how can I set field 'to' in Accounts.emailTemplates if it does exist.
configureAccounts = function() {
setMailVerification(enableMailVerification);
};
setMailVerification = function() {
Accounts.emailTemplates.from = 'myEmail#.com';
Accounts.emailTemplates.verifyEmail = {
subject : function(user) {
return "Confirmation"
},
text : function(user, url) {
var greeting = (user.profile && user.profile.nick) ? ("Hello " + user.profile.nick + ",") : "Hello,";
return greeting +
"\n\n" + "Thank you for registration."+
"\n" + "To confirm click the following link:" + url +
"\n\n" + "thank you."
}
};
Accounts.config({
sendVerificationEmail : true,
forbidClientAccountCreation : false
});
};
please let me know if you where I should put ...services.google.email in case of google login and the same for facebook...
in other words how I can sent verification email to Meteor.user().services.google.email .. (even recalling sendUserVerificationEmail with that email does not work as it is not in 'emails')
I modified .email property onCreateUser as follows:
if(user.services != undefined) {
console.log('services in onCreateUser');
user.sentVerificationEmail = false;
user.emails =[];
var emailServices = user.services.google != undefined ?
user.services.google.email :
user.services.facebook.email;
user.emails.push({
address : emailServices,
verified : false
});
}
if (options.profile)
user.profile = options.profile;
return user;
I called then Accounts.sentVerificationEmail then onLogin .. and it worked;
thank you all for having a look

Resources