Livecaller Guides
  • Management Console
    • Getting Started
      • Web Call
      • Co-browsing
      • Omni-Channel Inbox
    • Realtime dashboard
      • Tags Attach / Detach
    • Customer profiles
    • Inbox
      • Tag Management
      • Send Email
    • Live conversation
    • Blocked
    • Callbacks
    • Conversation history
      • Export to Excel
      • Export chat to PDF
    • Conversation Reports
    • How to transfer a chat
    • Working hours
    • Widget managemant
      • Pre-chat survey
      • Multi-language translation
      • Message typing preview
    • Chat shortcuts
    • General analytics
    • Agent Report
      • Agents performance
      • Response times
      • Availability
      • Satisfaction
      • Agent Activity
    • Notifications
      • Autoplay Policy
    • Integrations
      • Facebook Messenger
        • Meta Data Managment
      • WhatsApp
      • Instagram
      • Email
      • Viber
      • Telegram
    • Permission management
    • Chatbot
      • Events
      • Conditions
      • Actions
    • Automatic rules
    • Roadmap
  • Widget API
    • Javascript API
    • CSS
  • FAQ
    • Web call does not work?
    • How to change or translate widget texts?
    • How to remove "powered by livecaller.io"?
    • Timezone issues
    • Mobile app - iOS, Android
    • Does Livecaller support startups?
    • What is the duration for which information history is retained?
    • How to install?
    • Other Questions
Powered by GitBook
On this page
  1. Widget API

Javascript API

PreviousRoadmapNextCSS

Last updated 2 years ago

Open, Close and Toggle widget

LiveCaller.$emit('ui.widget.open');
LiveCaller.$emit('ui.widget.close');
LiveCaller.$emit('ui.widget.toggle'); 

example of a button, when clicked it will toggle Livecaller's widget frame

<script>
  document.getElementById('your button id').addEventListener('click', function (e) {
    e.preventDefault()LiveCaller.$emit('ui.widget.toggle')})
</script>

Listen to the widget opening or closing events

LiveCaller.$on('ui.widget.open', () => {});
LiveCaller.$on('ui.widget.close', () => {});

Change language

change en to your native language 2 letter iso code:

Change language before the widget load

LiveCaller.config.merge({app: {locale: 'en'}});

Update language inside the loaded widget

LiveCaller.$emit('app.locale.update', 'en');

JWT authentication

For authentication and profile editing is used JWT verification algorithm HS256.

Token lifetime is 15 minutes Necessary payload information: sub - unique id of the customer in your system iat - token generation timestamp ( UNIX timestamp seconds)

JWT Header example:

{
  "alg": "HS256",
  "typ": "JWT"
}

Edit Customer JWT Payload example:

{
  "sub": "12ba81b2-c1fe-479b-8b4a-09fecb02a3d6",
  "name": "John Doe",
  "email": "user@example.com",
  "mobile": "995000123456",
  "iat": 1565610612
}

User authorization

LiveCaller.$emit('user.login', 'JWT Token Here');

User profile update

 LiveCaller.$emit('user.update', 'JWT Token Here');

User Logout

LiveCaller.$emit('user.logout');

Read more about JWT here:

https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
https://jwt.io/