Search code examples
aws-lambdaactions-on-google

how to use 'actions-on-google' libray in aws lambda


In actions-on-google , both the request and response object need to provide as input to this library. but in lambda function, only the request object exists.

So how can i override it ?

in aws lambda the format is

exports.handler = function (event, context, callback) { // event is the request object , the response is provided using the callback() functon 
}     

the actions-on-google object is created as :

const DialogflowApp = require('actions-on-google').DialogflowApp;
const app = new DialogflowApp({ request: request, response: response });

Solution

  • To get a Google Action to work on AWS Lambda, you need to do 2 things:

    • Code your app in a way that it's executable on Lambda
    • Create an API Gateway to your Lambda Function which you can then use for Dialogflow Fulfillment

    I believe the first setp can't be done off-the-shelf with the Actions SDK. If you're using a framework like Jovo, you can create code that works for both Amazon Alexa and Google Assistant, and host it on AWS Lambda.

    You can find a step by step tutorial about setting up a "Hello World" Google Action, host it on Lambda, and create an API Gateway here: https://www.jovo.tech/blog/google-action-tutorial-nodejs/

    Disclaimer: I'm one of the founders of Jovo. Happy to answer any further questions.