This example shows how to integrate with the Central Tickets support system.
Integration Code
HTML + JavaScript (Simple)
<!-- Add this button to your HTML -->
<button onclick="contactSupport()">Contact Support</button>
<!-- Add this script -->
<script>
function contactSupport() {
// Get user data (implement these functions based on your auth system)
const email = getCurrentUserEmail();
const name = getCurrentUserName();
// Create form and submit
const form = document.createElement('form');
form.method = 'POST';
form.action = 'https://your-ticket-system.com/auth/redirect/your-tenant-slug';
const emailField = document.createElement('input');
emailField.type = 'hidden';
emailField.name = 'email';
emailField.value = email;
form.appendChild(emailField);
const nameField = document.createElement('input');
nameField.type = 'hidden';
nameField.name = 'name';
nameField.value = name;
form.appendChild(nameField);
document.body.appendChild(form);
form.submit();
}
</script>
Advanced JavaScript (with error handling)
<script>
class SupportRedirect {
constructor(systemUrl, tenantSlug) {
this.systemUrl = systemUrl;
this.tenantSlug = tenantSlug;
}
async redirectToSupport(email, name, extraData = {}) {
try {
const response = await fetch(`${this.systemUrl}/auth/redirect/${this.tenantSlug}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, name, ...extraData })
});
if (response.redirected) {
window.location.href = response.url;
} else if (response.status === 429) {
alert('Too many requests. Please try again later.');
} else {
alert('Unable to contact support. Please try again.');
}
} catch (error) {
console.error('Support redirect failed:', error);
alert('Network error. Please check your connection and try again.');
}
}
}
// Usage
const support = new SupportRedirect('https://your-ticket-system.com', 'your-tenant-slug');
function contactSupport() {
const email = getCurrentUserEmail();
const name = getCurrentUserName();
support.redirectToSupport(email, name, {
company: 'Your Company',
role: 'Customer'
});
}
</script>
Integration Documentation
API Endpoint
POST https://your-ticket-system.com/auth/redirect/{tenant-slug}
Request Body
{
"email": "user@example.com",
"name": "John Doe",
"company": "Optional Company Name",
"role": "Optional User Role"
}
Response
- 302 Redirect: Success - redirects to ticket subdomain
- 400 Bad Request: Invalid data
- 429 Too Many Requests: Rate limited
DNS Setup
Add this CNAME record to your domain:
*.ticket.yourdomain.com CNAME your-ticket-system-domain.com
Security Notes
- Always use HTTPS for all requests
- Validate user input before sending
- Don't send sensitive data (passwords, tokens, etc.)
- Implement proper error handling