Skip to main content

Add or update user properties from bot conversations

Auto-capturing of location-specific user properties

The system can automatically capture essential user details based on the user's location for both Web and WhatsApp bots.

ChannelUser properties capturedAdditional details
WhatsApp botPhone number, Country codeCaptures country using the country code in phone number. However, the system may not capture the user's name in all cases, as the user might not have provided it, or the name might contain numbers or special characters that fail validation for the firstName and lastName properties.
Web botTimezone and country codeUses IP address to capture these details.
note

This is currently supported for web, and WhatsApp bots.

Different ways to add/update user properties

There are four different ways in which you can capture user properties:

Store user properties from bot conversations

In addition to the userId, you can also store other user properties in real-time within the user record. User properties are stored in the current record, which is mapped in User 360. You can utilize these properties to create personalized conversations with bot users, taking into account their previous interactions and preferences.

To store user details (such as name, email address, phone number, and any other relevant information) through the bot, use Prompt nodes or Variables node in the bot Builder.

note
  • All user properties captured for a record will be mapped to the user as soon as the `userId' is captured during the session.

To store the user’s response in User 360, in Store Response in, choose variables only under User properties. If a specific user property is not avilable, create a custom property and use it.

Capture user property values from the bot script

Use the syntax: data.variables.variableName

For example, in the sample script below, to capture the phone number as the userId, use data.variables.phoneNumber:

`<script type="text/javascript">`  
window.ymConfig = {"bot":"x1673261303850","host":"[https://cloud.yellow.ai](https://cloud.yellow.ai/)", "payload":{"name":"Tom","phoneNumber":"9090000000","email":"[[email protected]](mailto:[email protected])"},};
(function() {
var w = window,
ic = w.YellowMessenger;
if ("function" === typeof ic) ic("reattach_activator"), ic("update", ymConfig);
else {
var d = document,
i = function() {
i.c(arguments)
};
function l() {
var e = d.createElement("script");
e.type = "text/javascript", e.async = !0, e.src = "[https://cdn.yellowmessenger.com/plugin/widget-v2/latest/dist/main.min.js](https://cdn.yellowmessenger.com/plugin/widget-v2/latest/dist/main.min.js)";
var t = d.getElementsByTagName("script")[0];
t.parentNode.insertBefore(e, t)
}
i.q = [], i.c = function(e) {
i.q.push(e)
}, w.YellowMessenger = i, w.attachEvent ? w.attachEvent("onload", l) : w.addEventListener("load", l, !1)}
})();
</script>

Capture user property values from Function

You can use the Function node to capture and store the variable in the respective user property.

For instance, here returnId is the function name containing the provided code.

return new Promise(resolve => {
let payload = data.profile.payload
if (typeof (payload) === "string") {
payload = JSON.parse(payload);
}
console.log(payload);
ymLib.logger.log(payload,"init--Payload");
resolve(payload)
});

Store the response returned by the Function in the corresponding variable, in this case, 'userId`.

Capture user properties from API or integration action payload

First, store the payload in an object variable.

Sample payload

{
"name": "Tom",
"phoneNumber":"9090000000",
"email":"[email protected]"
}

To access a specific key value from the object variable, use the syntax: {{{variables.objVariableName.key}}}

For example:

  • {{{variables.userData.phoneNumber}}}
  • {{{variables.userData.email}}}
note
  • You can also use SDK APIs to programmatically set user properties and the user ID.
  • You can also make use of Function to extract the required information from a payload.

Update user properties through bot conversations

Once the user is identified, you can update the user properties (other than userId) using the Prompt or Vaiable nodes.

note

You cannot update user properties once captured. If the userId is captured again in a flow, it will map to the existing record if it already exists, or create a new userId if it does not exist. To know about user identification in Builder, see How user records are created through conversations & unified in User 360.

To update existing user properties:

  1. Capture the user property that you want to update using the Variable node or Prompt node, as explained in Store userId through builder.

  2. Store them in the respective User properties, as explained in Store user properties through builder.

  • In Prompt nodes, choose the relevant name under User properties.