Initialization

📘

Latest version: 1.0.0

Overview

Estimated integration time: 10 minutes.

To add Web Chat, upload the SDK JavaScript and CSS files to your website and provide your public channelKey. The widget adds itself to the page; no HTML container or manual Socket.IO setup is required.

ValueRequiredDescription
channelKeyYesPublic, unique channel or project identifier.
baseUrlNoWeb Chat environment URL. Defaults to https://eu1.chat-v2.indigitall.com.
contactCodeNoStable contact ID. If omitted, the SDK creates a UUID for the browser-tab session.
contactNameNoContact display name.
⚠️

Security

channelKey is public. Never include a serverKey, private token, or server credential in browser code.

  • download .zip and extract its two files to upload them to the main folder of your website.

🤖 Click to expand AI Integration Prompt (ChatGPT / Copilot / Claude)

Copy and paste this prompt into your AI assistant to accelerate your integration:

# Prompt: indigitall Web Chat SDK V2 Basic Integration

Copy this prompt into your AI assistant (GitHub Copilot, ChatGPT, Claude, etc.) to get guided through integrating indigitall Web Chat SDK V2 into your website.

---

Act as an expert engineer in indigitall Web Chat SDK V2 integration. Your goal is to help me add the Web Chat widget to my website, generating the final code adapted to my answers.

## Step 0 — Preliminary questions (REQUIRED)

Before generating any code, ask me these questions one by one and wait for my answers:

1. What is your public channelKey?
   It is the public channel identifier provided by indigitall.
2. Where will you host the SDK files?
   By default, use /indigitall/web-chat-sdk-v2.min.js and /indigitall/web-chat-sdk-v2.css.
3. Do you have identified users?
   If yes, tell me where I can read the stable user ID and display name in the website code.
4. Do you need to use a custom Web Chat environment URL?
   If yes, provide the baseUrl. If not, omit baseUrl and use the SDK default.
5. What language should the widget use?
   Use en, es, or pt when possible.
6. Does your site use a strict CSP with nonces?
   If yes, tell me how the server-generated nonce is exposed in the page.

## Step 1 — SDK files

Tell me to download the Web Chat SDK V2 .zip from the official documentation, extract it, and upload these files to my website:

- web-chat-sdk-v2.min.js
- web-chat-sdk-v2.css

Use the folder path I provided in question 2.

## Step 2 — Add the SDK to the page

Add the stylesheet and load the JavaScript before the closing </body> tag:

<link rel="stylesheet" href="/indigitall/web-chat-sdk-v2.css" />

<script>
  const script = document.createElement('script')
  script.src = '/indigitall/web-chat-sdk-v2.min.js'
  script.charset = 'utf-8'

  script.onload = () => {
    window.supportChat = WebChat.init({
      channelKey: 'YOUR_CHANNEL_KEY',
      contactCode: window.currentUser?.id,
      contactName: window.currentUser?.name,
      language: 'en',
    })
  }

  script.onerror = () => {
    console.error('Could not load indigitall Web Chat')
  }

  document.body.appendChild(script)
</script>

## Step 3 — Adapt the code

Generate the final implementation applying these rules:

- Replace YOUR_CHANNEL_KEY with my public channelKey.
- Adjust the CSS and JS paths to the folder I provided.
- If I do not have identified users, remove contactCode and contactName.
- If I have identified users, use a stable contactCode. Never use passwords, access tokens, private keys, or sensitive data.
- Include baseUrl only if I provided a custom Web Chat environment URL.
- Set language to the language I requested.
- If my site uses CSP nonces, add cspStrict: { nonce: 'SERVER_GENERATED_NONCE' } and use the real server-generated nonce. Never generate the nonce in browser code.
- Store the returned instance in window.supportChat.
- If the project has logout, user-change, route cleanup, or component unmount logic, call window.supportChat?.destroy().
- Do not add a manual HTML container. WebChat.init() creates the launcher and panel automatically.
- Do not add Socket.IO manually.
- Do not expose serverKey, private tokens, or server credentials in browser code.

## Step 4 — Verification

Guide me to verify the integration:

1. Confirm web-chat-sdk-v2.css and web-chat-sdk-v2.min.js load with HTTP 200.
2. Confirm the floating launcher appears.
3. Check the browser console for loading or authorization errors.
4. If the chat does not connect, verify channelKey, baseUrl, CORS, and WebSocket/polling proxy rules.
5. If a new contact is created every visit, use a stable contactCode for identified users.
6. On logout or user change, confirm window.supportChat?.destroy() is called before initializing a new chat.

## Official documentation

For more details and advanced configuration options, refer to the official indigitall Web Chat SDK V2 documentation.

Important: AI can make mistakes. Always review and test the generated code before deploying it.

1. Upload the SDK files

Upload these files to a public folder, such as /indigitall/:

  • web-chat-sdk-v2.min.js
  • web-chat-sdk-v2.css

Use FTP, a hosting control panel, a CDN, or your normal deployment process.

2. Add Web Chat to your page

Paste this immediately before the closing </body> tag:

<link rel="stylesheet" href="/indigitall/web-chat-sdk-v2.css" />
<script
  src="/indigitall/web-chat-sdk-v2.min.js"
  charset="utf-8"
  onload="WebChat.init({ channelKey: 'YOUR_CHANNEL_KEY' })"
></script>

Replace YOUR_CHANNEL_KEY with your public channel key. Without baseUrl, the SDK uses https://eu1.chat-v2.indigitall.com.

Use another environment by providing its URL:

WebChat.init({
  baseUrl: 'https://YOUR-ENVIRONMENT.chat-v2.indigitall.com',
  channelKey: 'YOUR_CHANNEL_KEY',
})
📘

WebChat.init() automatically creates the floating launcher and chat panel.

Contact identification

Automatic session contact

When no user ID is available, omit contactCode:

WebChat.init({ channelKey: 'YOUR_CHANNEL_KEY' })

The SDK generates a UUID and saves it in sessionStorage. It is reused while the browser-tab session is active, then replaced after the tab or browser session ends.

Your own contact identifier

For identified users, pass a stable, unique value:

WebChat.init({
  channelKey: 'YOUR_CHANNEL_KEY',
  contactCode: 'user-12345',
  contactName: 'Ada Lovelace',
})

An explicit contactCode replaces the value in sessionStorage; later initializations in the same tab reuse it when no code is passed.

⚠️

Use the same contactCode for the same user. Never use passwords, access tokens, or private keys.

Recommended JavaScript setup

<link rel="stylesheet" href="/indigitall/web-chat-sdk-v2.css" />
<script>
  const script = document.createElement('script')
  script.src = '/indigitall/web-chat-sdk-v2.min.js'
  script.onload = () => {
    window.supportChat = WebChat.init({
      channelKey: 'YOUR_CHANNEL_KEY',
      contactCode: window.currentUser?.id,
      contactName: window.currentUser?.name,
      language: 'en',
    })
  }
  script.onerror = () => console.error('Could not load Indigitall Web Chat')
  document.body.appendChild(script)
</script>

Reinitialization and removal

Only one Web Chat instance can be active. Calling WebChat.init() again automatically destroys and replaces the prior instance.

The returned instance has destroy(). Call it on logout, user changes, or when the containing view is removed:

window.supportChat?.destroy()

CSP with nonce

To keep the full normal UI under a CSP that requires a nonce for dynamically created style elements, configure the response and provide the same server-generated nonce to the SDK:

<script nonce="SERVER_GENERATED_NONCE">
  WebChat.init({
    channelKey: 'YOUR_CHANNEL_KEY',
    cspStrict: { nonce: 'SERVER_GENERATED_NONCE' },
  })
</script>

The response header must include style-src 'self' 'nonce-SERVER_GENERATED_NONCE'. The nonce is generated once per response by the server; never generate it in browser code. This lightweight mode retains normal customization and functionality, but it does not support style-src-attr 'none' because a nonce does not permit style attributes.

Troubleshooting

DOWNLOAD
IssueRecommended check
Launcher is not visibleCheck JavaScript/CSS URLs and browser-console loading errors.
Chat cannot connectCheck channelKey, configured baseUrl, CORS, and the WebSocket/polling proxy.
A new contact is created on every visitPass a stable contactCode; automatic UUIDs only last for the browser-tab session.
Authorization errorCheck that channelKey belongs to the intended channel and any provided contactCode is valid.

Next step

See DOC_CUSTOMIZATION.md for all WebChat.init() customization options.