title: Firestore return after promise
body: <p>I'm using Firestore, Cloud Functions and Dialogflow to create a Google Home app. My cloud function should return a calculation based on values in a collection, but I can only return a Promise.</p>
  
  <pre><code>// query firestore based on user
  var transactions = db.collection('accounts')
                 .doc(request.body.result.parameters.accountowner)
                 .collection('transactions');
  var accountbalance = await transactions.get()
      .then(snapshot =&gt; {
          var workingbalance = 0
          snapshot.forEach(doc =&gt; {
              workingbalance = workingbalance + doc.data().amount;
          });
          return workingbalance
      })
      .catch(err =&gt; {
          console.log('Error getting transactions', err);
      });
  
  console.log(accountbalance)
  balanceresponse = {
      "speech": request.body.result.parameters.accountowner + " has a balance of $" + accountbalance,
      "displayText": request.body.result.parameters.accountowner + " has an account balance of $" + accountbalance,
      "data": {},
      "contextOut": [],
      "source": "system"
  }
  
  response.send(balanceresponse);    
  </code></pre>
  
  <p>How can I wait for the promise to return the actual value before calling response.send? I have also tried to put the response.send inside a then, but the function completes and sends headers before the operation completes.</p>