Email Trigger based on custom date field


10 댓글

  • Joel Hellman

    Hi Travis, I can't of a simple way to do this either. Date and time based logic in Zendesk are in much need of improvements. 

    That said, I have a workaround you might consider using a second field holding the due date, a trigger (or an automation) and a HTTP target.

    I'll just go through the parts specific to the dates, but you'll have to figure out how to modify the trigger/automation conditions yourself to suit your situation.

    Using a second date field holding the due date

    If you add another custom field that hold the due date, and initialize it when your first custom date field is set, you could then use a automation condition like this to fire off your automation like this:

    (I use a larger value for days since its conceivable you'd have situations where you initialize the due date when it's already way due.)

    Since Zendesk doesn't have calculated fields or business rule actions to do field calculations, you'd need something like a HTTP target to initialize this followup field based on the value of the delivery date field.

    Making a HTTP Target to update tickets

    Set up a HTTP target (Settings>Extensions>HTTP target) like this:


    The URL string should look like this:


    For reference, you are setting up the target to work the REST API of Zendesk documented here:


    You need to provide credentials when using a HTTP target to call Zendesk this way. 

    • The username is hard coded, you might use a dedicated user account for this, or re-use an existing user.
    • The user permissions will apply, so best use a user with admin privileges or appropriate custom role.

    Use credentials either like:

    • user_email
    • user_password

    or if you prefer to use an API token you have set up

    • user_email/token
    • api_token

    Setup your trigger (or automation) 

    Next would be to setup a trigger or automation that activates your HTTP target to update a the ticket's second date field to the value of the first date field + 14 days. 

    First, find out your custom ticket IDs:

    • Add that second custom date field to hold the follow due date if you haven't already.
    • You'll find the ticket field IDs if you go to settings>manage>ticket_fields>[click on ticket field]

    Let's say you have two fields like this (your IDs will differ):

    • Delivery Date (ID 33382889)
    • Delivery Followup Date (ID 33511485)

    Then the action part of the trigger should look like this:

    We use Zendesk placeholders and liquid markup to calculate the second date value based of the first date value, and when the HTTP request is sent, the resulting JSON payload will looks like this:

    Here is the JSON body to copy-paste:

    "ticket" : {
    "custom_fields": [
    "id": 33511485,
    "value": "{% unless ticket.ticket_field_33382889 == blank %}{{ ticket.ticket_field_33382889 | date:'%s' | plus:1209600 | date:'%F' }}{% endunless %}"

    (Modify the IDs in this example, so the ID in the id field refer to your Delivery Followup Date field, and the ID in the value field refer to your Delivery Date.)

    Explanation of the liquid code for the value calculation

    {% unless ticket.ticket_field_33382889 == blank %}...{% endunless %}

    We only want set the followup date if the Delivery Date has a value, and if there is no Delivery date, there should be no followup date either.

    {{ ticket.ticket_field_33382889 | date:'%s' | plus:1209600 | date:'%F' }}

    Here we

    • read the Delivery Date value
    • covert it into a unix timestamp (%s, seconds since Number of seconds since 1970-01-01 00:00:00 UTC)
    • add 14 days (86400 seconds per day times 14 days=1209600 seconds)
    • format the new value back into the The ISO 8601 (%F) date format (YYYY-MM-DD) that Zendesk accepts


    Using HTTP targets this way is not really supported by Zendesk, meaning you can do it, but if you need to troubleshoot you might have to do it yourself. HTTP targets are more meant to deliver information to 3rd party systems.

    Using HTTP targets this way, you'll have no feedback when the targets fail. You might use the 'Test Target' option in the edit target page to check your target if it doesn't seem to work.

    This is one way to do it using only Zendesk. The "proper" way to this kind of operation using a Zendesk trigger and HTTP target would be to point the target to a web service, and have that web service call back to Zendesk to update the ticket. Then you'd have logs, error handling etc. 

    The Zendesk agent interface is not always updated when a HTTP target fires in this way, or sometimes the update is delayed a bit. Reload the ticket if in doubt. This is only relevant if you actually show the ticket field in the ticket (if you are using ticket forms). You don't actually need to show the second date field to the ticket (i.e. in a form) for this to work. 

    This will only work if you are on an appropriate Zendesk plan where you have access to targets and custom triggers and liquid markup. 



  • Joel Hellman

    Here is how it might look in case you have the Delivery Date Followup field showing in the ticket. 

    Showing the field in the ticket is not necessary for the HTTP target or triggers/automations to work, though.

  • Travis Abdelhamed

    Wow Joel, thank you for the detailed explanation! This is an incredible amount of effort to accomplish something so simple.

    Hopefully there will be other solutions native to Zendesk

  • Joel Hellman

    You're welcome. I agree with you, by the way :)

  • Joel Hellman

    FYI: Travis made a feature request on this topic. 

  • Andrew J
    Community Moderator

    Have you looked at using the 'Task' Due date option instead?  Of course this may not suit what you are doing.

    It gives more options.

  • Andrew J
    Community Moderator

    Also - we've been using the Sweethawk deadline app  which is a very effective date app - once again may not suit your application.

  • Travis Abdelhamed

    Thanks for the feedback Andrew!

  • Thomas D'Hoe


  • Nicole Saunders
    Zendesk Community Manager

    Hey Thomas - 

    Are you +1-ing the OP or one of the comments? Adding your +! by voting with the arrow buttons helps specify which thing you're responding to. 


게시물 댓글 달기가 중지되었습니다.

Zendesk 제공