Out of the box, TalkJS supports and automatically sends e-mail, SMS and push notifications. However, if you got this far, you might have noticed TalkJS does not yet send any e-mails, SMSes or push notifications, only browser notifications. TalkJS needs some additional information before it can. Until then, it's only a chatbox - great for testing and getting a feel, but not so great for going live.

TalkJS is also designed as a "slow chat" where conversations are real-time when both parties are online, but if not it becomes e-mail based and that works just as well. This means users can reply to a conversation via e-mail and their replies will show up in the conversation which gets your users the speed and informality of chat, without the pressing need to be online and available all the time.

A Configuration

In the Dashboard, you can modify the behavior of TalkJS in all kinds of ways. This is done through a named set of settings called "configurations", and you can have more than one configuration in your app.

For example, let's assume your app is a marketplace, where buyers interact with sellers. We'll first finetune TalkJS for the buyers in this marketplace. Create a new configuration called buyer in the Dashboard, and set it up as you see fit. Notably, TalkJS needs the link back to the page containing your Inbox or your Chatbox so that buyers can respond to messages with a single click.

For example, let's tell TalkJS that Alice is a buyer:

var me = new Talk.User({
    id: "123456",
    name: "Alice",
    email: "[email protected]",
    photoUrl: "https://demo.talkjs.com/img/alice.jpg",
    welcomeMessage: "Hey there! How are you? :-)"
    configuration: "buyer" // <-- that's the one!
});

Do this for all User objects you create of users that are buyers. From then on, whenever any of these users logs in or receives a message, the buyer settings will be applied.

Then, make a second configuration, say, seller, for the sellers and repeat the process. Try it out! Ensure that the recipient's user email is set to an address from which you can read and write a message. If the user is offline, you should see an email appear shortly.

When are notifications sent?

The TalkJS notification system has been carefully designed to send notifications as fast as possible, while not giving your users the feeling that they're getting spammed. We use a number of heuristics to get this right.

There are a few conditions that must be met in order to send notifications:

  • The user is offline.
  • The user is online, but has a different conversation selected in the UI.
  • The user is online, has the current conversation selected in the UI, but the browser tab/window does not have focus.

In other words, a notification is not sent out when the user has the current conversation selected in the UI and the tab containing TalkJS is focused.

To keep the email count low, subsequent messages are grouped together. After a user sends a message, TalkJS tracks whether they continue typing. A notification is sent when the user has stopped typing for a number of seconds, with all the messages they sent since they started typing.

This also holds for group conversations: if two users have a quick real-time interaction, then the notification sent to the other participants will include all messages sent since the first user started typing until the last user stopped typing.