简体   繁体   中英

Dialogflow Webhook (Webhook call failed. Error: 500 Internal Server Error)

I've followed this tutorial's code ( https://dialogflow.com/docs/getting-started/basic-fulfillment-conversation ) to return results of an API to dialog flow. However my webhook keeps failing. Can someone help me figure out why?

Here's one of the failed conversations: 在此处输入图片说明

Here's my code:

'use strict';

const http = require('http');

exports.Hadoop = (req, res) => {
    // Get name node server from the request
    let nameNodeServer = req.body.queryResult.parameters['nameNodeServer']; // nameNodeServer is a required param

    // Call the Hadoop API
    getNameNodeInfo(nameNodeServer).then(function(output) {
        res.json({ 'fulfillmentText': output }); // Return the results to Dialogflow
    }).catch(() => {
        res.json({ 'fulfillmentText': 'getNameNodeInfo() Error'- });
    });
};

function getNameNodeInfo (nameNodeServer) {
    return new Promise((resolve, reject) => {
        // Create url for the HTTP request to get the name node info
        let url = 'http://' + nameNodeServer + '[rest of url]';

        // Make the HTTP request to get the name node info
        http.get(url, (res) => {
            let body = ''; // var to store the response chunks
            res.on('data', (chunk) => {body += chunk; });
            res.on('end', () => {
                // After all the data has been received, parse the JSON for desired data
                let response = JSON.parse(body);
                let beans = response['beans'][0];

                // Create response
                let output = `Percent Used: ${beans['PercentUsed']}`;

                // Resolve the promise with the output text
                console.log(output);
                resolve(output);
            });
            res.on('error', (error) => {
                console.log(`Error calling the Hadoop API: ${error}`);
                reject();
            });
        });
    });
}

I believe the getNameNodeInfo function and the retrieval of the name node server are correct, as they logged the correct output in debugging.

Diagnostic Info: 在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

I contacted someone at Dialogflow and this was their response.

Thank you for providing all the information. I have observed in your code that you have used http requests instead of https. The service must use HTTPS and the URL must be publicly accessible in order for the fulfillment to function. Dialogflow does not support self-signed SSL certs. For information on SSL setup, please refer to this : https://developers.google.com/web/fundamentals/security/encrypt-in-transit/enable-https

We've had a somewhat different, but related, issue:

Internal Server Error when running an agent.

“status”: {
   “code”: 500,
   “errorType”: “internal_server_error”,
   “errorDetails”: “Internal Server Error”
},

This error was not caused by any changes we introduced. We are using that agent in a dev version of an app and one morning it stopped working.

We tested by creating a .zip and restoring into a new agent. The new agent would work properly, but we would continue to get the 500 error on the agent hooked into our dev app. We submitted a help request and overnight the error got resolved. We suspect that DialogFlow team had to manually reboot the server or something similar.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM