Give the assistant a personality: set title, subtitle, botName, userName and image botAvatar / userAvatar (any URL or data-URI). Leave the avatars unset to fall back to themed initials.

jQuery Chat: Custom Branding

Brand the jqxChat assistant with custom avatars, name, title and subtitle.

A live JavaScript/jQuery example of jqxChat, the jQWidgets Chat component, with its complete source code below. It is one of 5 jqxChat demos for jQuery.

jqxChat API used in this demo

Source code

To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $.

The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxchat.js.

It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers), mockassistant.js.

script.js

$(document).ready(function () {
    // small inline SVG data-URI avatars so the demo has no external assets.
    var botAvatar = 'data:image/svg+xml;utf8,' + encodeURIComponent(
        '<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"><rect width="64" height="64" fill="#2b6cb0"/>' +
        '<circle cx="32" cy="26" r="12" fill="#fff"/><rect x="14" y="42" width="36" height="18" rx="9" fill="#fff"/></svg>');
    var userAvatar = 'data:image/svg+xml;utf8,' + encodeURIComponent(
        '<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"><rect width="64" height="64" fill="#48bb78"/>' +
        '<text x="32" y="42" font-size="30" fill="#fff" text-anchor="middle" font-family="Arial">U</text></svg>');

    $('#chat').jqxChat({
        colorScheme: 'auto',
        theme: 'light',
        width: 440,
        height: 600,
        title: 'Nova',
        subtitle: 'Your product guide',
        botName: 'Nova',
        userName: 'Me',
        botAvatar: botAvatar,
        userAvatar: userAvatar,
        showTimestamps: true,
        sendButtonIcon: true,
        welcomeMessage: 'Hi, I\'m **Nova** - your product guide. What would you like to know?',
        starterPrompts: ['What is jQWidgets?', 'Show me a code example'],
        sendRequest: jqxChatMock
    });
});

body.html

<p class="hint">
    Give the assistant a personality: set <code>title</code>, <code>subtitle</code>, <code>botName</code>,
    <code>userName</code> and image <code>botAvatar</code> / <code>userAvatar</code> (any URL or data-URI).
    Leave the avatars unset to fall back to themed initials.
</p>
<div id="chat"></div>

More jQuery Chat demos