HomeGuidesAPI ReferenceChangelogsDiscussions
GuidesChangelogsAPI ReferencePublic RoadmapService StatusLog In

User data

In this section, we will go see some useful things that can help you enhance your Facebook Webchat bot.

Can I send some user data from my website to the bot platform?

Once connected to your website, you may want to send some user data to the chatbot so it can personalize the user experience. It's very simple to do with the built-in user_data that you can use and extend within the webchat integration:

Here is what the default code looks like in our integration code:


var SMARTLY_USER_DATA = {}; // No data sent here

And here is how you can send data to the bot


    "email":"[email protected]",
    "comments":"in this guy, the force is strong"

This allow you, for instance to have personalized greeting messages.
You can use the following code to get the name for instance.

var first_name = user_data.first_name;
output.answer = 'Hello '+ first_name + ', happy to see you again!';

This will show Hello Anakin, happy to see you again!


Add your own fields!

The user_data field is extendable, you can add your own fields on it, and retrieve them from your bot flow

Below is a demo of an intranet bot that greets the user by its first name

Is the user data stored in the platform? How safe is it?

The following fields are stored to be displayed on the Conversation Module

  • first_name
  • last_name
  • email
  • phone_number
  • gtu_accepted
  • comments


If you want to reuse the user data in your conversational flow after receiving it, our recommandation is to store the user data fields in the long_term_memory for a single bot or shared_memory for a masterbot

How safe is it?

This data is hashed and hosted in a secure way. Only collaborators with an access to the Conversations or the Builder module of a specific bot can access the user data generated by this bot.

How can I know if the user is on a mobile device?

We got you covered for this, Smartly.AI webchat is able to detect automatically wether you are on a mobile device or not and so you the information via a value named user_data.on_mobile
This will allow you to code specific behaviors for mobile users. Here is a sample code you can test in a code block of the Builder:

if(user_data.on_mobile == true)
  output.answer = "Hi, I see that you are chatting via a mobile device! πŸ“±";
  output.answer = "Hi, I seems that you are probably chatting via a desktop πŸ’» ";