-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes callback issue #60
Conversation
Thanks for submitting this, Octavio! |
@jkelvie my pleasure. I'm using bespoken virtual test packages for my unit tests in voice projects. Do you have an estimated date to release this and/or any other features to the NPM package ? |
Hi @omenocal , we just published the latest version of the virtual-google-assistant with your change. Thanks! |
@dmarvp just confirmed these changes work perfect. Thank you for the quick response! |
@jkelvie @omenocal @dmarvp i've just had an issue after upgrading because of this change. According to the documentation the "handler" is expecting a "Google Cloud Function" This change is essentially chaning the Eg: exports.handler = (req, res) => {
res.send('Hello, World');
}; |
Hi @armonge thanks for pointing this out. I should have looked at this more closely, because an error object as the first parameter to send is not familiar to me. My understanding is that Google modeled cloud functions on the Express.js API, which does not support such a parameter. @omenocal - can you point me to the Jovo docs where the response.send is? I'd like to see that before proposing a solution. |
Hi @jkelvie . The class that Jovo uses to return a response for Google projects is Lambda.ts, lines 74 and 83 https://github.com/jovotech/jovo-framework/blob/master/jovo-framework/src/hosts/Lambda.ts#L74 |
Thank you! It seems to me a flaw/limitation in what we are doing to be tightly coupled to Google Cloud Functions. This is probably something that we need to address. As an immediate fix, it seems like we can serve both Cloud Functions and Alexa by leaving the send function alone, but passing a third parameter that looks like this:
send would revert to look like this:
The final return statement would look like this:
That should work for Jovo as well as someone using a Lambda with callbacks - and "regular" Lambdas as well. Does it sound like I'm on the right track? |
I guess the issue comes mostly because if a misunderstanding, or even because of lack of consistency, virtual Alexa supports a lambda handler, this is not that. Should there maybe be a separate "lambda" handler? |
This PR addresses issue #58 . When using it with a Jovo application, the Lambda class of Jovo expects a callback, which is not being sent in line 59 of the Bespoken VA package. Also, the
send
function is expecting only one parameter, the payload, and not the error object that might be null but it goes before the payload. That's why I'm always getting a null response, because the payload object is getting the error null object returned by the Jovo framework.