Fullfillment server

Google will send all its requests to the fullfillment URI.

We will serve this URI with a ASP.NET Core Web API, hosted on an AWS Lambda.

To create a Visual Studio solution that deploys in an AWS Lambda follow my previous post. In this post we will focus on the ASP.NET project. The only difference here, is that we use the ASP.NET Core Web API template:

Delete from the templated project the two sample APIs S3ProxyController and ValuesControlles. Right click on Controllers folder and select Add new: Controller (of type API):

The controller will have only one POST endpoint:

 [Route("api/v1/[controller]")]
    public class GoogleController : Controller
    {
// POST: api/v1/Google
        [HttpPost]
        public IActionResult Post([FromBody]object intent)
        {
            try
            {
                Console.WriteLine("Google.POST. Intent=" + intent);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Google.POST Generic: " + ex);
            }
        }

For now we just log what we receive to be sure we are receiving something.

Let’s publish the Web API on AWS. Once published we will use the URL to configure the Action:

We can start testing.

Test the draft version

The action is ready (in DRAFT mode), we can test it. Go to Console▶Develop▶Test:

Make sure that Testing on device is enabled:

Once the test is enabled we can go to our Android phone, that must be logged with same account, and open Google Home app:

Click + on the upper left ▶ Setup device ▶ Have something already set up?

Search for your action name:

Click on it to test the Account Linking.

Warning: this test will result in an error, but we should receive a REST API call to our fullfillment REST API (check on AWS CloudWatch):

[Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request starting  POST https://XXXXX.execute-api.XXXXXX.amazonaws.com/Prod/api/google application/json;charset=UTF-8
Google.POST. Intent={
"inputs": [
{
"intent": "action.devices.SYNC"
}
],
"requestId": "10224884186323447126"
}

This means that the Account linking is working! ???

The next step is to implement the real fullfillment.

End of part 4Part 5