Attributes

Prefer a step-by-step guide? Try our attributes tutorial.

The attributes service is essentially a simple key/value store. It allows you to keep track of any attribute (for example, a name, age, or preference) against a bot's response path.

Set an Attribute

This action sets or updates an attribute's value. To set an attribute, you'll need to give a response path, attribute name(s) and value(s). Let's explain what each of those are:

  • Response Path - use a bot response path here so that you can link the attribute to a particular bot conversation. The response path is a unique identifier which you'll receive with bot triggers. You can actually use any value in this field, not just a response path (use the pencil icon to edit it). See the section below 'Using attributes more generally' to learn more about that.
  • Attributes - set as many attributes as you need to. Each attributes takes a name and value. The name should be something like 'age' or 'email' (made up of letters, numbers, hyphens or underscores only). The value itself should be up to 200 characters long and shouldn't include any spaces, for example '35' or 'john@example.com'.

Using an empty value will unset/delete the attribute. As well as setting any string, you can use the notation +n or -n to add or subtract numbers from the existing value. If you try adding or subtracting from an unset attribute, it will be assumed to be 0. For example, to add 10 to an existing value of 10, use '+10'. The new value will be 20.

Each field above can accept up to 200 characters.

Attributes on Bot Triggers

Once an attribute is set against a response path, when a bot trigger fires for that response path (for example, on a new message), the attribute will be provided in an output called Attributes in the output data.

You can then use the attribute to filter the trigger, or use it in any of your actions within the flow. See our other guide about using attributes for more details.

Get an Attribute

This gets the current value of an attribute (or returns empty outputs if the attribute is not found). You'll need to provide the response path and attribute to get its value.

You'll get these outputs:

  • Response Path
  • Attribute
  • Value
  • Created At - the date & time (ISO 8601 format) that the attribute was first set.
  • Updated At - the date & time that the attribute was last updated. This will be set to '0000-00-00 00:00:00' for a newly set attribute.

Note: If you set an attribute with the same value as it's already set to, the Updated At date won't change.

Get all Attributes

Provides any attributes set against the response path in an output called Attributes. You can use the Attributes output just like the similar one you receive with bot triggers. See our guide to using attributes for some tips.

Attribute Updated

This is a trigger that will start a flow every time a known attribute is first set or its value changes.

A separate interaction is triggered for every response path/attribute combination that is updated. You'll get these outputs through:

  • Response Path
  • Attribute
  • Old Value
  • New Value
  • Created At - the date & time (ISO 8601 format) that the attribute was first set.
  • Updated At - the date & time that the attribute was last updated. This will be set to '0000-00-00 00:00:00' for a newly set attribute.

Using Attributes

There are many ways to use attributes, but we'll talk about some of the most popular uses here.

Persisting data across interactions

Suppose you received a message through a bot, and asked the user what their name and favorite film is. The next time you interact with that same user, you'll want to be able to recall those details.

So we set up a flow like this:

  • Bot > New Message (on direct message "remember my favorite film").
  • Bot > Ask a Question (asks "what's your name?").
  • Bot > Ask a Question (asks "and your favorite film?").
  • Attributes > Set an Attribute (set the response path from the trigger, then set 'name' and 'favorite_film' as attribute names, with answers from the questions we just asked as the values).

Now, you can create another flow:

  • Bot > New Message (on direct message "what's my favorite film?").
  • Bot > Send a Message ("Hi {{bot_new_message.attributes__name}}, you told me your favorite film is {{bot_new_message.attributes__favorite_film}}." You can see here that the attributes are taken from the trigger's data).

In fact, you could also improve this by filtering on the 'name' attribute value and either sending the message above, or if it's empty, sending a message to say that we don't know it.

Now, you could also create a third flow that is triggered on Attributes > Attribute Updated. Use the attribute 'favorite_film'. Your flow will then trigger every time a user sets or updates their favorite film.

You could maybe use a webhook to get matches for similar films from a film API, and then message the response path with some suggestions.

Using attributes more generally

You might sometimes need to set attributes of your bot in general. In that case, it's actually OK to use a general identifier like 'my_bot', 'stats' or even 'general' in the Response Path field.

Try using the Date & Time service to get the current date ('2016-05-18') and use that in Response Path to save attributes of the current day, such as 'votes_today' or 'interactions_today'.

FAQ's

How many attributes can I store?

There is no limit, other than a general fair use policy.

Why is there no delete/unset attribute action?

To unset or delete an attribute, simply set it with an empty value. That will delete it completely. Note that deleting an attribute will trigger Attribute Updated.

Can I delete all attributes, in bulk?

Sorry, there's no way to do that currently.

How often do updated attributes trigger?

We check for updates either every minute (on paid plans) or every 5 minutes (on the free plan). You can see our pricing details here.

Let us know how we can improve Flow XO on our feedback site.

Still need help? Contact Us Contact Us