Creating new tickets automatically using triggers | Community
Skip to main content

Creating new tickets automatically using triggers

  • June 16, 2018
  • 11 replies
  • 0 views

I'm trying to have a trigger run that will automatically create a new ticket based on events on a separate ticket. I've got as far as the ticket generating but it always creates the ticket with the agent (me) as the requester. I need the ticket to be created with the same requester as the ticket that the ticket originally ran on. 

I've a http target set up as

Url - https://**OURDOMAIN**.zendesk.com/api/v2/tickets
Method: Post
Content Type: JSON
BasicAuthentication: Enabled

and the code so far is

{ "ticket": { "subject": "About your order ", "public": true, "description": "this is my content.", "priority": "high", "status": "new", } }

But everything i try to get the requester of the new ticket to match the requester of the trigger ticket won;t play ball. 

Any thoughts?



This topic has been closed for replies.

11 replies

  • June 25, 2018

Kev -- you'll need to reference the requester information of your current ticket and pass it to your target in the trigger's JSON payload. You'll need to use dynamic content to do that. Your JSON payload to your target should look something like:

{"ticket": { "subject": "About your order ", "public": true, "comment" : {"body": "this is my content."}, "priority": "high", "status": "new", "requester":
{"name": "{{ticket.requester.name}}", "email": "{{ticket.requester.email}}"} }

Note: the description of a ticket is set by the first comment -- use the 'comment' attribute for this, not 'description'. Hope this helps!


  • June 25, 2018

PS -- I moved this to the Q&A section of the Community


  • June 26, 2018

Hello Kev,

This is an awesome idea - once you've completed it, please write a tutorial to help others along.  I can see this having several use-case for Zendesk users.  Well done so far!


Heather13
  • June 26, 2018

Kev,

I bet it's using you as the Requester because it's using your authentication token. Is there any way to test that theory by using another license to set it up?  I don't know how to get around that but at least you'd be closer to the root cause......


Dan28
  • June 26, 2018

This is impressive.  I'm curious if using the Requests API instead of the Tickets API might help.  The Requests API handles tickets from the end user side, versus the Tickets API which is on the agent side. I can't say that I'm sure it's the solution you need, but since you want the ticket to be set as the requester, it might be a path worth looking into. 


  • July 31, 2018

Hello Kevin, have you made any further progress on this?


  • Author
  • August 1, 2018

Not yet I'm afraid. Other projects have gotten in the way so haven't made any real progress on this. :-(


  • February 1, 2019

hi all ,

I tried and it works well

 
1- Settings>Extensions> a new HTTP destination must be created
 
2 - In Macro add a new TAG
 
 
3- with a trigger, remove the tag and run the API
 
 
 
:)

 

 

 


  • February 13, 2019

I'm not seeing the images from Donald's post but I have a it working. Basically using the same ideas as other extensions/webhooks to use the https://myessentials.zendesk.com/api/v2/tickets.json address to create a new ticket.

I use an API token for credentials so be sure to create an API token first and have it ready for the extension.

My extension is configured:

Extension type: HTTP target

Title: NEW TICKET

Url: https://YOURDOMAINGOESHERE.zendesk.com/api/v2/tickets.json

Method: POST

Content type: JSON

Basic Authentication: Enabled

Username YourLoginEMail@domain.com/token (probably needs to be an admin account)

Password: -token code here-

Once you have this extension I use a macro that adds tags and a comment to the current ticket and solves it. The tag sets off a trigger that uses the extension. Once the conditions of the trigger are set you just add the notify target and the JSON to create the ticket. (https://developer.zendesk.com/rest_api/docs/support/tickets) Something like:

Notify Target -> NEW TICKET

JSON:

{ "ticket": {
"subject": "Refund check - {{ticket.ticket_field_360003186812}} {{ticket.ticket_field_360003212251}}",
"comment": { "body": "{{dc.request_check}}" },
"tags": ["send_check"],
"requester": { "name": "NameOfRequester", "email": "email@example.com" },
"custom_fields": [{"id": CustomFieldID1, "value": "{{ticket.ticket_field_CustomFieldID1}}"}, {"id": CustomFieldID2, "value": "{{ticket.ticket_field_CustomFieldID2}}"}, {"id": CustomFieldID3, "value": "{{ticket.ticket_field_CustomFieldID13}}"}, {"id": CustomFieldID4, "value": "{{ticket.ticket_field_CustomFieldID4}}"}, {"id": CustomFieldID5, "value": "{{ticket.ticket_field_CustomFieldID5}}"}]
}}

NOTE: The custom fields are mapping the current value on the ticket to the same fields on the new ticket. The {{dc.request_check}} uses a multi line custom field (copied from the original ticket) to populate the first comment with a trigger.


  • February 15, 2019

Thank you very much for sharing this Bradley!


Nicole17
  • February 20, 2020

This thread has been closed for comments by the Zendesk Community Team. If you have a question you'd like to ask the Zendesk Community, please create a new post