[Solved] Alexa response based on json statusCode

Hello,

I am doing an Alexa webhook that performs a JSON API request. Based on the response of 200 or 450, I would like to generate a different Alexa verbal response. I haven’t find exactly how in documentation yet. I thought setting two webhook replies with the statuscode defined might trigger the proper response but it did not. I also tried conditional statements to no avail. Most likely I have some basic syntax wrong. If there is a document or tutorial to point to that performs this task, it would be much appreciated.

Thanks,

Where are the 200 and 450 status codes coming from? Are you making another HTTP request that could return those or is your choosing to reply with a 200 or 450 based on some other conditions?

Brandon,

The 200 and 450 status codes are coming from a JSON API request. So Amazon Alexa links to a Webhook. The Webhook triggers an API call to my platform. It will return either a 200 or 450 depending on authentication. I would a conditional webhook reply that is customized based on the statusCode.

Thank you,

The HTTP node has a configuration option that sets where on the payload the result of the request will be stored.

The above example is saving the result on data.pricing. This field will then include all of the details of the HTTP response, including the status code.

{
  "body" : { ... },
  "headers" : { ... },
  "statusCode" : 200
}

From here, I’d recommend a Switch node to take different paths based on that status code.

You can then attach Webhook Reply nodes to each status code and reply as needed.

That worked like a champ again Brandon. Thanks for your help!