Workflow: How to obtain a ticket ID from a Sunshine Conversation ID

<p>If you use a custom Sunshine Conversations integration, use this workflow to find the ticket ID linked to a Sunshine Conversations conversation ID in Zendesk Support. This helps you build custom workflows.</p><p>Follow these steps:</p><div style="margin-bottom: 20px; text-align: right;">
<button id="master-toggle" class="btn fw-semibold text-dark" data-action="expand" style="background-color: #DEF991; border: none; outline: none; border-radius: 7px; padding: 10px 20px; font-size: 15px; transition: background-color 0.2s ease;" onmouseover="this.style.backgroundColor='#cbef6d'" onmouseout="this.style.backgroundColor='#DEF991'">
Expand all tabs
</button>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const toggleBtn = document.getElementById('master-toggle');

toggleBtn.addEventListener('click', function () {
const action = this.getAttribute('data-action');
const headers = document.querySelectorAll('.accordion');

headers.forEach(header => {
const isActive = header.classList.contains('active');
const panel = header.nextElementSibling; // Grabs the corresponding .panel container

if (action === 'expand' && !isActive) {
// Open it by simulating a standard click
header.click();
} else if (action === 'collapse' && isActive) {
// Close it by simulating a standard click
header.click();
}
});

// Flip button text and states
if (action === 'expand') {
this.setAttribute('data-action', 'collapse');
this.textContent = 'Collapse all tabs';
} else {
this.setAttribute('data-action', 'expand');
this.textContent = 'Expand all tabs';
}
});
});
</script><div class="accordion"><h3 id="h_01HXY1BFCAPEN08R87P7ENG6TS">Step 1: Add a custom field in your Zendesk tickets to store the conversation ID</h3></div><div class="panel"><ol>
<li data-list-item-id="e08cd187ce17ba0975ba20cf55c417530">Create a <a href="https://support.zendesk.com/hc/en-us/articles/4408883152794-Adding-custom-ticket-fields-to-your-tickets-and-forms#topic_ubz_ynk_xj" target="_blank" rel="noopener noreferrer">custom field</a> for the conversation ID</li>
<li data-list-item-id="ec359929fe12d77a8a3494afd171aefdb">Add it to your <a href="https://support.zendesk.com/hc/en-us/articles/5494868102426-Editing-ticket-forms" target="_blank" rel="noopener noreferrer">ticket forms</a>
</li>
</ol></div><div class="accordion"><h3 id="01HXY1G18XYBGPX37812NDQPP4">Step 2: Pass the conversation ID through metadata in your flow</h3></div><div class="panel">
<ol>
<li data-list-item-id="e8d5840909f47279ea9e6e6243b532ac2">In your flow, collect the conversation ID as metadata before you escalate to an agent through the Zendesk Agent Workspace integration. Use pass control.</li>
<li data-list-item-id="e9eed1b83e6227af899f5c899be62ec07">If you do not have a custom integration or bot, ask your developer to create a <a href="https://app.smooch.io/integrations/webhook" target="_blank" rel="noopener noreferrer">webhook</a> in Sunshine Conversations to control the conversation. Then pass control to the Zendesk Agent Workspace integration, so Zendesk Support creates a ticket with the conversation ID in the metadata.</li>
<li data-list-item-id="e4622c01cd63e52183823d9d66a0be0e5">The ticket now shows the conversation ID</li>
</ol>
<p>For examples, see <a href="https://developer.zendesk.com/documentation/zendesk-web-widget-sdks/sdks/web/conversation-metadata/" target="_blank" rel="noopener noreferrer">Using Messaging Metadata with a Zendesk bot to send page data to a ticket</a>.</p>
</div><div class="accordion"><h3 id="h_01HXY1GYQDRZ3V1Y2A1VJXG88P">Step 3: Create a Zendesk webhook</h3></div><div class="panel"><ol>
<li data-list-item-id="ebc10fc4afbbd8d6c7b5d70bd45787e38">Create a <a href="https://support.zendesk.com/hc/en-us/articles/4408839108378-Creating-webhooks-to-interact-with-third-party-systems" target="_blank" rel="noopener noreferrer">Zendesk webhook</a>
</li>
<li data-list-item-id="e989b86500e927ba541d6e019365b3abf">Use a trigger to send that webhook to your third-party system or Sunshine Conversations. Include the ticket ID and the conversation ID in the payload.<br>This links the IDs when Zendesk Support creates the ticket. Use this information in your custom workflow.</li>
<li data-list-item-id="ee43beb8a12505f2b0ddb8e1d63216fc4">You can <a href="https://developer.zendesk.com/api-reference/conversations/#tag/Conversations/operation/UpdateConversation" target="_blank" rel="noopener noreferrer">update the Sunshine Conversation</a> with the ticket ID as metadata in the conversation</li>
</ol></div><div class="accordion"><h3 id="h_01K94R28DHFKX8QJRPQFDQ87M2">Step 4: Create a Zendesk trigger</h3></div><div class="panel">
<ol>
<li data-list-item-id="e118a052f663a167c0d5bce2bdf2224a7">Add a new <a href="https://support.zendesk.com/hc/en-us/articles/4408839108378-Creating-webhooks-to-interact-with-third-party-systems#:~:text=Connect%20a%20webhook%20to%20a%20trigger%20or%20automation" target="_blank" rel="noopener noreferrer">trigger</a> that runs when Zendesk Support creates a ticket</li>
<li data-list-item-id="ecd8a8b0fd5a19b8fe850032c51bc0497">In the <strong>Action</strong>, notify by active webhook and select the webhook you created earlier</li>
</ol>
<p>Your system now receives a webhook from Zendesk Support every time a ticket is created. The payload includes the Sunshine Conversations conversation ID and the related ticket ID for your use case.</p>
</div><div class="accordion"><h3 id="h_01K99P825DF9GCHD44KKDYY8V9">Step 5: Clear the metadata from the conversation</h3></div><div class="panel"><ol>
<li data-list-item-id="e29696b4ded547d08bcdd7725f86b3b97">Create another <a href="https://support.zendesk.com/hc/en-us/articles/4408839108378-Creating-webhooks-to-interact-with-third-party-systems" target="_blank" rel="noopener noreferrer">webhook</a> and <a href="https://support.zendesk.com/hc/en-us/articles/4408839108378-Creating-webhooks-to-interact-with-third-party-systems#:~:text=Connect%20a%20webhook%20to%20a%20trigger%20or%20automation" target="_blank" rel="noopener noreferrer">trigger</a> in Zendesk Support to clear the metadata when the ticket is solved or closed</li>
<li data-list-item-id="ec68e4e81ad67876712fc08e23354a216">Use the Sunshine Conversation update <a href="https://developer.zendesk.com/api-reference/conversations/#tag/Conversations/operation/UpdateConversation" target="_blank" rel="noopener noreferrer">endpoint</a> to clear the metadata, so the process works for a new conversation. The conversation ID differs from the ticket ID.</li>
</ol></div><div class="note">
<span class="notetitle"><strong>Disclaimer</strong>:</span> This article is provided for instructional purposes only. Zendesk does not support or guarantee the code. Post any issues you have in the comments section or try searching for a solution online.</div>