You can also show a conversation in a popup widget that only shows up when the user clicks a button somewhere. When shown, the popup is positioned on the bottom right of your page.

The code for showing a popup is virtually identical to the code for showing a Chatbox: Just change createChatbox to createPopup and remove the parameter to the mount function. However, you usually don't want to show the popup right when the page loads, but only when the user clicks some button. This is easy with a little bit of JavaScript: we'll need to put the createPopup call in an event handler.

Let's assume the user is on another user's profile page and you added a button with id="btn-getInTouch" that's supposed to trigger the popup when clicked. Find the lines that start with var inbox = and change them into the following:

    var other = new Talk.User(/* user data from your backend - see previous chapter */);

    var conversation = talkSession.getOrCreateConversation(Talk.oneOnOneId(me, other));
    var popup = talkSession.createPopup(conversation, { keepOpen: false });
    popup.mount({ show: false });

    var button = document.getElementById("btn-getInTouch");
    button.addEventListener("click", function(event) {

The line popup.mount({ show: false }) will make sure that the popup will be preloaded in the browser and will only show up after an explicit in the button click handler. Optionally you can choose to mount and show it in one go (because e.g. there is no way to preload the data) by calling: popup.mount().

You can make a popup persistent across the page loads by changing keepOpen setting to true.

See the Popup JavaScript API reference for additional events and features.

Looking good? Let's enable notifications.