1

I'm able to get the webhook response in dialogflow cx. but I need to return my custom event name as webhook response. I used below code to trigger custom event inside the fulfillment it was not worked for me. any idea for better solution.

exports.cxWhatsappAgent = (req, res) => {
     return axios
      .get(
        `$apiURL`,
        { data: {} }
      )
      .then(
        (result) => {
          if (result.data.length > 0) {
            var responseText = "Hi Welcome";
       
      res.status(200).send({
          event: "REGISTERED-USER"
         });
       }
        },
        (error) => {
          console.log(error);
        }
      )
      .catch((error) => {
        
      });
};
Oshini
  • 613
  • 4
  • 17
  • Can you share the code of your webhook so it can be easily reproduced by the community members? As well as a high level flow of your bot if possible. – Ricco D Sep 06 '21 at 03:21
  • It's difficult to share entire code. Now I just edit the post . flow-> Once user type hi check this user is valid user or not. if valid then try to access my custom event ("REGISTERED-USER"). that will redirect user to different page – Oshini Sep 06 '21 at 06:44
  • What is the value `$apiURL`? Just to confirm this line of code `res.status(200).send()`, are you trying to send a request to Dialogflow API that contains the body `event: "REGISTERED-USER"`? If so, what Dialogflow endpoint are you trying to access? But please let me know if I'm mistaken. – Ricco D Sep 06 '21 at 08:52
  • ```$apiURL``` this is our private network own API url that used to retrieve some data. After receive some data from that API (Inside then) try to trigger my custom event (event name is REGISTERED-USER) – Oshini Sep 06 '21 at 09:36
  • Do you encounter any error? If you encounter an error what is the error message? Do you have a response from the Dialogflow API when triggering the custom event in your code? – Ricco D Sep 07 '21 at 01:42

0 Answers0