Once you've added a chatbox or popup to your site, and you have some conversations going, you might want your users to be able to switch between them.

In a popup

Let's say you have a few buttons on a page, each corresponding to a conversation topic:

<button onclick="buttonClicked(this.innerHTML)">Conversation A</button>
<button onclick="buttonClicked(this.innerHTML)">Conversation B</button>
<button onclick="buttonClicked(this.innerHTML)">Conversation C</button>

Then we can define buttonClicked(conversationId) as follows

function() buttonClicked(conversationId) {
    //window.talkSession must be set elsewhere
    var conversation = window.talkSession.getOrCreateConversation(conversationId);

    if (window.popup == null) {
        //if there is no existing popup, create one
        window.popup = window.talkSession.createPopup(conversation);
        window.popup.mount({show: true});
    } else {
        window.popup.show(); //in case popup is hidden
        window.popup.select(conversation) //select the conversation clicked on

When the user clicks on a button, the text within the button is used as a conversation id. The popup then makes this the active conversation. select takes either a Conversation object or conversation id as its parameter - see select.

In a chatbox

Assuming someChatbox exists, we can simply do:

function() buttonClicked(conversationId) {
var conversation = window.talkSession.getOrCreateConversation(conversationId);