When chatting with your contacts, your bot can use the information it has gathered during the conversation or by running workflows. Information stored within attributes or tags (see the corresponding documentation for more details on the general functioning of the memory), which can be used within resource messages or as input for other workflows.

While the way of reading the contents of these types of memories may vary, the overall way of accessing them is to use the following writing: {{ abcd }}. This notation also called "moustache writing" allows the bot to know that it must not display strictly the text it is given to know "{{ abcd }}", but the information stored in the attribute or tag named "abcd".

1. Read the content of Attributes

a) Simple attributes (string)

Simple attributes are attributes that contain text such as an email address, name, date of birth, etc.

For example, if you have a "firstname" attribute, accessing its value is as easy as

{{firstname}}

Inside a resource message, it could be used tas follows

Hello {{firstname}}, how may I help you?

As a result, the message displayed to the user "Elisabeth" would be "Hello Elisabeth, how may I help you?"

b) Structured attributes

A "structured" attribute is a data structure that allows to store several pieces of information. This type of data is usually obtained via a "Smart Resource" or following a call to a third party API (see dedicated documentation for more information on these subjects).

For example, an "identity" attribute can store the surname, first name and date of birth of a user. To access each of this information, the following notation must be used.

{{identity.firstname}} (ou {{identite.lastname}}, ...)

2. Read the content of Tags

While Attributes are intended to store information (simple attribute) or a grouping of information (structured attribute), Tags are used to store a list of information.

a) Simple Tags

A simple tag is a list of information where each element is (most often) text. This type of information is notably generated by activating the "Request a list of answers" feature of the Resources. Here is for example a "favorite_sports" tag:

["running", "skateboarding", "curling"]

To access each of these responses in a message, use the following script:

You like {{tag.favorite_sports.0}}, {{tag.favorite_sports.1}} and {{tag.favorite_sports.2}}


⚠️ As you can see on the example, the numbering of the elements of a tag starts at 0. So to access the first element you have to use the index "0", for the second one the index "1", etc.

You can also directly access the complete list of elements of a tag using the following script: {{tag.favorite_sports}} (or {{tag.favorite_sports.[]}}). As for example in the following message text:

Here are the favorite sports you have entered : {{tag.favorite_sports}}

This will give in the conversation: "Here are the favorite sports you have entered: running, skateboarding, curling".

πŸ”† Note that the second notation ({{tag.favorite_sports.[]}}) can be used to display a list of buttons from the contents of a tag. For example, the resource below (and by setting the right associated parameters; see the dedicated doc) :

Will produce the following result in the conversation :

b) Advanced Tags

As we have seen previously, a tag is no more than a list of values. In their simple version, tags are lists of textual values. But these values can be more complex.

  • Tags whose values are lists :

You might indeed want to store (or receive from an API) data that looks like this:

favorite_sports: [[basketball, handball], [skateboarding, basejumping]]

You will then be able to access the information of this tag in the following way: (for example to retrieve the value "basejumping") :

{{tag.favorite_sports.1.1}}}

  • Tags whose values are Objects (like "structured attributes", what)

When you receive a list of data from APIs, it is often in this format :

[
{"name": "running", "frequency": "twice a week"},
{"name": "skateboarding", "frequency": "once a month"},
{"name": "curling", "frequency": "daily"}
]

To access the individual data, then you need to use a combination of everything we have just seen, namely :

I do {{tag.favorite_sports.1.name}} as a hobby, {{tag.favorite_sports.1.frequency}}.

Another similar notation will be very useful, for example to define a list of buttons (a bit like we saw above) or to feed the different sections of a carousel: {{tag.favorite_sports.[].name}}. (for example, if we want to have the list of the names of the sports practiced)

In the case of setting up a carousel, the following setting :

Would give the following result:

3. Use a variable to access a value (a field) in a tag (structured attribute)

This part is for those who are very comfortable πŸ’ͺ with what we have just seen.

So far we have seen how to access an attribute field whose name we know, or an item in a tag with an explicitly given position.

That is to say that if we have a :

tag.favorite_sports = ["running", "skateboarding", "curling"]

you now know that writing {{tag.favorite_sports.1}} when configuring a message will display "skateboarding" in the conversation.

But let's imagine that you asked the user to give you the position of the sport to display, via the position_sport attribute (this attribute can therefore contain the value, 0, 1 or 2). How to use this attribute to display the corresponding item? Well, hang on : you can use "moustaches inside moustaches" 🀯. Concretely, and to end the suspense, to display the sport corresponding to the position chosen by the user, you "just" have to write :

{{tag.favorite_sports.{{position_sport}}}}}

To understand this, it is enough to say that this writing is interpreted in two steps (starting with the above writing; and for the example, let's say that the user has chosen position 2):

  1. {{position_sports}} is evaluated => then we get {{tag.favorite_sports.2
  2. {{tag.favorite_sports.2}} is evaluated => we get "curling" 🎺 πŸ₯ πŸ† πŸ‘

After this simple case, let's look at a slightly more complex case that is closer to reality.

Let's imagine that you have stored the list of the monthly income of a company (MRR) in the "mrr" tag and that you want to display the income of a month chosen by the user (stored in the "month" attribute). To do so, you can write your message like this :

Hey Bernard, you want to know how much money your company earned on {{month}} ; here it is : ${{tag.mrr.{{month}}}

This could produce the following result in the conversation :

Hey Bernard, you want to know how much money your company earned on November ; here it is : $250,000,000 

Not so complicated, eh! πŸ˜‰

Did this answer your question?