Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
Cómo obtener y usar la confirmación 'sí' o 'no' para la respuesta de intención de habilidad de Alexa

Estoy desarrollando una habilidad de Alexa en la que, al iniciarse, preguntará Do you want to perform something ?
Dependiendo de la respuesta del usuario 'yes' o 'no' , quiero lanzar otra intención.

 var handlers = { 'LaunchRequest': function () { let prompt = this.t("ASK_FOR_SOMETHING"); let reprompt = this.t("LAUNCH_REPROMPT"); this.response.speak(this.t("WELCOME_MSG") + ' ' + prompt).listen(reprompt); this.emit(':responseReady'); }, "SomethingIntent": function () { //Launch this intent if the user's response is 'yes' } };

Eché un vistazo al dialog model y parece que servirá para el propósito. Pero no estoy seguro de cómo implementarlo.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

La forma más sencilla de hacer lo que está buscando desde la habilidad es manejar AMAZON.YesIntent y AMAZON.NoIntent desde su habilidad (asegúrese de agregarlos también al modelo de interacción):

 var handlers = { 'LaunchRequest': function () { let prompt = this.t("ASK_FOR_SOMETHING"); let reprompt = this.t("LAUNCH_REPROMPT"); this.response.speak(this.t("WELCOME_MSG") + ' ' + prompt).listen(reprompt); this.emit(':responseReady'); }, "AMAZON.YesIntent": function () { // raise the `SomethingIntent` event, to pass control to the "SomethingIntent" handler below this.emit('SomethingIntent'); }, "AMAZON.NoIntent": function () { // handle the case when user says No this.emit(':responseReady'); } "SomethingIntent": function () { // handle the "Something" intent here } };

Tenga en cuenta que, en una habilidad más compleja, es posible que deba almacenar algún estado para darse cuenta de que el usuario envió una intención de 'Sí' en respuesta a su pregunta sobre si "hacer algo". Puede guardar este estado utilizando los atributos de sesión de habilidad en el objeto de sesión . Por ejemplo:

 var handlers = { 'LaunchRequest': function () { let prompt = this.t("ASK_FOR_SOMETHING"); let reprompt = this.t("LAUNCH_REPROMPT"); this.response.speak(this.t("WELCOME_MSG") + ' ' + prompt).listen(reprompt); this.attributes.PromptForSomething = true; this.emit(':responseReady'); }, "AMAZON.YesIntent": function () { if (this.attributes.PromptForSomething === true) { // raise the `SomethingIntent` event, to pass control to the "SomethingIntent" handler below this.emit('SomethingIntent'); } else { // user replied Yes in another context.. handle it some other way // .. TODO .. this.emit(':responseReady'); } }, "AMAZON.NoIntent": function () { // handle the case when user says No this.emit(':responseReady'); } "SomethingIntent": function () { // handle the "Something" intent here // .. TODO .. } };

Finalmente, también podría considerar el uso de la interfaz de diálogo como mencionó en su pregunta, pero si todo lo que está tratando de hacer es obtener una simple confirmación Sí/No como un mensaje de la solicitud de lanzamiento, creo que mi ejemplo anterior sería bastante sencillo de implementar.

over 4 years ago · Santiago Trujillo Report

0

Así es como lo tengo codificado con javascript en la función Lambda para la habilidad:

 'myIntent': function() { // there is a required prompt setup in the language interaction model (in the Alexa Skill Kit platform) // To use it we "deligate" it to Alexa via the delegate dialoge directive. if (this.event.request.dialogState === 'STARTED') { // Pre-fill slots: update the intent object with slot values for which // you have defaults, then emit :delegate with this updated intent. //var updatedIntent = this.event.request.intent; //updatedIntent.slots.SlotName.value = 'DefaultValue'; //this.emit(':delegate', updatedIntent); this.emit(':delegate'); } else if (this.event.request.dialogState !== 'COMPLETED'){ this.emit(':delegate'); } else { // completed var intentObj = this.event.request.intent; if (intentObj.confirmationStatus !== 'CONFIRMED') { // not confirmed if (intentObj.confirmationStatus !== 'DENIED') { // Intent is completed, not confirmed but not denied this.emit(':tell', "You have neither confirmed or denied. Please try again."); } else { // Intent is completed, denied and not confirmed this.emit(':ask', 'I am sorry but you cannot continue.'); } } else { // intent is completed and confirmed. Success! var words = "You have confirmed, thank you!"; this.response.speak(words); this.emit(':responseReady'); } } },

Y deberá habilitar una confirmación para la intención en el modelo de interacción de Alexa.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!