如何在行编辑器的dialogflow中调用外部api?

时间:2019-05-06 15:30:56

标签: api external dialogflow-fulfillment

dialogflow中调用外部api时遇到问题,我需要一些帮助。

您将在下面找到我的代码:index.js

我收到此错误:

  

错误:无法处理请求

const functions = require('firebase-functions');
    const {WebhookClient} = require('dialogflow-fulfillment');
    const {Card, Suggestion} = require('dialogflow-fulfillment');

    process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements

    exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
      const agent = new WebhookClient({ request, response });
      console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
      console.log('Dialogflow Request body: ' + JSON.stringify(request.body));


    function country(agent) {

        const request = require('request-promise-native');
        const url = "https://xxxxxxxxxx.hanatrial.ondemand.com/public/DBtest/xx.xsjs";
        agent.add(`Found a country:`);

          var options = {*strong text*
           uri: url,
           json: true };
      return request( options )

0 个答案:

没有答案