angularjsinitializationchatsmooch

Upgrading Smooch from 3 to 4. When I get the messages, the user is Web User b0b0b2865ba9080d31d7894d instead of having the name


I use the latest version 4.13

This is my init:

var promise = Smooch.init({
                appId: smooch_key,
                givenName: $rootScope.data.user.first_name,
                surname: $rootScope.data.user.last_name,
                properties: {
                    email: $rootScope.data.user.email,
                    uid: $rootScope.data.user.id,
                    language: $rootScope.data.user.language,
                    country: $rootScope.data.user.country
                }
            });
            promise.then(function() {
                $('#sk-holder').addClass('no-print');
                $rootScope.smooch_inited = true;
            });

As you can see, I give it the name, but it seems to now work. What am I doing wrong?


Solution

  • givenName, surname, and properties are not part of the supported init parameters. You should call Smooch.updateUser to set the properties on the user record

    Smooch.init({
        appId: smooch_key
    })
        .then(function() {
            Smooch.updateUser({
                givenName: $rootScope.data.user.first_name,
                surname: $rootScope.data.user.last_name,
                properties: {
                    email: $rootScope.data.user.email,
                    uid: $rootScope.data.user.id,
                    language: $rootScope.data.user.language,
                    country: $rootScope.data.user.country
                }
            });
    
            $('#sk-holder').addClass('no-print');
            $rootScope.smooch_inited = true;
        });