You are using an unsupported browser. Please update your browser to the latest version on or before July 31, 2020.
close
Home > HappyFox Help Desk > Tips and Tricks > Set custom fields via Smart Rules using Zapier
Set custom fields via Smart Rules using Zapier
print icon

Introduction:

While HappyFox currently doesn't allow you to set or clear custom fields using Smart Rules directly, this can be achieved using HappyFox Webhooks and Zapier. In the following example, the custom field 'Remarks' is set as 'RMA approved' if the ticket is moved to 'Open' status.

Requirements:

  • A live HappyFox account.
  • A live Zapier account (Any Paid plan - refer to Zapier pricing).
  • Some developer experience is nice to have, in case you are planning to alter the behavior.

Steps to set up:

  1. Log in to HappyFox as an agent.
  2. Go to Apps >> Goodies >> API and set up a new API, auth code pair.
  3. Go to Manage >> Custom fields >> Ticket Fields and create a new custom field.
  4. Log into Zapier and create a new Zap.
  5. In the Choose App, choose 'Webhooks by Zapier'.
  6. Choose 'Catch Hook' in the Choose Trigger Event and click on Continue.

6. Custom Webhook URL appears. Copy this webhook URL to the clipboard. Ignore the 'Pick off a Child key' option and go to the next step.

7. In HappyFox, open Automate >>Smart Rules and create a new smart rule of Trigger Webhook under Notify. In the new rule, set your conditions for the smart rule which should trigger the custom field change. In the Choose Actions, choose Trigger Webhook. Paste the webhook URL copied from step 6 here.

Note: If you are not seeing 'Trigger Webhook' option, go to Apps >> Goodies >> Webhooks and make sure Webhooks active is set as Yes. When Zapier prompts you, Trigger a test webhook by creating a new ticket and satisfying the smart rule conditions at this stage, to see if the webhook is received by Zapier. This is required for the following steps.

8. In Zapier for the Action app click 'choose app' and pick 'Code by Zapier' and pick 'Run Python' as the 'Choose Action Event'.

9. In the set template part under input date, give ticket-id as the name of the field and pick 'Step1: Ticket Id'. In the code area paste the following code:

import requests

url = 'https://<subdomain>.happyfox.com/api/1.1/json/ticket/' + input['ticketid'] +'/staff_update/'

auth = (‘<api key>', ‘<authcode>')

payload = {'staff' : '1', 't-cf-<ticket field ID>' : ‘<value>'}

res = requests.post(url,auth=auth,data=payload)

output = [{'dummy': 'output'}]

10. Finally, replace the < placeholder > items with your account information. After this step, the set page will look like this.

11. On running the test, when your smart rule conditions are met, HappyFox triggers the webhook URL, which then invokes the python script to set the custom field to a pre-determined value automatically.

Feedback
1 out of 2 found this helpful

scroll to top icon