Migrate from Chat 1.0

Learn how to migrate to the Kustomer Chat 2.0 Web SDK from Chat 1.0.

This guide explains the key changes your team needs to make to migrate to the Kustomer Chat 2.0 Web SDK from earlier SDK versions.

We've listed the Web SDK JavaScript methods you'll need to update for the migration below. Each entry provides brief descriptions and examples of the changes.

πŸ“˜

Where did the method go?

If you don't find the method you're seeking here, check out the full list of Overview: Chat UI API methods. If the method is neither here nor there, there's a good chance that we've deprecated and removed the method from the Kustomer Chat 2.0 Web SDK.

Initialize chat

From Chat 1.0

<script>!function(a,b,c,d){a.Kustomer=c,c._q=[],c._i=[],c.init=function(a){function b(a,b){a[b]=function(){a._q.push([b].concat(Array.prototype.slice.call(arguments,0)))}}for(var d="init clear identify track start describe on".split(" "),e=0;e<d.length;e++)b(c,d[e]);c._i.push(a)};var e=b.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://cdn.kustomerapp.com/cw/sdk.v1.1.min.js";var f=b.getElementsByTagName("script")[0];f.parentNode.insertBefore(e,f)}(this,document,window.Kustomer||{});

// Add your API key here
Kustomer.init('YOUR_API_KEY');

// Start the chat client
Kustomer.start();</script>

To Chat 2.0

<script
  src="https://cdn.kustomerapp.com/chat-web/widget.js"
  data-kustomer-api-key="YOUR_API_KEY"
></script>
<script>
  Kustomer.start();
</script>

πŸ“˜

Updated options for Kustomer.start

We've updated the options for Kustomer.start() in the Chat 2.0 Web SDK. To learn more, see Kustomer.start().

Identify a customer

From Chat 1.0

// Kustomer.identify was run before Kustomer.start()

Kustomer.identify("JWT_TOKEN"); 
Kustomer.start();

To Chat 2.0

// Kustomer.login must now be run after Kustomer.start() completes

Kustomer.start({}, function () {
  Kustomer.login({
    jwtToken: "JWT_TOKEN"
  });
});

Log out a customer

From Chat 1.0

Kustomer.clear();

To Chat 2.0

Kustomer.logout();

Describe a customer or a conversation

πŸ“˜

A more specific way to describe

Instead of the general describe() method available in Chat 1.0, you can use either describeCustomer() or describeConversation().

From Chat 1.0

Kustomer.describe('conversation', { custom: { exampleAttributeStr: 'example' } });

To Chat 2.0

Kustomer.describeConversation({
  conversationId: 'some_conversation_id',
  customAttributes: {
    exampleAttributeStr: 'example'
  }
});

Listen for events

πŸ“˜

Where are the events?

The full list of events you can listen for are available in Kustomer.addListener().

From Chat 1.0

Kustomer.on('unread', count => { 
  console.log('new unread count is ' + count);
});

To Chat 2.0

Kustomer.addListener('onUnread', (callbackResponse, error) => {
  const total = callbackResponse.total;
  console.log('new unread count is ' + total);
});

Open and close chat

Kustomer.open() and Kustomer.close() now accept an optional callback rather than options.

From Chat 1.0

Kustomer.close({
  noIcon: false
});

To Chat 2.0

Kustomer.close();