Add or update user properties from AI-agent 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 AI-agents.
Channel | User properties captured | Additional details |
---|---|---|
WhatsApp AI-agent | Phone number, Country code | Captures 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 AI-agent | Timezone and country code | Uses IP address to capture these details. |
This is currently supported for web, and WhatsApp AI-agents.
Different ways to add/update user properties
There are four different ways in which you can capture user properties:
Store user properties from AI-agent 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 AI-agent 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 AI-agent, use Prompt nodes or Variables node in the AI-agent Builder.
- 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.
To capture property values from other variables
If you want to capture user properties from other variables, use the syntax: {{variables.variableName}}
.
Check out the list of all the user properties.
To capture user property values from bot script/function
For example, in the sample script below, to capture the phone number as the userId:
`<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>
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.
To access property vallues from the payload
schema above, you can use the syntax: data.profile.payload
.
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}}}
- 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 AI-agent conversations
Once the user is identified, you can update the user properties (other than userId) using the Prompt or Vaiable nodes.
You cannot update user ID 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:
Capture the user property that you want to update using the Variable node or Prompt node, as explained in Store userId through builder.
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.
In the Variable node, choose the relevant user property or add it manually using the syntax
{{user.propertyName}}
Furthermore, learn how to capture variables from Functions, Payload, and Bot script. Please note that the process for capturing userId or any any other user property remains the same.