Wednesday, 15 March 2017

api.ai webhook not working on heroku, error 206 partial content

I'm trying to just get the basic node.js webhook echo example working on heroku. However I keep getting 206 errors. I've heard this can be from redirects that heroku does or from incomplete json. Any help here?

I also attached my intents screenshot on api.ai

enter image description here

I get this same error with the yahoo weather sample python app, so i'm not sure whats going on, as that is all api.ai configuration.

and i asked the question here as well https://discuss.api.ai/t/webhook-issue-error-206/4535/4

my code is as follows, i'm new to node.js, is something wrong? I added fields for what i thought api.ai needs in its JSON.

app.post('/hook', function(req, res) {
console.log('hook request');

try {
    var speech = 'empty';
    if (req.body) {
        if (req.body.result) {
            speech = '';

            if (req.body.result.fulfillment) {
                speech += req.body.result.fulfillment.speech;
                speech += ' ';
            }

            if (req.body.result.action) {
                speech += 'action: ' + req.body.result.action;
            }
        }
    }

console.log('result: ', speech);

return res.json({
    speech: speech,
    displayText: speech,
    data: [],
    contextOut: [],
    source: 'carstatus'
});



via MadeByDouglas

No comments:

Post a Comment