The InboxTuesday, June 2, 2020 6:22 AM
The TalkJS Inbox is what you've seen up until now. Chat history on the left, selected conversation on the right. It's designed to act as the messaging center of your app, and it usually lives on its own page.
If you want your app to have an inbox, now would be a good moment to make a separate page for it, typically with a URL such as
Cut&paste all the code you wrote up until now to that page.
Just the inbox
In fact, the code you have now does two separate things:
- It creates the inbox
- It starts or continues a conversation with a user.
You probably don't always need step 2. Many TalkJS customers therefore give their inbox page an optional parameter, which tells the page to start a new conversation, and not just show the message history.
For example, you could design a URL path like
yoursite.com/inbox?chatWith=12345, and only generate the code you edited in the previous chapter if the
chatWith parameter is given.
Then, from anywhere else in your app, you can make a button link to that URL that lets the current user start a new conversation with a given other user.
For showing the inbox without starting a new conversation find the lines that contain
createInbox and change them into the following:
const inbox = session.createInbox(); inbox.mount(document.getElementById("inbox-container"));
var inbox = window.talkSession.createInbox(); inbox.mount(document.getElementById("inbox-container"));
Next step is to tweak the placement of your Inbox.