githubEdit

Code Examples

Practical code examples demonstrating common Alhena Website SDK integration patterns.

This section contains ready-to-use code examples for common Alhena chat widget integration scenarios. Each example includes complete, working code that you can adapt for your website.

Available Examples

Example
Description
Use Case

Automatically close the widget after human transfer

Clean up UI after support handoff

Switch to another support tool on human transfer

Use Freshworks, Zendesk, etc. for human agents

Configure widget language and locale

Multi-language websites

Show widget only after user scrolls

Reduce initial page load distraction

Track cart and checkout events in WooCommerce

E-commerce revenue attribution


Quick Start Template

All examples build on this basic setup:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Your Page</title>
</head>
<body>

<!-- Your page content -->

<!-- Alhena SDK -->
<script>
document.gleenConfig = {
    company: 'your-company-key',
    apiBaseUrl: 'https://app.alhena.ai'
};
</script>
<script src="https://app.alhena.ai/sdk/gleenWidget.js"></script>

<!-- Your custom integration code -->
<script>
// Event handlers and customizations go here
</script>

</body>
</html>

Example Categories

Widget Control

Learn how to programmatically control the chat widget:

  • Scroll-Triggered Widget - Delay widget display until user engagement

  • Open/close based on user actions

  • Toggle widget from custom buttons

Human Agent Handoff

Handle transitions from AI to human support:

Localization

Support multiple languages:

E-commerce

Track revenue attribution:


Need More Examples?

Check these related documentation pages:

Last updated