Skip to content

Web chat widget

The chat widget is a small button on your website that opens the conversation window. Each project has its own widget.

Copy the snippet from Project settings → Widget and paste it before the closing </body> tag of your website:

<script>window.Commelia=window.Commelia||function(){(Commelia.q=Commelia.q||[]).push(arguments)};</script>
<script src="https://api.commelia.ch/widget/loader.js" data-project="pk_..." async></script>

Use Open test page to try it before it goes live. Under Allowed websites, list the origins that may embed the chat (one per line, e.g. https://www.example.org). Leave it empty to allow every website.

You can control the widget from your page:

Commelia("setLocale", "de"); // show the widget in German
Commelia("open"); // open the chat, e.g. from a "Chat with us" button

Visitors see a single chat, like in a messenger: when they come back, their earlier messages are still there and they simply write on. Behind the scenes Commelia still keeps one conversation per request, so assignment, response times and ratings stay accurate:

  • A message within a day after a conversation was closed reopens it.
  • A later message starts a new conversation. Your team sees the earlier ones under History in the contact panel.
  • In the chat, a closed conversation ends with a divider and the date. Visitors can rate it there and have its transcript sent by email.

Visitors can attach an image or a PDF to a message with the paperclip button; see Images and PDFs.

The chat is remembered in the visitor’s browser. Signed-in visitors (see below) get the same chat on every device.

  • Branding (General tab): primary color, font (from Google Fonts), logo and position (bottom left or right).
  • Wording (Localization tab): replace the greeting, subtitle, placeholder, the button to talk to a person and its notice, the email request with its button, link and notices, the online/offline status texts, the divider after a closed conversation, the rating question and the texts visitors see when they end a conversation. The transcript email is worded in the same tab under Messages to visitors.
  • Languages (General tab): the languages your widget is offered in. English and German have built-in texts; for other languages, write the texts under Localization or translate them automatically from the first language.

Intro questions are asked with the first message, for example age group, postcode or topic. They are asked only once: later conversations of the same visitor take over the earlier answers. Questions can be free text, a choice or an email address, and can be required. The answers are attached to the conversation, can be used to filter the inbox and to route conversations to the right group.

Under Opening hours (Widget tab), set weekly hours, holidays and date-specific exceptions in your timezone. Outside these hours the widget shows your away message, and visitors can leave their email address so the team can answer later. Visitors can close this request; it then stays available as a link below the chat, and it disappears once someone from the team has answered. If the AI assistant runs in auto mode, you can choose whether it answers always, only outside opening hours, or whenever nobody is online.

If people sign in on your website, you can pass their identity so that conversations continue across devices. Compute an HMAC on your server with the project’s identity secret and pass it to the widget:

Commelia("identify", {
userId: "42",
email: "jane@example.org",
name: "Jane",
hash: "<HMAC-SHA256(identitySecret, userId) in hex, computed on your server>",
});

Keep the identity secret on your server. You can also allow only identified users to chat. Without identity, visitors stay anonymous unless they give their email address.