Chatwoot/docs/channels/website-sdk.md
Pranav Raj S 59f4dd7ebe
Feature: Introduce locale in web-widget SDK (#871)
* Introduce setLocale in SDK

Co-authored-by: Sojan <sojan@pepalo.com>
2020-05-17 16:15:53 +05:30

1.7 KiB

path title
/docs/website-sdk Sending Information into Chatwoot

Additional information about a contact is always useful, Chatwoot website SDK ensures that you can send the additional info you have about the user.

If you have installed our code on your website, SDK would expose window.$chatwoot object.

To hide the bubble, you can use the following setting. Please not if you use this, then you have to trigger the widget by yourself.

window.chatwootSettings = {
  hideMessageBubble: false,
  position: 'left', // This can be left or right
  locale: 'en', // Language to be set
}

To trigger widget without displaying bubble

window.$chatwoot.toggle()

To set the user in the widget

window.$chatwoot.setUser('identifier_key', {
  email: 'email@example.com',
  name: 'name',
  avatar_url: '',
})

setUser accepts an identifier which can be a user_id in your database or any unique parameter which represents a user. You can pass email, name, avatar_url as params, support for additional parameters are in progress.

Make sure that you reset the session when the user logouts of your app.

To set language manually

window.$chatwoot.setLocale('en')

To set the language manually use the setLocale function.

To set labels on the conversation

Please note that the labels will be set on a conversation, if the user has not started a conversation, then the following items will not have any effect.

window.$chatwoot.addLabel('support-ticket')

window.$chatwoot.removeLabel('support-ticket')

To refresh the session (use this while you logout user from your app)

window.$chatwoot.reset()