Host your Google Action on AWS Lambda

by Kaan Kilic on Sep 10, 2018

AWS Lambda is a serverless hosting solution by Amazon. Many Alexa Skills are hosted on this platform, thus it might make sense for you to host your cross-platform voice application (including your Google Action). This is what we're going to do in this section. This usually takes a few steps, so be prepared.

Create a Lambda Function

Go to the AWS Management Console:

Search for "lambda" or go directly to console.aws.amazon.com/lambda:

Click "Create a Lambda function", choose "Author from scratch" and fill out the form:

You can either choose an existing role (if you have one already), or create a new one. We're going to create one from a template and call it "myNewRole" with no special policy templates.

Now it's time to configure your Lambda function. Let's start by adding the Alexa Skills Kit as a trigger:

You can enable skill ID verification, if you want, but it's not neccessary.

Upload Your Code

Now let's get to the fun part. You can either enter to code inline, upload a zip, or upload a file from Amazon S3. As we're using other dependencies like the jovo-framework npm package, we can't use the inline editor. We're going to zip our project and upload it to the function.

To create a zip file that is ready to upload, run the following command:

This will create an optimizeds bundle.zip file into your project directory, which includes all necessary dependencies.

Let's go back to the AWS Developer Console and upload the zip:

Now save your changes with the orange button in the upper right corner:

Test Your Lambda Function

Great! Your Lambda function is now created. Click "Test" right next to the "Save" button and select "Alexa Start Session" as the event template, since the Jovo Framework supports both Google Action and Amazon Alexa requests:

Click "Test," aaand 🎉 it works!

If you want to test it with a "real" Google Assistant request, you can also copy-paste this one:

Create API Gateway

For Alexa Skills, you can just use the Lambda function's ARN to proceed, for Dialogflow, we need to create an API Gateway.

Go to console.aws.amazon.com/apigateway to get started:

Let's create a new REST API called "myGoogleActionAPIGateway":

After successful creation, you will see the Resources screen. Click on the "Actions" dropdown and select "New Method":

Dialogflow needs a webhook where it can send POST requests to. So let's create a POST method that is integrated with our existing Lambda function:

Grant it permission:

And that's almost it. You only need to deploy the API like this:

And create a new stage:

Yes! Finally, you can get the URL for the API Gateway from here:

There's one more step we need to do before testing: we need to use this link and add it to Dialogflow.

Add Endpoint to Dialogflow

Now that have either our local webhook or the API Gateway to AWS Lambda set up, it's time use the provided URL to connect our application with our agent on Dialogflow.

Agent Fulfillment Section

Go back to the Dialogflow console and choose the Fulfillment navigation item. Enable the webhook and paste either your Jovo webhook URL or the API Gateway:

Add Webhook to Intents

Dialogflow offers the ability to customize your language model in a way that you can choose for every intent how it's going to be handled.

This means we need to enable webhook fulfillment for every intent we use in our model.

Go to HelloWorldIntent first and check "Use webhook" in at the bottom of the page:

Do the same for the "MyNameIsIntent" and also take a look at the "Default Welcome Intent" and don't forget to check the box there as well. The intent comes with default text responses, which would otherwise cause random output instead of your model, when the application is launched.

That's it!


Kaan Kilic

Technical Content Marketing Associate at Jovo

Comments and Questions

Any specific questions? Just drop them below or join the Jovo Community Forum.

Join Our Newsletter

Be the first to get our free tutorials, courses, and other resources for voice app developers.