How to get webhook-style notifications when a new location is added

In all our service items, we have the office Location as a mandatory field. From an external broker, when I am making a createTicket API call, I need to pass the location ID - hence, I have downloaded the locations using the getAllLocations API and stored it locally - this is getting used by the createTicket API call . However, new locations could be added and I need a mechanism to keep the list of locations in sync with FreshService. Ideal would be if there is a way to get notified about changes to locations, but I could not find such an API - is there any workaround/clever hack to get an update about addition/updates the location?

Or is there any other way to get the location in sync without frequent polling as locations are added rarely. Notification on locations - add or update How to get webhook-style notifications when a new location is added

Hmm…

From what I understand,

  1. The Freshservice Account has Service Items with the ‘Location’ field on each service item.
  2. Now, from a different runtime (let’s assume out side Freshworks), the broker makes a create ticket API call to Freshservice. Of course, somehow you also get all the locations at one time.

The problem is your broker needs to have an updated list of these locations.

Here’s what you can maybe do:

You can build a custom app on the Freshworks platform that runs a corn job. We label it as scheduled events.

// register a recurring schedule maybe once a day onAppInstall

let scheduleDetails = {
        name: args.scheduleName,
        data: args.scheduleData,
        schedule_at: args.scheduleData.scheduleAtUTC
      };
      let scheduleCreationStatus = await $schedule.create(scheduleDetails);

exports = {
 onScheduledEventHandler: async function (payload) {
/*      
      1. Make getAllLocations API call
      2. Store the locations and send it to the broker. (The broker needs to open up an endpoint
          to receive the details.)
      3. Look if there are new updates to store in the broker. Every Day.
  }
}

You can learn from about building apps

  1. Introductory guide to Freshworks App Development
  2. Documentation: Scheduled Events
  3. Tutorials if you prefer to: Deep-dive into Serverless, Introduction to Freshworks Serverless Apps