Proactive events issue

amazon-alexa

#1

I am implementing proactive events in my project. I have checked the proactive events jovo tutorials

my project.js looks like

module.exports = {

   alexaSkill: {
        nlu: 'alexa',
        manifest: {
            permissions: [
                {
                    name: 'alexa::devices:all:notifications:write'
                }
            ],
            events: {
                publications: [
                    {
                        eventName: 'AMAZON.WeatherAlert.Activated'
                    },
                    {
                        eventName: 'AMAZON.SportsEvent.Updated'
                    },
                    {
                        eventName: 'AMAZON.MessageAlert.Activated'
                    },
                    {
                        eventName: 'AMAZON.OrderStatus.Updated'
                    },
                    {
                        eventName: 'AMAZON.Occasion.Updated'
                    },
                    {
                        eventName: 'AMAZON.TrashCollectionAlert.Activated'
                    },
                    {
                        eventName: 'AMAZON.MediaContent.Available'
                    },
                    {
                        eventName: 'AMAZON.SocialGameInvite.Available'
                    }
                ],
            }
        }
    },
    googleAction: {

       nlu: 'dialogflow',

    },

    endpoint: '${JOVO_WEBHOOK_URL}',

};

And the proactive event intent is

  async WeatherAlertIntent() {
    // Sets timestamp to current date and time
    let timestamp = new Date();
    timestamp = timestamp.toISOString();

    // Sets expiryTime 23 hours ahead of the current date and time
    let expiryTime = new Date();
    expiryTime.setHours(expiryTime.getHours() + 23);
    expiryTime = expiryTime.toISOString();

    const proactiveEventObject = {
        "timestamp": timestamp,
        "referenceId": "test-0001",
        "expiryTime": expiryTime,
        "event": {
            "name": "AMAZON.WeatherAlert.Activated",
            "payload": {
                "weatherAlert": {
                    "source": "localizedattribute:source",
                    "alertType": "TORNADO"
                }
            }
        },
        "localizedAttributes": [
            {
                "locale": "en-US",
                "source": "English Weather Channel"
            }
        ],
        "relevantAudience": {
            "type": "Multicast",
            "payload": {}
        }
    };
    const accessToken = await this.$alexaSkill.$proactiveEvent.getAccessToken(
        '',
        ''
    );
    console.log("AccessToken",accessToken)
    const result = await this.$alexaSkill.$proactiveEvent.sendProactiveEvent(proactiveEventObject, accessToken);
    console.log("RESULT",result)
}

I got the access token but while logging the result it shows

httpStatus: 400,
data:
{ type: ‘Bad Request’,
message: ‘Skill amzn1.ask.skill.68e04386-b318-40e1-baa8-6a969d11d6be in development does not have topic AMAZON.WeatherAlert.Activated defined in the manifest’ } }

Please help me to solve the issue.
thanks


#2

Did you build your project.js file and deploy it to the Alexa Developer Console?


#4

thank you .It worked in jovo webhook when I deleted the platform folder and build again. But I want to host it in aws lambda.
my request.js file

const https = require('https');

async function sendRequest(postData) {

    return new Promise((resolve, reject) => {

        const opt = {

            hostname: '',

            path: '',

            method: 'POST',

            headers: {

                'Content-Type': 'application/json',

                'Accept': 'application/json',

                'Content-Length': Buffer.byteLength(postData),

                'Accept-Charset': 'utf-8',

                'Signature': {

                    'SignatureCertChainUrl': 'https://s3.amazonaws.com/echo.api/echo-api-cert.pem'

                }

            },

        };

        const req = https.request(opt, (res) => {

            res.setEncoding('utf8');

            let rawData = '';

            res.on('data', (chunk) => {

                rawData += chunk;

            });

            res.on('end', () => {

                let parsedData;

                if (res.statusCode === 204) { // no content

                    return resolve(res.statusCode);

                }

                try {

                    if (rawData.length > 0) {

                        parsedData = JSON.parse(rawData);

                        return resolve(parsedData);

                    }

                } catch (e) {

                    return reject(JSON.parse(e));

                }

                resolve(res.statusCode);

            });

        }).on('error', (e) => {

            reject(e);

        });

        req.write(postData);

        req.end();

    });

}

let postData = {

    "version": "1.0",

    "session": {

        "new": true,

        "sessionId": "amzn1.echo-api.session.0000000-0000-0000-0000-00000000000",

        "application": {

            "applicationId": "amzn1.echo-sdk-ams.app.000000-d0ed-0000-ad00-000000d00ebe"

        },

        "attributes": {},

        "user": {

            "userId": "amzn1.account.AM3B00000000000000000000000"

        }

    },

    "context": {

        "System": {

            "application": {

                "applicationId": "amzn1.echo-sdk-ams.app.000000-d0ed-0000-ad00-000000d00ebe"

            },

            "user": {

                "userId": "amzn1.account.AM3B00000000000000000000000"

            },

            "device": {

                "deviceId": "amzn1.ask.device.XXXXXA6LX6BOBJF6XNWQM2ZO4NVVGZRFFEL6PMXKWLOHI36IY3B4XCSZKZPR42RAWCBSQEDNGS746OCC2PKR5KDIVAUY6F2DX5GV2SQAXPD7GMKQRWLG4LFKXFPVLVTXHFGLCQKHB7ZNBKLHQU4SJG6NNGA",

                "supportedInterfaces": {

                    "AudioPlayer": {}

                }

            },

            "apiEndpoint": "https://api.amazonalexa.com"

        },

        "AudioPlayer": {

            "offsetInMilliseconds": 0,

            "playerActivity": "IDLE"

        }

    },

    "request": {

        "type": "IntentRequest",

        "requestId": "amzn1.echo-api.request.0000000-0000-0000-0000-00000000000",

        "timestamp": "2019-04-30T12:02:56Z",

        "dialogState": "COMPLETED",

        "locale": "en-IN",

        "intent": {

            "name": "WeatherAlertIntent",

            "confirmationStatus": "NONE",

            "slots": {}

        }

    }

}

postData = JSON.stringify(postData);

sendRequest(postData).then((result) => {

    console.log(result);

}, (reason) => {

    console.log(reason);

});

what are the values I have to give for path and hostname .I tried by giving hostname: {API-GATEWAY-ADDRESS} but getting error.