This is a developer-focused reference. For general setup, see the Widget Setup guide.
Pre-Filling Visitor Fields
If your website already knows the visitor’s name or email (e.g., from a login session), you can pre-fill the widget’s form fields and optionally lock them so the visitor cannot change them.Via Data Attributes
Add attributes directly to the script tag:| Attribute | Description |
|---|---|
data-visitor-name | Pre-fill the name field |
data-visitor-email | Pre-fill the email field |
data-visitor-message | Pre-fill the first message |
data-lock-name | Set to "true" to make the name field read-only |
data-lock-email | Set to "true" to make the email field read-only |
data-lock-message | Set to "true" to make the message field read-only |
Via JavaScript API
For dynamic values (e.g., loaded after the page renders), set thewindow.TicketCordWidget object before the script loads, or at any point before the visitor opens the widget:
The JavaScript API and data attributes can be used together. If both are present, the JavaScript API values take priority.
Content Security Policy (CSP)
If your website uses aContent-Security-Policy header, you need to allow the widget’s domain. Add the following directives:
Directive Breakdown
| Directive | Why It’s Needed |
|---|---|
script-src https://ticketcord.net | The widget script itself |
connect-src https://ticketcord.net | API calls (config, session, messages) and the SSE stream |
style-src 'unsafe-inline' | The widget injects its own styles into a shadow DOM |
img-src https://cdn.discordapp.com | Staff avatar images from Discord |
Next.js Example
If you’re using Next.js with a custom CSP innext.config.ts:
next.config.ts
Image Domains
If your framework restricts which domains can serve images (e.g., Next.jsimages.remotePatterns), add both domains:
next.config.ts
Framework-Specific Embedding
React / Next.js
Use theScript component with the afterInteractive strategy:
Vue / Nuxt
In your main layout orapp.vue:
WordPress
Add this to your theme’sfooter.php before the closing </body> tag, or use a plugin like “Insert Headers and Footers”:
Static HTML
Paste the snippet before</body> in every page where you want the widget:
Troubleshooting
Widget bubble doesn't appear
Widget bubble doesn't appear
Open your browser console (F12) and look for
[TicketCord WebChat] messages:Widget disabled: no allowed domains are configured— Add your domain to the allowed domains list in the dashboard.Widget blocked: this domain is not in the allowed domains list— The current page’s origin doesn’t match any allowed domain. Check for typos (e.g.,httpvshttps,wwwvs non-www).Widget disabled: the bot owner's plan no longer includes web chat— The plan was downgraded. Upgrade back to Pro or Enterprise.- No console output at all — Verify the
data-widget-keyattribute is correct and the script URL is reachable.
CSP errors in the console
CSP errors in the console
Your Content Security Policy is blocking the widget. See the CSP section above for the required directives.
Staff avatar images not loading
Staff avatar images not loading
Add
https://cdn.discordapp.com to your img-src CSP directive. Discord serves avatar images from this domain.Pre-fill values not appearing
Pre-fill values not appearing
- Ensure the data attributes are on the
<script>tag itself, not on a parent element. - If using the JavaScript API, set
window.TicketCordWidgetbefore the script loads, or ensure the widget hasn’t already initialized. - Check that the pre-chat form is enabled in your dashboard settings — pre-fill values only appear on the form.
Widget loads but messages don't send
Widget loads but messages don't send
- Check that the bot is online in your dashboard.
- Verify the ticket category exists and the bot has permissions to create channels in it.
- Look for rate limit errors in the console — the default is 10 messages per minute.
Need Help?
Get instant support via private DM