Skip to main content
This page covers the technical details of embedding the Web Chat Widget: pre-filling visitor data, Content Security Policy configuration, framework-specific setup, and the JavaScript API.
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:
Lock fields when you trust the data. If the name and email come from your authenticated session, lock them to prevent visitors from impersonating other users. If the data is just a convenience default, leave them unlocked.

Via JavaScript API

For dynamic values (e.g., loaded after the page renders), set the window.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 a Content-Security-Policy header, you need to allow the widget’s domain. Add the following directives:

Directive Breakdown

If you see Refused to load or Refused to connect errors in the console, your CSP is blocking the widget. Add the domains listed above to the relevant directives.

Next.js Example

If you’re using Next.js with a custom CSP in next.config.ts:
next.config.ts

Image Domains

If your framework restricts which domains can serve images (e.g., Next.js images.remotePatterns), add both domains:
next.config.ts

Framework-Specific Embedding

React / Next.js

Use the Script component with the afterInteractive strategy:
For dynamic pre-fill values from your auth context:

Vue / Nuxt

In your main layout or app.vue:

WordPress

Add this to your theme’s footer.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

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., http vs https, www vs 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-key attribute is correct and the script URL is reachable.
Your Content Security Policy is blocking the widget. See the CSP section above for the required directives.
Add https://cdn.discordapp.com to your img-src CSP directive. Discord serves avatar images from this domain.
  • Ensure the data attributes are on the <script> tag itself, not on a parent element.
  • If using the JavaScript API, set window.TicketCordWidget before 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.
  • 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