How to use webhooks to access missing fields in apps

  • 7 January 2022
  • 0 replies
  • 774 views

Userlevel 7
Badge +11
  • Community Manager
  • 4577 replies

Hello friends! There can be times when an app integration doesn’t support certain types of fields (usually Custom Fields). Or sometimes fields are missing from the data we receive. While it’s not ideal, it’s not always the end of the world. In some cases you can use a Webhook action to access those fields. 

Freshdesk is one such integration, its Create Ticket action doesn't support custom fields. But we can get around this using a Webhooks by Zapier step.

Obtain an API Key

How and where you’d find the API Key differs between each app. For this example I’m going to be using Freshdesk. To find your API Key in Freshdesk you’d need to go to the Profile Settings page and it will be listed on the right-hand side: 

96380df9b27a844b6d6a445d41a9e4e3.png

Freshdesk - How to find your API key

Double-check the custom field names

The next thing we’ll need is the name of our custom field(s). I’ve set up a custom field in Freshdesk called Faction:
b04ef1f5a7ce396d4a393794d53b0319.png

But when I set up the POST request and used the field name "Faction" it said it was "Unexpected/incorrect":

3f997f1a17d8e5489e67b697ca6f2a29.png

So what is that field actually called? Well, a quick way to find the "correct" name, is to add another Webhook step into the Zap...

Setting up a GET request

Here we’ll make a GET request to view a specific ticket. This will allow us to see the name of the custom field we’re after. This step can be removed from the Zap once we’ve confirmed the custom field name. We don't need a lot of information here.

We only need:

  • The domain name for your Freshdesk instance
  • URL for the request (See the Freshdesk API documentation: View a Ticket)
  • The ID for an existing ticket
  • And your API Key of course!

Let's start with the URL. According to the Freshdesk API documentation this will need to be something like this:

https://domain.freshdesk.com/api/v2/tickets/20

Replace the domain.freshdesk.com with your own Freshdesk domain URL. And replace 20 with the ID number for the ticket.

For the Query String Params section I’ve opted to include the conversations but this part isn’t necessary.

Next, we'll add our API Key into the Basic Auth field in the following format:

OURAPIKEY|X

Note we're using a '|' pipe character here instead of the ':' colon referenced by the Freshdesk documentation.

Then finally, we'll specify a Content-Type of application/json in the Headers section.

Leaving us with a set up that looks like:083041ddfc0b5f7ca8f87aef92b432d8.png

We can then test this step to find the correct name to use for the Faction custom field:724bb718f29ed642e385091745338592.png

As we can see in the above screenshot, the name of the custom field is actually cf_faction, not Faction. Who knew?!

💡PRO TIP: GET requests are also super useful in cases where an integration doesn't have any search actions. Or if the current search action has limitations.

Setting up the POST Request

For this we’ll want to reference the Freshdesk API documentation here: Create a Ticket

Instead of the standard POST event we'll want to select the Custom Request action event:
e1319d6e8bed6791cbb98752517c8fdc.png

This will give us a bit more control over the formatting of our POST request.

For the Method field select the POST HTTP method.

To create a ticket we'll need to use https://domain.freshdesk.com/api/v2/tickets in the URL field. As per the URL for the GET request, we'll want to replace the domain.freshdesk.com with our own domain.

For the Data field we'll need to follow the structure outlined in the API documentation. But the fields may differ depending on your setup in Freshdesk.

Here's a handy example for you to copy into the Data field and edit as necessary:

{
"description": "Details about the issue...",
"subject": "Subject",
"email": "email@address.com",
"priority": 1,
"status": 2,
     "custom_fields" : {
          "cf_customfieldname" : "Value for custom field"
     }
}

You should then end up with something like this:

330879b8a5beb235141efa40e11457fd.png
With the description, subjectemail and cf_faction fields I’ve selected their values from the trigger step. Depending on what values you select from previous steps and what fields you’re using in Freshdesk your set up may look slightly different to the example above. 

And when we test the step, we should then see a new ticket created in Freshdesk with the Faction field filled out, like so:

c61d869beb6c1900428045844b8a2210.png
Success! :tada:

Further reading

Wrapping up!

While I was able to use this workaround for the Freshdesk app, I can't guarantee that using a Webhooks by Zapier action will work for all apps. Depending on the type of authentication the app uses it may be necessary to build a private integration on the Zapier platform instead which is a bit more advanced than the above. 

May the Zaps be with you! :zap:


0 replies

Be the first to reply!

Reply