When a contact field is created, the default value is null unless the field is imported with a pre-existing value. To change the value of a recently-created contact field, you can update it using this action or by editing a contact field value via the contacts tab. For example, when a new phone number sends a message to a channel connected to your account, a new contact will be created with a null Name value and null values for every contact field you've added. The new contact will only be identifiable by their phone number until their other field values are updated.
Use the Update the contact action to:
- create a new contact field and update its value for each contact that reaches this action
- update the value of an existing contact field for each contact that reaches this action
Using Community Connect Variables & Expressions
Contact fields can be updated with a fixed value, expressions, or Community Connect variables:
-
@flow - the variable assigned to the result of each RuleSet. May also include .text (e.g. @flow.response_1.text, the full text of the incoming message sent by the contact), .category (e.g. @flow.response_1.category, the category through which the incoming message sent by the contact passed) or .time (e.g. @flow.response_1.time, the time at which the incoming message was received from the contact).
-
@date - used to call date values (@date.now, @date.yesterday, @date.today, @date.tomorrow)
-
@channel - the channel that handled the incoming message (@channel.name, @channel.tel, @channel.tel_e164).
-
@step - the contact who sent the last message handled by the workflow. In most cases, this is also the active contact@step.value.
-
@extra - references variables pulled from an external application via a WebHook.
- An expression, e.g. @(HOUR(NOW())).
-
@parent - references variables collected by a parent flow.
- @child - references variables collected by a child flow.
Creating a New Contact Field
To create a new contact field using the Update the contact action, simply type the name of the field you want to add in the Save to field input.
Then, input the field value you'd like to give contacts that reach this step in the flow (in the form of a fixed value, variable, or expression). In the example below, we're creating a City field and updating that value to the fixed value Oakland for contacts who reach this step in the flow:
Updating an Existing Contact Field
In the example below, we're updating the Due Date field for contacts who have indicated they're pregnant using @flow.due_date, a variable collected earlier in the flow:
Incrementing Numeric Values
Contact fields must contain a number in order to be incremented. You can use Community Connect's expressions language to test a field for a value before incrementing it, e.g:
@(IF(contact.<field> <> "",contact.<field>, 0) +1)