$zopim is not defined

I've found a better solution (after submitting a request to support)

    zE(function() {
        $zopim(function() {
            $zopim.livechat.setName("{{\Auth::user()->name}}");
            $zopim.livechat.setEmail("{{\Auth::user()->email}}");
        });
    });

I was using a Zendesk Chat Code within Zendesk Support that is why I need to add Ze function to make it working using api.

Edit: check the interesting comment from Jay Hewitt and also his answer on this question.


This will loop, waiting for $zopim and $zopim.livechat to be loaded. Once they're loaded it will stop looping.

var waitForZopim = setInterval(function () {
    if (window.$zopim === undefined || window.$zopim.livechat === undefined) {
        return;
    }
    $zopim(function() {
        $zopim.livechat.setName("{{\Auth::user()->name}}");
        $zopim.livechat.setEmail("{{\Auth::user()->email}}");
    });
    clearInterval(waitForZopim);
}, 100);