Use the keystore


In this post, we are going to see how to use the Keystore and apply it to a real case of use.

The Keystore is meant to share information between different records or flow executions, so for this showcase, we are going to create a flow and a keystore schema.

The flow will send a different email depending on whether or not the user has been involved in a previous campaign.

Creating the keystore schema

We go to the Keystore Schema section and click on “New Keystore” button, we can “display as code” and insert the following JSON:

   "full_name": "",
   "email_address": "",
   "campaigns": []

We click on the button “Create” and we give a name to our keystore, in this case, user_info.

Now the flow functions have been created automatically so we can directly go and create the flow.

Creating the flow

These are the functions we are going to place in the flow, see here the documentation to create a new app:

  • Get keystore user_info: this function will get the keystore by the given key, which is @interface.email_address@. In case it doesn’t exist it will create it with the empty schema.
  • Dynamic decision: we check here if the @keystore.user_info.campaigns@ is empty, so we know if it is the first time we send an email to this user.

Depending on the previous condition (Dynamic decision), if the user is new:

  • Megamail: We send an email with the campaign found in the @interface.campaign@, assuming we have created a content called, for example, 123_campaign.
  • Update keystore user_info: this is one way to update the whole keystore for a given key, we are going to overwrite, in this case, the empty JSON with the resultant one once that @interface variables are replaced:
       "full_name": "@interface.full_name@", 
       "email_address": "@interface.email_address@", 
       "campaigns": ["@interface.campaign_name@"] 
  • End: we finish the execution.

If the user had received a previous email campaign:

  • Megamail: We send an email with the campaign found in the @interface.campaign@, this time we append _plus to the name of the campaign, assuming we have created also a content called 123_campaign_plus to, for example, reward our customer for staying with us since previous campaign.
  • Update variables: in this case, we are going to update the variable @keystore.user_info.campaigns[]@ (we use [] to append a new entry to an array), including the new email campaign we just sent to this user @interface.campaign@.
  • End: we finish the execution.

As you might have noticed, we can use this flow to send several campaigns over time by sending a batch file, so in the following ones, we can differentiate between new and regular subscribers.

Unique and exclusive key

It is very important to choose the right @ variable that contains a unique key for the keystore when we set up the flow, we should think about which is the entity we want to save in the keystore. For this example, let’s think it is information about people.

If we use the name and surname of a person, this might end up messing up our data stored in the keystore, merging or overwriting information of two people with the same name.

A good key for a person would be its ID number. That key is unique per person and a person can only have one. Passport number or another kind of ID would also be good, depending on the provenance of our data.

Like this, we can always find the information of a certain person having its identifier.