Needed: Complete list of available fields for Freshchat's JS Messenger Widget user API

:point_right: 1. Describe the challenge that you are facing or the topic that you want to discuss

I have been poking at the fcWidget.user API for hours, and still can’t figure out what it supports. All I want to do is set the contact’s status and lifecycle stage, but it resists me at every attempt.

I’ve tried every possible key/value/location of status/stage that I can think of, but as far as I can tell it isn’t possible, despite what the docs suggets: Freshchat SDK API

What’s worse is that when you provide an unrecognized top-level user property, the API almost fails in a useful way by listing the API’s expected fields…but it gets truncated!! Arrrgh!

And when I supply status/stage as part of the meta object (which is where the data appears in the object returned by a user.get()), the fields are ignored (or it fails silently???). Zero feedback.

Please provide a complete listing of available user properties. I really want to like this product, but its programming interfaces are opaque, and the docs superficial. :frowning:

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.

  1. 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");
});
  1. 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");
});
  1. 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.

2 Likes

Hey Arjun!

Thanks for getting back. The list of fields is much appreciated.

Can I get some clarification on point #1? You seem to suggest that I can create a user via the widget before the user has written their first message? This conflicts with my experience so far.

If this is the case, it would be incredibly useful. I’d love to be able to provide the user a tailored experience via targeted campaigns before any interaction, because I have enough information to do so.

Arjun!!

I am entirely mistaken. Everything works as you say. This is wonderful.

One thing that I’m noticing is that triggered campaigns don’t appear to be triggered on the same page that the user was created. For example, if I have a campaign triggered by the existence of a “show_survey” custom property, the campaign will not appear until the user navigates to another page. Can you confirm?

Thank you!

Nevermind. I figured it out.

For those who are wondering about the same thing, each Triggered Campaign has an associated trigger condition (which you can find on the Target Audience panel for the campaign).

Switch this from “on the load of every page” to “on any event contained in this rule”, and you’ll be good to go.

1 Like

Hi @shyndman,

Glad to know that you figured it out.

Sorry I could not help you earlier.

Let me know in case you have any more questions :slight_smile: