jovotech / jovo-framework

🔈 The React for Voice and Chat: Build Apps for Alexa, Messenger, Instagram, the Web, and more
https://www.jovo.tech
Apache License 2.0
1.68k stars 309 forks source link

`$alexaSkill.addDirective` broke google assistant conversation #520

Closed gustavopaes closed 5 years ago

gustavopaes commented 5 years ago

I'm submitting a...

Expected Behavior

I can call this.$alexaSkill.addDirective method without check if the conversation come from Alexa or Google Assistant or any other one. The framework need abstract this from me

Current Behavior

Call this.$alexaSkill.addDirective method can't broke Google Assistant webhook calls.

But when I create a Google Assistant conversation, I am getting this message error:

Message:
  Cannot read property 'addDirective' of undefined
app.setHandler({
    async LAUNCH() {
        this.$alexaSkill.addDirective({
            type: 'Alexa.Presentation.APL.RenderDocument',
            version: '1.0',
            document,
            datasources,
        });

        this.ask(speeches.LaunchRequest, speeches.LaunchRequest);
    },
})

Your Environment

aswetlow commented 5 years ago

Hey @gustavopaes!

Platform-specific calls should be checked. Try this:


app.setHandler({
    async LAUNCH() {
        if (this.isAlexaSkill()) {
         this.$alexaSkill.addDirective({
            type: 'Alexa.Presentation.APL.RenderDocument',
            version: '1.0',
            document,
            datasources,
        });
        }
        this.ask(speeches.LaunchRequest, speeches.LaunchRequest);
    },
})