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:
- Log in to HappyFox as an agent.
- Go to Apps >> Goodies >> API and set up a new API, auth code pair.
- Go to Manage >> Custom fields >> Ticket Fields and create a new custom field.
- Log into Zapier and create a new Zap.
- In the Choose App, choose 'Webhooks by Zapier'.
- 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.
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.