Customers hate repeating themselves when an AI bot fails and transfers them to a human agent. If your AI bot loses conversation history during a handoff, your customer satisfaction scores will plummet, and your support team will waste time asking questions the customer has already answered. You can solve this by building a clean handoff protocol that serializes the conversation state, generates an executive summary, and posts it directly to your ticketing system before routing the customer.
Here is what you need to follow this guide:
- A running AI support agent built on Node.js or Python. If you are starting from scratch, check out this guide on AI agent development to structure your architecture.
- Admin access to Zendesk with API token generation enabled.
- A vector store or session cache, like Redis, holding current user conversation state.
- Basic understanding of REST APIs and Webhooks.
Do not dump raw chat logs into a support ticket and expect your team to read fifty lines of back and forth. Use your LLM to summarize the key points right when the agent decides to trigger a handoff.
Define a simple schema for the summary payload:
{
"customer_intent": "Refund Request",
"resolved_points": ["Verified account ownership", "Located order #8841"],
"unresolved_issue": "System rejected automated refund due to policy threshold",
"user_sentiment": "Frustrated",
"recommended_action": "Manually override refund block in billing portal"
}
Run a fast, cheap model like GPT-4o-mini with a dedicated prompt to extract these fields from the raw chat memory before calling the Zendesk API.
Step 2: Format the Internal Note for Zendesk
Zendesk allows you to attach private notes to tickets that are visible only to agents, not customers. Format your AI summary as a Markdown string so it displays cleanly in the Zendesk Agent Workspace.
Here is a simple Node.js helper function to construct the ticket payload:
async function createZendeskHandoffTicket(user, summary, transcript) {
const ticketData = {
ticket: {
subject: `AI Handoff: ${summary.customer_intent} - ${user.name}`,
comment: {
body: `--- AI HANDOFF SUMMARY ---
Intent: ${summary.customer_intent}
Sentiment: ${summary.user_sentiment}
Key Information Gathered:
${summary.resolved_points.map(p => `- ${p}`).join('\n')}
Blocking Issue:
${summary.unresolved_issue}
Suggested Next Step:
${summary.recommended_action}
--- FULL CHAT TRANSCRIPT ---
${transcript}`,
public: false
},
priority: summary.user_sentiment === 'Frustrated' ? 'high' : 'normal',
requester: {
name: user.name,
email: user.email
}
}
};
return ticketData;
}
Setting public: false on the comment ensures this background information stays internal. The customer will not see this dump.
Step 3: Send the Ticket via Zendesk API
Send the formatted payload to Zendesk using basic authentication with your API token.
const axios = require('axios');
async function sendToZendesk(ticketPayload) {
const zendeskDomain = process.env.ZENDESK_SUBDOMAIN;
const authHeader = Buffer.from(
`${process.env.ZENDESK_EMAIL}/token:${process.env.ZENDESK_API_TOKEN}`
).toString('base64');
try {
const response = await axios.post(
`https://${zendeskDomain}.zendesk.com/api/v2/tickets.json`,
ticketPayload,
{
headers: {
'Authorization': `Basic ${authHeader}`,
'Content-Type': 'application/json'
}
}
);
return response.data.ticket.id;
} catch (error) {
console.error('Failed to create Zendesk ticket:', error.response?.data || error.message);
throw error;
}
}
If you are setting up larger automated routing logic across platforms, exploring workflow automation techniques can help you link custom webhooks directly to ticket routing tables without hardcoding everything.
Step 4: Transfer Live Web Chat State
If you use Zendesk Messaging or Web Widget for real time chat rather than email tickets, update the metadata directly on the active web session before passing control.
Use the Zendesk Messaging JS API on your web frontend:
zE('messenger', 'set', 'conversationFields', [
{ id: '12345678', value: summary.customer_intent },
{ id: '87654321', value: summary.user_sentiment }
]);
zE('messenger', 'open');
This populates custom ticket fields on the agent sidebar instantly when the live workspace picks up the chat thread.
Expected Outcomes
Once this protocol is active, your support pipeline will behave predictably:
- When an AI bot triggers a handoff, the backend executes the summary prompt in under two seconds.
- A Zendesk ticket is created automatically, populated with structured metadata and private notes.
- The human support agent receives the chat or ticket with full context already displayed on their sidebar.
- Average handle time drops significantly, and customers never have to repeat their account numbers or problem details.
If you need extra engineering horsepower to build customized AI tools or integrations like this for your operations, Gaper can match you with vetted developers who specialize in AI pipelines and backend infrastructure.
Top comments (0)