title: Fill intent based on result of API call in Dialogflow Fullfilment
body: <p>I am struggling to get the following fullfilment code for Dialogflow to work: </p>
  
  <pre><code>'use strict';
  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) =&gt; {
  
    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 testHandler(agent){
      var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
      var xmlhttp = new XMLHttpRequest();   // new HttpRequest instance
      const proxyurl = "https://cors-anywhere.herokuapp.com/";
      var theUrl = "http://xxxxx/sum?a=5&amp;b=11";
      var url = proxyurl + theUrl;
      var result = "Init";
  
      getText = function(url, callback)
      {
        var request = new XMLHttpRequest();
        request.onload = function()
        {
          if (request.readyState == 4 &amp;&amp; request.status == 200)
          {
            callback(request.responseText);
          }
        };
        request.open('GET', url);
        request.send();
      }
  
      function mycallback(data) {
        agent.add("DATA:" + data);
      }
  
      return getText(url, mycallback);
    }
  
    let intentMap = new Map();
    intentMap.set('test', testHandler);
    agent.handleRequest(intentMap);
  });
  </code></pre>
  
  <p>The line <code>agent.add("DATA:" + data);</code> does not have any effect. When trying the code in the browsers and changing <code>agent.add("DATA:" + data)</code> to <code>document.write("DATA:" + data)</code>, everything works just fine. 
  I am new to Dialogflow; any hint why this callback does not seem to work?</p>