Hi @shyndman
Apologies for the delay in getting back to you here.
Freshchat’s default properties are firstName
, lastName
, email
, externalId
and phoneNumber
.
You can send any additional details as custom user properties in to Freshchat and it will be shown on the conversation sidebar as Custom User Properties
.
There are a few ways to achieve this.
-
window.fcWidget.user.create()
Method -
This method can be used to create a user on Freshchat as soon as the widget is initalized. Typically used in scenarios where the user is logged into your webapp or website. This approach is best used with the restoreId
concept to prevent user duplication.
var data = {
firstName: "John",
lastName: "Adams",
email: "jadams@company.com",
externalId: "jadams@company.com:accounturl",
phone: "+1987956458",
meta: {
"plan": "Diamond",
"stage": "Verified"
}
}
window.fcWidget.user.create(data).then(function () {
console.log('User Created');
}, function () {
console.log("User Not Created");
});
-
window.fcWidget.user.setProperties
Method -
This method is similar to the above method, however the user will created on Freshchat only when the end user starts a chat entering text on the chat box.
var data = {
firstName: "John",
lastName: "Adams",
email: "jadams@company.com",
phone: "+1987956458",
"plan": "Diamond",
"status": "Verified"
}
window.fcWidget.user.setProperties(data).then(function () {
console.log('User Set');
}, function () {
console.log("User Not Set");
});
-
window.fcWidget.user.update
Method -
This method is typically used when a user is already created via the widget API (for instance using the code from Point #1). This method will over write user data including custom properties for identified users.
var data = {
firstName: "James",
lastName: "Adamson",
email: "jadamson@company.com",
phone: "+1987956458",
meta: {
"plan": "Diamond",
"status": "Expired"
}
}
window.fcWidget.user.update(data).then(function () {
console.log('User Updated');
}, function () {
console.log("User Not Updated");
});
These are three Web widget APIs you can use to Create/Update users on Freshchat.
Hope this helps.
In case you need more help, do reach out to support@freshchat.com immediate response.