Search code examples
node.jspromiseactions-on-googlegoogle-home

Actions On Google Async Issue: Error: No response has been set


Receiving the following error on my Google Diaglogflow intent from the intent below. The console.log("res", res) is correctly logging the JSON, but Error: No response has been set. Is this being used in an async call that was not returned as a promise to the intent handler? is logged immediately before it.

app.intent(DO_MY_THING, conv => {
  console.log("DO_MY_THING");
  axios
    .get("example.com")
    .then(res => {
      console.log("res", res);
      conv.close("Did the thing");
    })
    .catch(err => {
      console.log("err", err);
      conv.close("didnt do the thing");
    });
});

Solution

  • If you're doing an asynchronous callback, you need to return the Promise object.

    app.intent(DO_MY_THING, conv => {
      console.log("DO_MY_THING");
      return axios
        .get("example.com")
        .then(res => {
          console.log("res", res);
          conv.close("Did the thing");
        })
       .catch(err => {
         console.log("err", err);
         conv.close("didnt do the thing");
       });
    });