Errors with deploying to Alexa

amazon-alexa

#1

I have my endpoint set up on Google Cloud Functions and have also followed the verification instructions to get the system to work with Alexa but I keep getting the same errors

The skill end-point is not validating the signatures for incoming requests and is accepting requests when no signature URL headers are specified. Please make sure that your signature validation is correct. To reject an invalid request with an invalid signature or certificate, the skill should respond with HTTP status code 400 (Bad Request) in the response.

index.js

'use strict';
require('dotenv').config()
const { WebhookVerified: Webhook, ExpressJS, GoogleCloudFunction } = require('jovo-framework');
const { app } = require ('./app.js');

// ------------------------------------------------------------------
// HOST CONFIGURATION
// ------------------------------------------------------------------

// ExpressJS (Jovo Webhook)
if (process.argv.indexOf('--webhook') > -1) {
    const port = process.env.JOVO_PORT || 3000;
    Webhook.jovoApp = app;

    Webhook.listen(port, () => {
        console.info(`Local server listening on port ${port}.`);
    });

    Webhook.post(['/webhook','/webhook_alexa'], async (req, res) => {
        await app.handle(new ExpressJS(req, res));
    });
}

exports.handler = (req, res) => {
    app.handle(new GoogleCloudFunction(req, res));
    // app.handle(new ExpressJS(req, res));
};

Can anyone tell me if I’m doing something wrong


#2

Hi @Adnan_Aga, did you try this code example?


#3

Hey jan, just tried this and it worked however I had to throw in this line to check where the request was coming from as it was failing on Google Assistant saying missing cert url but it looked like that worked!

UPDATE: This method fails the validation checks on Amazon so do you have any ideas @jan

// Google Cloud function
exports.handler = async (req, res) => {

    if(req.request !== undefined) {
        try {
            await verify(req)
            await app.handle(new GoogleCloudFunction(req, res));
        } catch(e) {        
            console.log(e);
            res.status(400).json({ status: 'failure', reason: e.message })
        }
    } else {
        app.handle(new GoogleCloudFunction(req, res));
    }
};