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

Receiving an Alexa Notifications in Jovo Causes TypeError #224

Closed bcnichols3 closed 6 years ago

bcnichols3 commented 6 years ago

I'm submitting a...

I'm building a plugin to receive and handle Alexa Notifications on the v1 Amazon Notifications API. Unfortunately the jovo framework is choking when being pinged with one of these kinds of messages.

Expected Behavior

Jovo-Alexa skill should be able to receive a notification from the Amazon Notification API under the Messaging.MessageReceived request type. These notifications should be handleable by user-written code, or at least be sent to an unhandled handler.

Current Behavior

The skill chokes on this request type and doesn't seem to build a proper Jovo request object, and so fails when response methods are called.

Error log

TypeError: this.request.getIntentName is not a function
    at AlexaNLU.getIntentName (/Users/brian.nichols/git/vm-jovo/node_modules/jovo-framework/lib/platforms/alexaSkill/alexaNLU.js:32:29)
    at AlexaSkill.getIntentName (/Users/brian.nichols/git/vm-jovo/node_modules/jovo-framework/lib/platforms/alexaSkill/alexaSkill.js:65:25)
    at Jovo.getIntentName (/Users/brian.nichols/git/vm-jovo/node_modules/jovo-framework/lib/jovo.js:316:57)
    at onRequest (/Users/brian.nichols/git/vm-jovo/app/common/events.js:5:26)
    at BaseApp.on (/Users/brian.nichols/git/vm-jovo/node_modules/jovo-framework/lib/app.js:304:13)
    at emitOne (events.js:101:20)
    at BaseApp.emit (events.js:191:7)
    at Jovo.on (/Users/brian.nichols/git/vm-jovo/node_modules/jovo-framework/lib/jovo.js:38:22)
    at emitOne (events.js:96:13)
    at Jovo.emit (events.js:191:7)
    at Jovo.execute (/Users/brian.nichols/git/vm-jovo/node_modules/jovo-framework/lib/jovo.js:159:14)
    at BaseApp.handleWebhook (/Users/brian.nichols/git/vm-jovo/node_modules/jovo-framework/lib/app.js:257:14)
    at Webhook.post (/Users/brian.nichols/git/vm-jovo/index.js:17:13)
    at Layer.handle [as handle_request] (/Users/brian.nichols/git/vm-jovo/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/brian.nichols/git/vm-jovo/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/Users/brian.nichols/git/vm-jovo/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/brian.nichols/git/vm-jovo/node_modules/express/lib/router/layer.js:95:5)
    at /Users/brian.nichols/git/vm-jovo/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/Users/brian.nichols/git/vm-jovo/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/brian.nichols/git/vm-jovo/node_modules/express/lib/router/index.js:275:10)
    at /Users/brian.nichols/git/vm-jovo/node_modules/body-parser/lib/read.js:130:5
    at invokeCallback (/Users/brian.nichols/git/vm-jovo/node_modules/raw-body/index.js:224:16)

Your Environment

aswetlow commented 6 years ago

Hey Brian! Notifications haven't been integrated yet. But you can try this workaround:

app.setHandler({
    '(request.type=Messaging.MessageReceived)': function() {
            console.log(this.alexaSkill().getRequest().request);
    },
}
aswetlow commented 6 years ago

We liked the send to Unhandled handler idea :) Added it to 1.4.3 Unknown (not implemented) requests will be routed to Unhandled.

mishranaveen commented 5 years ago

Hi, I am not sure if anyone is still watching this space. But, I am not able to let Alexa speak the message. I am getting the message and I can see the message body getting printed in my console. I am using "this.speak(msg);" and it gives correct output in outputSpeach format with snippet.

jankoenig commented 5 years ago

Hi there @mishranaveen, are you using Jovo? There is no this.speak option in Jovo

mishranaveen commented 5 years ago

My bad, actually I was trying with this.tell only, but issue is the same that message does not play on my echo dot. And I really appreciate you for your time and effort. Thanks

On Thu, Jan 24, 2019, 21:51 Jan König <notifications@github.com wrote:

Hi there @mishranaveen https://github.com/mishranaveen, are you using Jovo? There is no this.speak option in Jovo

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jovotech/jovo-framework/issues/224#issuecomment-457259083, or mute the thread https://github.com/notifications/unsubscribe-auth/AH_zBoaGjh60u5NLmUgsr3E4RVYYRhE5ks5vGd2ZgaJpZM4V68l2 .

jankoenig commented 5 years ago

How are you trying to implement it?

mishranaveen commented 5 years ago

Ok , so I'm sending a message through messaging app, using message token and user ID. Intercepting the message, and now here I am using the messaging.messageReceived as a route to invoke related intent based on message type. The default message I am trying Alexa to speak out. The response syntax looks correct, but no sound on echo dot . I just wanted the message to be read y Alexa for the user. Thanks again

On Fri, Jan 25, 2019, 22:20 Jan König <notifications@github.com wrote:

How are you trying to implement it?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jovotech/jovo-framework/issues/224#issuecomment-457637808, or mute the thread https://github.com/notifications/unsubscribe-auth/AH_zBsmcsbk5oqZ9ss6bc_mYOX_Q4rx6ks5vGzW8gaJpZM4V68l2 .