Automating Freshdesk Workflows: Using REST API to Auto-Populate Ticket Fields

In today’s fast-paced customer service environment, automating workflows is key to maintaining efficiency and delivering a seamless experience for both agents and customers. Freshdesk, with its powerful automation features, allows you to streamline processes by integrating external services. One common scenario is calling a REST API when a ticket is created and using the result to auto-populate some fields.

In this blog, we’ll walk through setting up an automation rule in Freshdesk to call a web service and fill ticket notes with the returned data.

Why Automate Ticket Notes?

Automating the notes field based on data from an external source can be incredibly useful. For example:

  • Automatically fetching and documenting customer details or purchase history.
  • Adding relevant product or service info based on the ticket content.
  • Logging external system status or response, such as shipping or billing information.

Step-by-Step Guide to Automating REST API Calls on Ticket Creation

1. Setup Your Freshdesk Environment

Before we begin, ensure that:

  • You have access to Freshdesk’s Admin panel.
  • Your API integration requires admin access or permission to configure workflows.
  • The REST API endpoint you plan to use is well-documented and allows interaction (including access keys or authentication).

2. Plan Your API Call

Identify the REST API you will call every time a ticket is created. It could be anything, such as fetching customer records, product information, or shipping updates.

  • Example API: Let’s assume we are calling a REST API to fetch customer order details, and we want to log the order status in the ticket notes.

Sample API Endpoint:

GET https://exampleapi.com/orders?ticketId={ticketId}

The API returns a JSON response:

{

    “orderId”: “12345”,

    “status”: “Shipped”,

    “expectedDelivery”: “2024-10-12”

}

We’ll use this information to populate the Notes section of the ticket.

3. Creating a Webservice Call the API

Freshdesk allows you to trigger webservice call whenever a ticket is created or updated. Here’s how to configure that:

  1. Go to Freshdesk’s Automation Rules:
    • Navigate to the Admin section.
    • Under Automation & Productivity, select Workflow Automator.
    • Create a new rule by clicking New WorkFlow.(Make sure the workflow type is selected as “Event Based Workflow”)
  2. Create a New Workflow Rule:.
    • Name your rule something like “Fetch Order Details on Ticket Creation.”
    • Select Module as Tickets if not already selected.
    • Recheck the workflow type.
    • Create
  3. Set Conditions:
    • In the conditions section, specify when the rule should be triggered. For example, if you want it to trigger for specific tickets, set criteria based on the ticket source, group, or any other attribute.
    • For this case, we will trigger it whenever a ticket is raised without any additional filters.
  4. Add a Webrequest Action:
    • Drag and drop the webrequest node from the toolbar on the left to extend the event node.
    • Fill in the following details:
      • Request Type: GET
      • Endpoint:: https://exampleapi.com/orders?ticketId={{ticket.id}}
      • Authentication: (If your API requires authentication, include the necessary headers or API keys here.)
      • You can test the webservice response by clicking the “Test Web Request”.

4. Capture the API Response and Insert it into Ticket Notes

Once the webservice response, we need to parse the data and add it to the ticket’s notes.

  1. Handle the Response:
    • Optionally, you can add a condition to check the returned Status code to direct how you want to handle the response. This can be done by drag and drop the condition node and adding the different status codes conditions.
  2. Parse the response:
    Use the JSON parser node to parse the response from the webservice. This gives you a structured representation of the response that you can analyze and look for the right node(s) to retrieve. For Source select webserviceNodeName.response.
  3. Retrieve the Right Node value:
    Use the Expression Builder node to retrieve the right output from the parsed response. Based on your criteria you can use freshdesk available functions to process the data according to your use case.
  4. Insert the processed data into ticket notes:
    Use the Action node, with Ticket as the object to Perform actions on.
    Add Note from the drop down list.
    In the Description add the Expression builder expression using the insert Placeholder link.

5. Save and Activate the Workflow

After configuring the Nodes and notes, save the rule. Make sure the rule is active, so it triggers every time a ticket is created.

6. Testing the Automation

Now, it’s time to test the automation. Create a sample ticket in Freshdesk and observe the following:

  1. Ticket Created: A new ticket is created either by email or through the customer portal.
  2. Webhook Triggers: The automation rule triggers a webhook that calls the external API.
  3. Notes Updated: The API response is parsed, and the ticket’s notes are updated with the relevant details.
  4. You can also check the “View execution logs” from the workflow builder page for your workflow to debug the flow and the events of execution.

7. Error Handling and Monitoring

You should also account for errors or cases where the API doesn’t return data. Use Freshdesk’s condition node or expression builder to handle scenarios where the API might return an empty response or error message. You can log such errors as notes, or send alerts to admins if needed.

Conclusion

By leveraging Freshdesk’s workflow automation and integrating with external REST APIs, you can significantly enhance the efficiency of your support process. Automating the population of ticket notes based on real-time API data ensures that agents always have the most relevant information at their fingertips, reducing time spent switching between systems and improving overall customer experience.

This type of automation opens the door to endless possibilities, from tracking shipments to fetching customer account details, making your Freshdesk setup even more powerful.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.