Push a user attribute

Push a User Attribute via the webchat SDK.
In order to push an attribute, its name must have been declared in the whitelist configured in the API settings of your bot.

1337

You can push an attribute and ignore request result.

window.ClustaarWebchat.pushAttribute('city', 'Paris');

Or you can push an attribute with a promise, in order to know if the call was successful.
The returned attribute is a boolean.

window.ClustaarWebchat.pushAttribute('city', 'Paris').then(function(ok){
  // "ok" is a boolean: true if the attribute is whitelisted and has been set successfully
  console.log(ok);
});

🚧

Important

If you want this piece of code to run in IE11 (which does not support much of ES6 at all), then you need to get a 3rd party promise library :