User Attributes

1. Introduction

User Attributes are data points associated with a user or relevant for the conversation. These attributes are persistent in nature unless they are cleared or overridden explicitly.

User attributes can also be used as variables for storing data related to a path execution. For example – email or username of a chatbot user, items ordered, quantity and delivery address for a pizza ordering bot and so on.

2. Mechanisms for setting attributes

User attributes can be associated or managed via various means. Listing down the various ways how the attribute values can be added, updated or reset – 

  • Set Attribute Node can be used to set an attribute value for a user. While setting the value, it even allows selecting from one of the three types as listed below: 
    • Text
    • Number
    • Date

These types, further allow appropriate search options for the attributes in the Users workflow. 

  • Send Message with Options Node can be set up to store the option selected as an attribute value for the user. To be able to do that – specify the attribute against which you want selected value to be saved in 
  • Request User Data Node can be used to request information from the user and store it as an attribute
  • JSON API Node – The response fields from an API call can be fetched and stored as an attribute which can be utilized later. This can be a really helpful way to load more contextual and relevant information about a user or an activity via an API call. To store a response from an API as an attribute:
  1. Click on the key from the response whose value you want to use in the flow
  2. The attribute is created right below the response box
  3. You can change the name of these attributes as per your desire

Note: This is only available for the customers on the professional plan & higher

  • Script Node – The output of a script node execution can also be returned to add or update a user attribute value. 

You can set up an attribute by using the attributes field which takes in an array of attribute objects. Each attribute object is a very simple object with name and value fields. This field can be used in conjunction with the other sections as well.

  • process({“data”: { },”attributes”: [{“name”: “dob”,”value”: “03/06/1988”}]});

Note: the script node is only available in the Business plan and higher

  • During website bot initialization – For both the widget mode and the standalone mode, attributes can be set up for a user to initialize the bot. This can be helpful for cases where contextual information is available for the user during the chat initiation. 
    • Standalone Mode: While launching the bot using the direct URL, you can specify a Path/flow to be launched as well as specify the values for a set of attributes. 
      • &launch_flow=<Launch_Flow>
      • &data_attrs={key1=val1::key2=val2}
    • These have to be added to the bot’s direct URL
      • <Bot_Key>
  • Website Widget: You can add an additional parameter for user_attributes as is highlighted in an example of the initialization script below: 
    • !function(e,t,a){varc=e.head||e.getElementsByTagName(“head”)[0],n=e.createElement(“script”);n.async=!0,n.defer=!0,n.type=”text/javascript”,n.src=t+”/static/js/chat_widget.js?config=”+JSON.stringify(a),c.appendChild(n)}(document,””,{bot_key:”7b61ede44c1c4928″,welcome_msg:true,branding_key:”default”,“user_attributes”:[{“name”:”user_id”,”value”:”340490123″}, {“name”: “user_email”, “value”: “[email protected]”}]});
  • Identity Node – The identity node can also be used as a simple form to collect data from the user and persist them as attributes
  • Other means for example Google Calendar node utilizes attributes to store the date and time values selected for the appointment/event.

3. System-defined attributes

Outside of the explicitly set up user attributes, there are some system defined attributes which are provided based on the details available in the system about the user. These are namely – 

  • user.user_id – The unique identifier of a user in the MyBOT system
  • First Name – User first name, detects from channel (Facebook)
  • Last Name – User last name, detects from channel (Facebook)
  • user.channel_user_id – The identifier provided by a particular channel where the user is interacting from.
  • – The channel from where the particular user is interacting.
  • user.last_query – The latest text input by the user 
  • user.username – The username of the user as provided by the channel. Not applicable for all the supported channels. Would be blank where the channel does not provide the data
  • user.fileUpload.url – URL of uploaded file
  • user.fileUpload.type – Uploaded file type

4. Viewing Attribute Values

All the attributes which are associated with a user are displayed in the User Details section. Here is an example of the same – 

5. Using Attribute Values

All user attributes including the system provided ones can be accessed in the relevant nodes by using the double curly braces notation {{attribute}}. For example – To access the value stored in email_address attribute, use {{email_address}} in the node. An autocomplete list will start showing up to ease the access to the user attributes. The double curly braces notation is to be only used while accessing the variables. While defining them there is no need to specify braces.

6. Standard Attribute Length

The attributes are limited in size by design. The constraint is due to performance factors.

Here are the standard limits:
1. Up to 25K characters for in flow usage
2. Up to 1000 characters for also persisting this information in DB for reporting and segmentation.
Note : For double byte characters, these limits may be halved.

In order to deal with larger data, it is a standard practice for any development to split the data or use paginated responses.

Was this article helpful?

Related Articles

Leave A Comment?