Appearance
Multiple bots
widget.js runs once per page, so a second script tag with another data-bot is ignored. Start each bot with boot(). The queue stub lets you do it before widget.js has loaded:
html
<script>
window.WirefaceChat = window.WirefaceChat || function () {
var args = [].slice.call(arguments);
return new Promise(function (resolve, reject) {
(window.WirefaceChat.q = window.WirefaceChat.q || []).push([args[0], args.slice(1), resolve, reject]);
});
};
WirefaceChat('boot', { bot: 'pk_support_bot' });
WirefaceChat('boot', {
bot: 'pk_sales_bot',
launcher: { type: 'tab', edge: 'right', align: 'center', label: 'Sales' },
});
</script>
<script src="https://chat.example.com/widget.js" async></script>Queued boot calls replace data-bot (widget.js only boots from the tag when nothing was queued), so leave it off the tag. The first bot booted is "the first chat" for the global's methods. With the npm package, call bootWirefaceChat() once per bot.
Placing them
Give each launcher its own place (different corners, or a bubble and a tab) so they don't overlap: the bot's appearance.launcher settings or the launcher option.
By default, opening one bot's chat closes the others. Pass exclusive: false to let a bot's chat stay open alongside another.
Reaching each one
- Methods on the
WirefaceChatglobal act on the first chat on the page. WirefaceChat.get('pk_sales_bot')returns another bot's chat;WirefaceChat.instances()returns them all.boot()andbootWirefaceChat()resolve with the chat they started.data-wireface-open="pk_sales_bot"opens a particular bot from your own button.- Window events (
wirefacechat:<event>) carrydetail.bot, so one listener can tell them apart.
js
const sales = WirefaceChat.get('pk_sales_bot');
sales.on('lead', lead => crm.add(lead.fields));
document.querySelector('#talk-to-sales').addEventListener('click', () => sales.open());Same bot twice
Booting a bot that is already on the page returns the chat that's there. The exception is the inline layout: an inline chat (with a target) and a launcher chat of the same bot can share a page, and they share one conversation.
Each bot remembers its own visitor and conversation, so visitors have a separate conversation with each bot.