Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

188
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda