Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Voice User Interface Projects

You're reading from   Voice User Interface Projects Build voice-enabled applications using Dialogflow for Google Home and Alexa Skills Kit for Amazon Echo

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher Packt
ISBN-13 9781788473354
Length 404 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Henry Lee Henry Lee
Author Profile Icon Henry Lee
Henry Lee
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Introduction 2. Building an FAQs Chatbot FREE CHAPTER 3. Building a Fortune Cookie Application 4. Hosting, Securing, and Testing Fortune Cookie in the Cloud 5. Deploying the Fortune Cookie App for Google Home 6. Building a Cooking Application Using Alexa 7. Using Advanced Alexa Features for the Cooking App 8. Migrating the Alexa Cooking Application to Google Home 9. Building a Voice-Enabled Podcast for the Car 10. Hosting and Enhancing the Android Auto Podcast 11. Other Books You May Enjoy

Securing the Node.js webhook for Dialogflow

You will now make slight modifications to the Node.js code in order to secure the webhook. The one you deployed is not secure and anyone can access it.

  1. Go to Dialogflow and to the Fulfillment section.
  2. In the headers, add the key mysecret and the value 12345.

The following screenshot shows the security header added to the webhook:

Securing the webhook
  1. Edit server.js. Add code that extracts the mysecret key using let secret = req.get("mysecret"). Then, check the value and see if it is equal to 12345. If it is equal, process the request, and if not, return a 403 access denied response return response.status(403).end('Access denied!').

The following code shows the modified code that secures the webhook:

app.post('/fortuneCookie', function (req, res) {
let secret = req.get("mysecret");
if...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime