Product Event - Not Getting Triggered

Hi,
I am facing an issue in onTicketCreate and onTicketUpdate events not getting triggered in the serverless app
It working fine in local but not working in the custom app

Below is the Manifest.json file

{
  "platform-version": "2.2",
  "product": {
    "freshservice": {
      "events": {
        "onTicketCreate": {
          "handler": "onTicketCreateHandler"
        },
        "onTicketUpdate": {
          "handler": "onTicketUpdateHandler"
        },
        "onScheduledEvent": {
          "handler": "onScheduledEventHandler"
        }
      }
    }
  },
  "whitelisted-domains": [
    "https://app.lansweeper.com",
    "https://api.lansweeper.com",
    "https://cresthelpdesk.freshservice.com"
  ],
  "engines": {
    "node": "14.20.0",
    "fdk": "8.5.0"
  }
}

Below is the server.js file

exports = {
  
  
  onTicketCreateHandler: async function (payload) {
    try {
      console.info("args ", JSON.stringify(payload));

      let finalresult = [];
      let i = 0;
      let per_page = 20;
      do {
        i = i + 1;
        console.log("I ", i);
        let headers = {
          "Content-Type": "application/json",
          "Authorization": "Basic <%= encode(iparam.api_key) %>",
        };
        let url = `https://domain.freshservice.com/api/v2/products?per_page=${per_page}&page=${i}`
        console.info("url ", url);

        await $request.get(url, { headers }).then(function (data) {
          // success
          console.info("sites ", data);
          let result = JSON.parse(data.response)
          console.info("result ", result.products);

          finalresult = result.products;
          console.info("result ", finalresult.length);

        }, function (err) {
          // failure
          console.error(err);
        });
        // success

      } while (i < 551);
    } catch (ex) {
      console.log("ex ", ex)
    }
  },

  onTicketUpdateHandler: function (payload) {
    console.info("args 11 ", payload);

    let headers = {
      "Content-Type": "application/json",
      "Authorization": "Bearer <%= access_token %>"
    };
    let reqData = {
      headers: headers,
      isOAuth: true,
      body: JSON.stringify({
        "query": "{ authorizedSites { sites { id name } } }"
      })
    };
    let url = "https://api.lansweeper.com/api/v2/graphql"

    $request.post(url, reqData)
      .then(function (data) {
        // success
        console.info("sites ", data);
      }, function (err) {
        // failure
        console.error(err);
      });
  },

  onScheduledEventHandler: function (payload) {
    console.log("Logging arguments from onScheduledEvent: " + JSON.stringify(payload));
    if (payload.data.account_id = "3") {
      //your code to perform any actions
    }
  }
};

So I am not getting what is wrong in above structure?
Anybody can help

Thanks !!

I can find nothing wrong with the code you posted.

Can you try creating a new trial account and uploading the app to test there?

If the same events work in another account, there might be something wrong with the present account and we will have to involve Marketplace support.

1 Like

I have tried to upload the same app to another account

But it is still not working

Can you help!!

@devrels Can one of you please take a look at the code here? I don’t see anything outright wrong, but I may have missed something.

@Anushka_Ahir Please allow us a while to get back. The whole team is busy with or travelling for our upcoming developer summit. :slight_smile:

Hi @kaustavdm ,

Any updates on the above topic?

Thanks!!

Hi @kaustavdm ,

Any updates?

Thanks!!

I do not have any updates and sorry for the delay.

Can you please book an office hour with the devrel team to run through the code?

@Anushka_Ahir How is the events are tested to confirm if they are working?
Are you checking the Serverless logs?

Hi @Raviraj ,

I have tested this functionality using a custom app, I have tested like created the ticket and checking the logs that event is getting triggered or not

Yes, I have checked serverless logs but no logs are getting display because event is not triggering

Thanks!!

Hello @Anushka_Ahir

Would it be possible for you to share a small video demonstrating the problem? We would like to see how you are testing the app and what you are looking for when you test your app. Please do capture the published app, its installation as well as part of the video.

I got on a call with the team and I was told that the issue has fixed itself after they packaged the zip and uploaded it as a new app in the same account. I wonder if something went wrong with our app publishing services when registering events for the previous app.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.