Switch from Alhena to another support widget (Freshworks, Zendesk, Intercom, etc.) when human handoff is initiated.
This example shows how to close the Alhena widget and load an alternative support solution when a conversation needs human attention. Use this when you want Alhena AI to handle initial inquiries but transfer to your existing helpdesk widget for human support.
What You'll Learn
Listen for ticket:agent_handoff_initiated event
Close the Alhena widget gracefully
Load an external support widget dynamically
Use Case
Many companies use Alhena AI for first-line support but have an existing helpdesk (Zendesk, Freshworks, Intercom) for human agents. This pattern lets you:
Use Alhena for AI-powered responses
Detect when a human is needed
Seamlessly switch to your helpdesk's native widget
User requests human help: When the AI determines human help is needed (user asked for a person, AI couldn't answer, etc.), the ticket:agent_handoff_initiated event fires
Close Alhena: We close the current ticket and hide the Alhena widget
Load external widget: Dynamically inject the external helpdesk's script
Open external widget: Optionally auto-open the new widget
Event Timing
There are two related events:
Event
When It Fires
Use Case
ticket:agent_handoff_initiated
AI decides human help is needed, before email collection
Switch widgets early
ticket:agent_handoff
After user submits email, ticket created in helpdesk
Switch after confirmation
Use ticket:agent_handoff_initiated if you want to switch widgets before the user enters their email (they'll enter it in the external widget instead).
Use ticket:agent_handoff if you want Alhena to collect the email first, then switch.
Considerations
Script caching: External widget scripts may already be cached, so loading is usually fast
User context: The external widget won't have the Alhena conversation history
Analytics: Track this handoff event in your analytics to measure AI deflection rate