How can we access custom user properties stored in our app in our flows?

Hi.
Users of our app have unique properties e.g. “purchase platform”, which we want to use in our flows. How can we set up user ID’s in the chatbot SDK so that this information can be passed from our app and associated with the correct bot user?

SDKs used:

@Tim

in the docs shared, you’ll find sections to pass a payload with the required fields.

Now to access these datapoints inside the flows,
You can use the format of {{{variables.profile.payload.fieldName}}} — inside the bot flow using the Variable nodes

or data.profile.payload inside a function using the code section to set the values

2 Likes

Maybe I’m missing something obvious here, but help me through it :slight_smile: I don’t understand why I would need to use a “variable node” - my understanding is that those nodes are for making changes to a variable’s value. We are already passing a payload with the required fields - now I want to use one of those variables, which already has a fixed value, in a condition node. It gives me a list of variables to choose from, or I can set up a new global variable. I set up a variable called fieldName (as in your example above). But when I test the bot, this does not trigger, and my bot uses the fallback option.

Please log {{data.profile}} and check the values.

Yes, we do this. The values exist. But how can we pass them inside the condition node?

Assign this in a variable and then check.
Or you can check directly with moustache in condition node.

@Tim

Sending data from app/website to the bot

You can do so via the payload which is present in native channels like Web. and Mobile SDKs. You can do it in 2 ways :-

  • By setting values inside the bot (lower code, more so variable setting)
  • By using a function (better when you want to perform some sort of code level logic using these values)

To set this value you can use the variable node. The variable node is not just to change values but to set values to the variables inside the bot flow.

1. Fetching values via variables in the bot flow

Setting via variables would look like inside a flow. Ideally, do this in the welcome flow itself

2. Using Functions

Function code

return new Promise(resolve => {
        let payloadValues = data.profile.payload;
        console.log(payloadValues, "yellow-payload")
        resolve(payloadValues);
    });  

Flows screenshot

Set the returned value inside a variable (usually an object)

Using these values conditionally

Hope this clears your doubts :smiley:

2 Likes

Thank you @gautham , that is helpful, though it hasn’t fully resolved our question.

Of the alternative approaches you demonstrated, we first implemented 1. Fetching values via variables in the bot flow.

Unfortunately, we could not get this to work for us.

Next, we tried using “mustache”, as demonstrated in your final screenshot. This works well for us on condition nodes.

To print variables within a text node we use a template like {{{profile.payload.nameOfVariable}}}, which also seems to work ok.

We still have some issues though. In particular with raising a ticket, where the only option for adding user information to a ticket appears to be via pre-set, drop down selection of variables - as we have not been able to get the variable node to work for us, this leaves our tickets bare.

If {{profile.payload.variableName}} works in the text node - assigning the value to a variable in the variable node should also work

What are you observing when you’ve tested this out?

There was initially no sign to us that assigning values via the variables node is having an effect at all. When I changed the assigned values in the variable node to use the same format that worked for us in text nodes, the bot stopped at the variable node and didn’t move on to the next (text) node in the flow.

Hi @Tim ,
Please check the ScreenShot


You need to assign object or array properties like this.
Please check the datatype of the variable you have created.
If youre assigning a string its datatype should be string, else array/object or likewise.