The Current User

Near the top of our TalkJS code, we created a Session, but we haven't given it much attention yet in this guide. This code has remained pretty much untouched:

await Talk.ready;
const me = new Talk.User({
id: '123456',
name: 'Alice',
photoUrl: '',
welcomeMessage: 'Hey there! How are you? :-)',
role: 'default',
const session = new Talk.Session({
appId: 'YOUR_APP_ID',
me: me,

This code should, ideally, appear on every page you serve, so that TalkJS can notify your users and your app of changes. Also include the <script> snippet, which loads TalkJS (without slowing down your page).

Note: you can also load TalkJS using our npm package if you prefer.

Starting a session

In the second <script> body, we use the Talk.Ready promise to wait for TalkJS to load. Then, we initialize this user's session. A session is the connection between a user's active browser tab and TalkJS. It also identifies your app to the TalkJS backend and it synchronizes your user's profile information. Read more about sessions.

As you might notice, we're still logged in as Alice. Use the same code that you used in the last section to remove Alice and replace it with information about the currently logged in user.

Next steps

That's it! You now have a basic 1-on-1 chat up and running. Check out the Features section for many ways to enrich and customize TalkJS. For instance: