Using the Chat widget JavaScript API

Have more questions? Submit a request

8 Comments

  • Bharath Kashyap

    Hi Niall,

     

    Quick question..!

    Does this syntax work ?

     

     

    Am looking to customize my web widget through JS. But am not able get hold of the syntax to make widget & JS talk to each other. 

    Let me know how could I make JS functions work for Web widget please.

     

    0
  • Dan Ross

    Hey Bharath,

     

    At first glance, it looks like you need to wrap those zopim calls in a zE(function() (see bold text below) for them to work as you're expecting. 

     

     zE(function(){
        $zopim(function(){
    /// YOUR ZOPIM CALLS HERE
    }); });
    0
  • Bharath Kashyap

    Hi Dan, 

    Much Appreciated with your help. 

    This is a code, checking if simple code works, but cannot see its reflection on chat widget. Any thoughts on this ?

     

    Widget color 

     

     

    0
  • Dan Ross

    Hey Bharath,

    According to the docs, $zopim.livechat.theme.reload(); needs to be called after button.setColor is invoked. Please add that line after your line setting the color. Worth noting that the docs also list button.setColor as deprecated, you may want to consider using the latest function instead.

    “$zopim.livechat.theme.setColor” 

    If that doesn't work, please post any messages you might be getting in your browser's console log. 

    Good luck!

    0
  • Bharath Kashyap

    Hi Dan, 

     

    Tried this 

     

    This is message from Console.

    0
  • Dan Ross

    Hey Bharath,

     

    I'm not sure what adrum.js is, but I think it's independent of this issue. The line you highlighted is a standard message and not an error.  I just saw you have this chat module and API calls in your home_page.hbs file, could you try putting it in your document_head.hbs template? I'm not certain it will make a change, but I don't see anything else that looks wrong in what you've posted.

    0
  • Solvvy, Inc

    Hi Dan, 

     When I try the new web widget API's callback options they don't seem to be working as expected for migrating from the old zopim API's. Consider the following example:

    <script type="text/javascript">
    zE(function(){
    $zopim(function(){
    // Custom code here
    zE('webWidget:on', 'chat:status', function(status) {
    console.log('This chat session is now', status);
    });
    $zopim.livechat.setOnStatus(status=> {
    console.log('This zopim chat session is now', status);
    });
    });
    });

    </script>

    1. This only prints the zopim chat session logs on change in status. The example code for web widget was picked from the documentation https://developer.zendesk.com/embeddables/docs/widget/api

    2. The page that documents equivalent migrations for the API's seems to differ from the actual API documentation. Eg:

    https://developer.zendesk.com/embeddables/docs/widget/chat_api_migration

    In the above link it shows zE('webWidget:on', 'chat.status', (status) => {})

    while in the widget api document it says zE('webWidget:on', 'chat:status', function(status<string>) {});

    Note the colon instead of dot between chat and status. I've tried both and neither worked in the above example.

    I've tried zopim and web widget separately too and they still haven't worked.

    3. The Zendesk webwidget script for our organisation is just a single line that goes something like

    <script id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=KEY">

    Is that causing any problems?

    Thanks,

    Solvvy

     

    akclsdkmsd

    0
  • Dan Ross

    Hey Solvvy,

    I've not checked out the newer Chat APIs yet, but it's on my to-do list to migrate. The fact that the docs differ is never a good sign. I don't actually work for Zendesk, so I won't be able to tell you what the correct method to use would be - you may want to drop a ticket to them and show them the inconsistency in the docs and see if they can get you an answer as to which of them is the correct one to use.

    I don't see anything wrong with your syntax though, so it seems like its an issue with the API not delivering what you're expecting it to. 

    Sorry that wasn't more helpful. If you check with their Support team and get an answer that works, please come back and share, I imagine many people would be interested in the correct method!

    0

Please sign in to leave a comment.

Powered by Zendesk