weixin_39559486
weixin_39559486
2020-12-09 07:46

Add utterance to alexa.launch() ?

Hi all:


const launchResponse = await alexa.launch();

can simulate a user say "Alexa, open {invocation-name}"

Is it possible to add utterance support to launch(), maybe it is like


await alexa.launch("do some work");

to simulate a user say "Alexa, ask {invocation-name} to do some work" ?

and thank you all, you did a great job.

该提问来源于开源项目:bespoken/virtual-alexa

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

8条回答

  • weixin_39875167 weixin_39875167 5月前

    Hi - just saying alexa.utter("do some work") as a first call to the emulator should do it. Have you tried that? It is equivalent to saying "ask skill to do some work".

    点赞 评论 复制链接分享
  • weixin_39559486 weixin_39559486 5月前

    Thank you , yes it works. um... should I close it or something? I am new to github

    点赞 评论 复制链接分享
  • weixin_39875167 weixin_39875167 5月前

    Yes, go ahead and close. Thanks!

    On Thu, Jan 18, 2018, 2:53 AM MnHung wrote:

    Thank you https://github.com/jkelvie , yes it works. um... should I close it or something? I am new to github

    — You are receiving this because you were mentioned.

    Reply to this email directly, view it on GitHub https://github.com/bespoken/virtual-alexa/issues/24#issuecomment-358565961, or mute the thread https://github.com/notifications/unsubscribe-auth/AABDcxUbIVgNDvR6Iwx9d5tTr_6OD8F3ks5tLvhrgaJpZM4RaRw5 .

    点赞 评论 复制链接分享
  • weixin_39679091 weixin_39679091 5月前

    I am probably missing something simple, but I am unable to get my LaunchRequest to trigger. I set up a very simple index.js:

    
    "use strict";
    const Alexa = require("alexa-sdk");
    
    //=============================================================================
    const APP_ID = "amzn1.ask.skill.[unique-value-here]";
    
    const HELP_MESSAGE = "You can ask for help.";
    const HELP_REPROMPT = "Ask for help.";
    const STOP_MESSAGE = "Goodbye!";
    
    exports.handler = (event, context) => {
        const alexa = Alexa.handler(event, context);
        alexa.appId = APP_ID;
        alexa.registerHandlers(handlers);
        alexa.execute();
    };
    
    const handlers = {
        "LaunchRequest" : function() {
            console.log("DEBUG: start LaunchRequest");
            this.attributes.speechOutput = "Welcome to the test program.";
            this.response.speak(this.attributes.speechOutput);
            this.emit(':responseReady');
        },
        "AMAZON.HelpIntent": function() {
            this.attributes.speechOutput = HELP_MESSAGE;
            this.attributes.repromptSpeech = HELP_REPROMPT;
            this.response.speak(this.attributes.speechOutput)
                .listen(this.attributes.repromptSpeech);
            this.emit(":responseReady");
        },
        "AMAZON.RepeatIntent": function() {
            this.response.speak(this.attributes.speechOutput)
                .listen(this.attributes.repromptSpeech);
            this.emit(":responseReady");
        },
        "AMAZON.CancelIntent": function() {
            this.emit("EndSession");
        },
        "AMAZON.StopIntent": function() {
            this.emit("EndSession");
        },
        "EndSession": function() {
            this.response.speak(STOP_MESSAGE);
            this.emit(":responseReady");
        },
        "Unhandled": function() {
            this.attributes.speechOutput = "No intent match.";
            this.attributes.repromptSpeech = "Try again";
            this.response.speak(this.attributes.speechOutput)
                .listen(this.attributes.repromptSpeech);
            this.emit(":responseReady");
        },
    };
    

    for testing using Jest with this test file:

    
    const vax = require("virtual-alexa");
    const alexa = vax.VirtualAlexa.Builder()
        .handler("../src/index.handler") // Lambda function file and name
        .interactionModelFile("./model.json")
        .applicationID("amzn1.ask.skill.[unique-value-here]")
        .create();
    
    test("Launches successfully", (done) => {
        alexa.utter("get started").then((payload) => {
            expect(payload.response.outputSpeech.ssml).toContain("Welcome");
            return alexa.utter("");
        });
    });
    

    And it triggers the CancelIntent instead of LaunchRequest. Specifically:

    
      console.warn node_modules/virtual-alexa/lib/src/SkillInteractor.js:33
        No intentName matches utterance: get started. Using fallback utterance: cancel
    

    What am I doing wrong? If you need the code, I put it up at https://github.com/ultradian/AlexaTesting For package.json I used:

    
    {
      "name": "unitTest",
      "version": "1.0.0",
      "private": true,
      "dependencies": {
        "alexa-sdk": "^1.0.22",
        "i18next": "^10.2.1",
        "i18next-sprintf-postprocessor": "^0.2.2"
      },
      "devDependencies": {
          "jest": "^22.3.0",
          "pack-zip": "^0.2.2",
          "virtual-alexa": "^0.4.2"
      },
      "scripts": {
        "build-aws-resource": "pack-zip",
        "test": "jest"
     }
    }
    
    
    点赞 评论 复制链接分享
  • weixin_39875167 weixin_39875167 5月前

    Hi - you want to call alexa.launch instead of utter to get a launch request. See here: https://github.com/bespoken/giftionary/blob/master/test/index.test.js#L48

    Let me know if that works for you! Best, John

    点赞 评论 复制链接分享
  • weixin_39679091 weixin_39679091 5月前

    Thanks, John. That works great. I didn't go deep enough into the code... Is there a doc page besides https://github.com/bespoken/virtual-alexa/blob/master/README.md? The info at http://docs.bespoken.io/ only describes bstAlexa.

    点赞 评论 复制链接分享
  • weixin_39875167 weixin_39875167 5月前

    Yes, take a look here: https://bespoken.github.io/virtual-alexa/api/

    点赞 评论 复制链接分享
  • weixin_39679091 weixin_39679091 5月前

    Thanks for the link. I'll put it in the Github. A further question that I don't see documented (but probably is there somewhere)... is there a way to trigger the 'Unhandled' intent? I think there is some config file I'm missing because it says it is using a 'fallback utterance' which defaults to cancel.

    点赞 评论 复制链接分享

相关推荐