Forum Discussion

Christopher-'s avatar
Christopher-
Icon for LM Champion rankLM Champion
8 years ago

Basic Freshdesk Integration

The following guide is an example of a custom http integration using the Freshdesk API along with some of LogicMonitor's token values. 


To start off I would recommend reviewing the following resources. 

LogicMonitor Custom HTTP Delivery Documentation:
https://www.logicmonitor.com/support/settings/integrations/custom-http-delivery/

LogicMonitor Tokens: NOTE: (In this guide I create a token ##freshdesk.requesterid## using a custom property on the device. This allows me to pass this value through the integration. This can be very useful if you need to use the same integration to create tickets as multiple organizations or users. I've included a screenshot below detailing where this is set on the device.)
https://www.logicmonitor.com/support/settings/logicmodules/tokens-available-in-datasource-alert-messages/

YBtDKke.png

 

Freshdesk API Documentation:
https://developer.freshdesk.com/api/

Complete these steps in Freshdesk prior to creating your integration:

Create a Freshdesk User to be used for authentication.
https://support.freshdesk.com/support/solutions/articles/37591-adding-new-support-agents-

 

In the below payloads I use the Freshdesk requester_id as a token to create, update and close tickets. You can find the requester_id for a Freshdesk user by checking the following. 

 

wfzpr1n.png

 

Configure your Freshdesk API key for authentication.
https://support.freshdesk.com/support/solutions/articles/215517-how-to-find-your-api-key

Complete these steps in LogicMonitor to create the Integration:

  • Add a new Custom HTTP Delivery under Integrations using the following payloads as a starting point.
  • Determine if you would like to use a wildcard for things such as your Freshdesk requester_id or organization_id etc.

Payload Examples:

The following examples will Create, Update and Close FreshDesk tickets with LogicMonitor Alerts.

NOTE: When authenticating with the Freshdesk api, you will only need to enter your api key in the username field, the password is blank. 

 

SPwvew5.png

 

Active: 

{ "description": "Host: ##HOST##\nDatasource: ##DATASOURCE##\nDatapoint: ##DATAPOINT##\nLevel: ##LEVEL##\n Start: ##START##\nDuration: ##DURATION##\nValue: ##VALUE##\nReason: ##DATAPOINT## ##THRESHOLD##", "subject": "##LEVEL## - ##HOST## ##INSTANCE##", "requester_id": ##freshdesk.requesterid##, "priority": 1, "status": 2 }

xRR6Gty.png

Escalated:

{ "description": "Alert Escalated/De-escalated\nHost: ##HOST##\nDatasource: ##DATASOURCE##\nDatapoint: ##DATAPOINT##\nLevel: ##LEVEL##\n Start: ##START##\nDuration: ##DURATION##\nValue: ##VALUE##\nReason: ##DATAPOINT## ##THRESHOLD##", "subject": "##LEVEL## - ##HOST## ##INSTANCE##", "requester_id": ##freshdesk.requesterid##}

isN3erl.png

 

Acknowledged:

{ "body":"Note: ##MESSAGE##" }

N9KnSdM.png

Cleared: 

{ "description": "Alert Cleared\nHost: ##HOST##\nDatasource: ##DATASOURCE##\nDatapoint: ##DATAPOINT##\nLevel: ##LEVEL##\n Start: ##START##\nDuration: ##DURATION##\nValue: ##VALUE##\nReason: ##DATAPOINT## ##THRESHOLD##", "subject": "##LEVEL## - ##HOST## ##INSTANCE##", "requester_id": ##freshdesk.requesterid##, "priority": 1, "status": 4 }

lrmacMI.png

 

 

Here we can see the finished product, a ticket generated and cleared using the above payloads. 

Active Warn:

9yG1Deo.png

Active Error:

TqARusp.png

Active Critical:

B2fd61I.png

Active Critical Ack: 

akFT9ai.png

Cleared: (Note that the Status changes to Resolved)

gQgOGp8.png

  • @MaddyM no, I never saw that error.

    That looks like a message from FreshService rather than LM, so I suspect it’s a Fresh user issue.

    I suspect the Fresh docs mean “A Fresh user for LM”, rather than the credentials of an LM user, but that’s just a guess at this point.

  • Hi @Antony Hawkins,

    I’m working on using the custom http delivery to integrate FreshService with LM and am running into the following error whenever I try to test my alert:

    {"code":"not_authorized","message":"You are not authorized to access AMS"}

    Did you see this error at all when you were configuring your integration? According to the Fresh Service documentation a LM username and password should be used in the integration credential fields. We have SSO set up in both systems and I’ve tried several LM accounts that also have access to create tickets in FreshService but continue to receive the error. I’ve reached out to FreshService support but I’m not having much luck. 

  • Further comments... I've just used almost all of this to integrate to:

    https://<my-customer>.freshservice.com/api/v2/tickets/

    (note, freshservice.com not freshdesk.com)

    We needed to also add a "group_id" field and integer value into the JSON payloads (can be tokenised as per requesterID and _api.key values); we also needed to add a "category" field and value as my customer's FreshService setup has this as a mandatory field with a defined list of acceptable values - you may therefore need to do the same or similar additions for any fields your setup defines as mandatory.

    Finally, the JSON path for the created ticket ID from FreshService is (certain for my customer's version) at ticket.id, not merely id.

    However, all of these things were very easy to learn from the Integration Logs within LogicMonitor and the results of attempting test alert deliveries, so many thanks @Chris Seiber for providing 98% of the necessary work!

  • @Chris Seiber - It looks like this is actually working despite the above now.  I think the problem was I had some additional attributes set for Freshdesk that despite being supported by the API didn't seem to go through (which caused the entire update to fail).  So I think I'm good now on this but do still think the HTML formatting I mentioned may be helpful to others.

  • I've also just done a test to create a new escalation chain with only the ticket update integration on it, but no improvement.  I get this for ##EXTERNALTICKETID##:

    Freshdesk - Create and Update Tickets : 20024

    I will report back if I find anything new.

  • Correction on the above - I do see that "id" can also work but results in the same thing.  I was just going off of what I was aware of as "proper" path syntax... but in any case, it still seems to work that way.  So, again, the main issue now seems to be the extra text added to the ##EXTERNALTICKETID## property which has nothing to do with the JSON response AFAIK.  

  • @Chris Seiber thanks for posting this.  I have found a couple of things when setting this up and thought I'd share (and ask for feedback):

    1.  To properly format the message in the ticket you need to use HTML.  In other words you need to use <br> instead of \n for a line break.

    2. The JSON path you have doesn't seem valid.  I was able to use $.id to get the ticket ID... however there is an issue with that (see below).

    When I get the ##EXTERNALTICKETID## it is coming back like this:

    Slack Integration : -1, Freshdesk - Create and Update Tickets : 20018

    Where the first part before the colon are the display names of all integrations used on the alert (note the first one is for Slack and the second is for Freshdesk).  If I only had the Freshdesk integration configured, it would likely say "Freshdesk - Create and Update Tickets".  The part after the colon is the actual ticket number.  Do you have any thoughts on how to strip off the first part?  I know you support regular expressions but then that doesn't seem to be usable at teh same time as JSON for the ##EXTERNALTICKETID## mapping.  Is this a bug in your software that is including this in the property to begin with given I don't see how we could possibly get those values (the integration labels) from the JSON response itself (I don't see them when I do a test).

  • Anonymous's avatar
    Anonymous

    Chris, I'm working on implementing this and the test's all work correctly.  However, tickets are not being created when alerts fire.  I have case #83246 entered to see if I can get some assistance and hopefully we can get this flushed out.