Workflow recipe: Assign a ticket to the last agent that served the requester

<div class="article-banners" translate="no">
<div id="docs-wmp-link"><a href="https://support.zendesk.com/hc/en-us/articles/5411234991258-plan" rel="noopener" target="_blank">What's my plan?</a></div>
<div class="article-banner" id="suite_all">
<table>
<tbody>
<tr>
<td><strong>Suite</strong></td>
<td>Team, Growth, Professional, Enterprise, or Enterprise Plus</td>
</tr>
</tbody>
</table>
</div>
<div class="article-banner" id="support_all">
<table>
<tbody>
<tr>
<td><strong>Support</strong></td>
<td>Team, Professional, or Enterprise</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Some organizations assign new tickets to the agent who last assisted a requester to ensure continuity and personalization. </p>
<p>In this recipe, you'll learn how to replicate this workflow with custom user fields and business rules.</p>
<p>This article contains the following topics:</p>
<ul>
<li><a href="#h_01JZK6YJ4N5WPYVJXK6CHADVQD">Workflow goal</a></li>
<li><a href="#h_01JW9FQ5P1CKEJCD3W0MX199EQ"><span class="wysiwyg-underline">Creating a custom user field</span></a></li>
<li><a href="#h_01JW9FQ5P7VCQFGVST98BY07BM"><span class="wysiwyg-underline">Creating a webhook to update the ticket requester</span></a></li>
<li><a href="#h_01JW9FQ5PDA6RSEFB37EV4ZMF0"><span class="wysiwyg-underline">Creating a trigger to save the last assigned agent</span></a></li>
<li><a href="#h_01JW9FQ5PR6NYVHCZ0009Y504S"><span class="wysiwyg-underline">Creating a webhook to update tickets</span></a></li>
<li><a href="#h_01JW9FQ5PXWWKRZK8ZNHCWQGB2"><span class="wysiwyg-underline">Creating a trigger to assign tickets based on the last handling agent</span></a></li>
<li><a href="#h_01JW9FQ5Q485MYKT5B7SMKHW05">Notes and tips</a></li>
</ul>
<h2 id="h_01JZK6YJ4N5WPYVJXK6CHADVQD">Workflow goal</h2>
<p>In this workflow, you'll set up custom user fields, webhooks, and triggers so that the last agent who assisted a requester is assigned subsequent tickets from that same requester. </p>
<p>When you're done setting up this workflow, the first time a requester submits a ticket, any agent can be assigned to it manually or based on another rule. After the requester submits their first ticket, any new ticket from that requester will automatically be assigned to the last agent who handled their previous ticket.</p>
<h2 id="h_01JW9FQ5P1CKEJCD3W0MX199EQ">Creating a custom user field</h2>
<p>The first thing you need to do is store who the last agent was that worked on a ticket. To do this, you'll start by creating a custom user field to store that information for each end user.</p>
<p><strong>To create a custom user field:</strong></p>
<ol>
<li>In the <a href="https://support.zendesk.com/hc/en-us/articles/4581766374554-Using-Zendesk-Admin-Center"><span class="wysiwyg-underline">Admin Center</span></a>, click  <span style="background-color: #fefaf2; color: #16140c;"><img height="16" src="https://support.zendesk.com/hc/article_attachments/9304536619546" width="16"> </span> <strong>People </strong>in the sidebar, then select <strong>Configuration </strong>&gt; <strong>User Fields</strong>.</li>
<li>Click <strong>Add Field</strong>.</li>
<li>Select <strong>Text</strong> as the field type.</li>
<li>In the <strong>Display Name </strong>field enter <strong>Handler agent</strong>.<br>This automatically sets the Field key to <em>handler_agent</em>.</li>
<li>(Optional) Enter a <strong>Description</strong> for the custom field.<br><img class="image img-screenshot" height="348" src="https://support.zendesk.com/hc/article_attachments/9304706252186" width="458">
</li>
<li>Click <strong>Save</strong>.</li>
</ol>
<p>See <a href="https://support.zendesk.com/hc/en-us/articles/4408822051866" rel="noopener noreferrer" target="_blank">Adding custom fields to users</a> for more information.</p>
<h2 id="h_01JW9FQ5P7VCQFGVST98BY07BM">Creating a webhook to update the ticket requester</h2>
<p>Next, you'll update the custom user field you created by setting up a webhook that updates a user.</p>
<p><strong>To create the webhook:</strong></p>
<ol>
<li>In the <a href="https://support.zendesk.com/hc/en-us/articles/4581766374554-Using-Zendesk-Admin-Center"><span class="wysiwyg-underline">Admin Center</span></a>, click<span style="background-color: #fefaf2; color: #16140c;">  <img height="16" src="https://support.zendesk.com/hc/article_attachments/9304552107290" width="16"></span> <strong>Apps and Integrations </strong>in the sidebar, then select <strong>Webhooks </strong>&gt; <strong>Webhooks</strong>.</li>
<li>Click <strong>Create Webhook</strong>.</li>
<li>Use the following values for your configuration:
<ul>
<li>
<strong>Name</strong>: Update user handler agent</li>
<li>
<strong>Endpoint URL</strong>: <span style="background-color: #ececec; color: #0d0d0d;"><code>https://yourdomain.zendesk.com/api/v2/users/{{ticket.requester.id}}.json</code></span>
</li>
<li>
<strong>Request method</strong>: PUT</li>
<li>
<strong>Request format</strong>: JSON</li>
<li>
<strong>Authentication:</strong> Basic authentication<br><img class="image img-screenshot" height="335" src="https://support.zendesk.com/hc/article_attachments/9304687320346" width="407"><br>See <a href="https://support.zendesk.com/hc/en-us/articles/4408839108378" rel="noopener noreferrer" target="_blank">Creating webhooks to interact with third-party systems</a> for more information.</li>
</ul>
</li>
</ol>
<h2 id="h_01JW9FQ5PDA6RSEFB37EV4ZMF0">Creating a trigger to save the last assigned agent</h2>
<p>Next, you'll create a trigger to invoke the webhook you created to update the custom user field with the agent ID.</p>
<p>This trigger uses the webhook to update the custom user field linked to the ticket requester with the agent ID each time a ticket assignee changes.</p>
<p><strong>To create a ticket trigger to use the webhook:</strong></p>
<ol>
<li>In <a href="https://support.zendesk.com/hc/en-us/articles/4581766374554-Using-Zendesk-Admin-Center"><span class="wysiwyg-underline">Admin Center</span></a>, click <img height="16" src="https://support.zendesk.com/hc/article_attachments/9304536619802" width="16"> <strong>Objects and rules</strong> in the sidebar, then select <strong>Business rules</strong> &gt; <strong>Triggers</strong>.</li>
<li>Click <strong>Create trigger</strong>.</li>
<li>Enter a <strong>Trigger name</strong>, such as Assign handler agent.</li>
<li>(Optional) Enter a <strong>Description</strong> and a <strong>Category</strong>.</li>
<li>In the <strong>Conditions</strong> section, under <strong>Meet ALL of the following conditions</strong>, add the following conditions:
<ul>
<li><strong>Ticket: Assignee |  Changed</strong></li>
<li><strong>Ticket: Assignee | Is not | (blank)</strong></li>
<li>
<p><strong>Ticket: Ticket | is | Updated</strong></p>
<p><img class="image img-screenshot" height="278" src="https://support.zendesk.com/hc/article_attachments/9304706252442" width="519"></p>
</li>
</ul>
</li>
<li>In the <strong>Actions</strong> section, add the following:
<ul>
<li><strong>Notify by: Active Webhook | Update user handler agent</strong></li>
<li>Use the following for the <strong>JSON Body</strong>:</li>
</ul>
</li>
</ol>
<pre><code>{
"user": {
"user_fields": {
"handler_agent": "{{ticket.assignee.id}}"
}
}
}</code></pre>
<ol start="7">
<li>Click <strong>Create</strong>.<br>See <a href="https://support.zendesk.com/hc/en-us/articles/4408886797466" rel="noopener noreferrer" target="_blank">Creating ticket triggers for automatic ticket updates and notifications</a> for more information.</li>
</ol>
<h2 id="h_01JW9FQ5PR6NYVHCZ0009Y504S">Creating a webhook to update tickets</h2>
<p>Next, you'll create a second webhook to update the relevant ticket via REST API.</p>
<p><strong>To create the webhook:</strong></p>
<ol>
<li>In the <a href="https://support.zendesk.com/hc/en-us/articles/4581766374554-Using-Zendesk-Admin-Center"><span class="wysiwyg-underline">Admin Center</span></a>, click<span style="background-color: #fefaf2; color: #16140c;">  <img height="16" src="https://support.zendesk.com/hc/article_attachments/9304552107290" width="16"></span> <strong>Apps and Integrations </strong>in the sidebar, then select <strong>Webhooks </strong>&gt; <strong>Webhooks</strong>.</li>
<li>Click <strong>Create Webhook</strong>.</li>
<li>Use the following values for your configuration:</li>
</ol>
<ul>
<li style="list-style-type: none;">
<ul>
<li>
<strong>Name</strong>: Update ticket</li>
<li>
<strong>Endpoint URL</strong>: <span style="background-color: #ececec; color: #0d0d0d;"><code>https://yourdomain.zendesk.com/api/v2/tickets/{{ticket.id}}.json</code></span>
</li>
<li>
<strong>Request method</strong>: PUT</li>
<li>
<strong>Request format</strong>: JSON</li>
<li>
<strong>Authentication:</strong> Basic Authentication<br><img class="image img-screenshot" height="371" src="https://support.zendesk.com/hc/article_attachments/9304607327642" width="448"><br>See <a href="https://support.zendesk.com/hc/en-us/articles/4408839108378" rel="noopener noreferrer" target="_blank">Creating webhooks to interact with third-party systems</a> for more information.</li>
</ul>
</li>
</ul>
<h2 id="h_01JW9FQ5PXWWKRZK8ZNHCWQGB2">Creating a trigger to assign tickets based on the last handling agent.</h2>
<p>Finally, you'll create a trigger to check if a ticket has a previously assigned agent. This information is  used to assign new tickets.</p>
<p><strong>To create the trigger:</strong></p>
<ol>
<li style="list-style-type: none;">
<ol>
<li>In <a href="https://support.zendesk.com/hc/en-us/articles/4581766374554-Using-Zendesk-Admin-Center"><span class="wysiwyg-underline">Admin Center</span></a>, click <img height="16" src="https://support.zendesk.com/hc/article_attachments/9304536619802" width="16"> <strong>Objects and rules</strong> in the sidebar, then select <strong>Business rules</strong> &gt; <strong>Triggers</strong>.</li>
<li>Click <strong>Add trigger</strong>.</li>
<li>Enter a <strong>Trigger name</strong>, such as Assign ticket to end user handler agent.</li>
<li>(Optional) Enter a <strong>Description</strong> and a <strong>Category</strong> for your trigger.</li>
<li>In the <strong>Conditions</strong> section, under <strong>Meet ALL of the following conditions</strong>, add the following conditions:
<ul>
<li>
<strong>Ticket: Ticket | Is</strong> |<strong> Created</strong>
</li>
<li>
<p><strong>Requester: Handler_agent | Is not | (blank)</strong></p>
<p><img class="image img-screenshot" height="224" src="https://support.zendesk.com/hc/article_attachments/9304706252698" width="468"></p>
</li>
</ul>
</li>
<li>In the <strong>Actions</strong> section, add the following actions:
<ul>
<li><strong>Notify by: Active Webhook | Update ticket</strong></li>
<li>Use the following for the <strong>JSON Body</strong>:</li>
</ul>
</li>
</ol>
</li>
</ol>
<pre><code>{
"ticket": {
"assignee_id": "{{ticket.requester.custom_fields.handler_agent}}"
}
}</code></pre>
<p>The trigger action should be similar to the image below:</p>
<p><img class="image img-screenshot" height="289" src="https://support.zendesk.com/hc/article_attachments/9304634817818" width="495"></p>
<h2 id="h_01JW9FQ5Q485MYKT5B7SMKHW05">Notes and tips</h2>
<ul>
<li>Make sure agents don't delete or modify the <span style="background-color: #ececec; color: #0d0d0d;"><code>handler_agent</code></span> custom user field unless necessary.</li>
<li>You can combine this setup with business hours, priority rules, or SLAs.</li>
<li>Introduce new conditions to the trigger to meet your business’ use case.</li>
<li>Test the flow thoroughly in a sandbox or test account before deploying it live.</li>
</ul>
<p>
<script id="docs-schema-markup" type="application/ld+json">{
"@context": "https://schema.org",
"@type": "TechArticle",
"@id": "https://support.zendesk.com/hc/en-us/articles/9304552109722",
"url": "https://support.zendesk.com/hc/en-us/articles/9304552109722-Workflow-recipe-Assign-a-ticket-to-the-last-agent-that-served-the-requester",
"headline": "Workflow recipe: Assign a ticket to the last agent that served the requester",
"description": "You can set up custom user fields, webhooks, and triggers to automatically assign new tickets to the last agent who assisted the requester, ensuring continuity in ticket handling.",
"articleSection": "Workflow best practices and recipes",
"datePublished": "2025-05-27T19:18:33+00:00",
"dateModified": "2026-02-27T05:52:30+00:00",
"inLanguage": "en-US",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://support.zendesk.com/hc/en-us/articles/9304552109722"
},
"author": {
"@type": "Organization",
"name": "Zendesk",
"@id": "https://www.zendesk.com"
},
"publisher": {
"@type": "Organization",
"name": "Zendesk",
"@id": "https://www.zendesk.com"
},
"isPartOf": {
"@type": "WebSite",
"name": "Zendesk Help",
"@id": "https://support.zendesk.com/hc/"
},
"about": {
"@type": "SoftwareApplication",
"name": "Zendesk",
"@id": "https://www.zendesk.com"
}
}</script>
</p>