In this chapter we'll describe how to configure workflows that are launched from the SMS Pipeline. NoteLooking for Text to Workflow?Before the SMS Pipeline was introduced, Text to Workflow was the go-to solution for automating SMS processes in Rock. If you're already using Text to Workflow your configuration will still work, but we recommend using the SMS Pipeline feature going forward. You'll find it's even more powerful and flexible than Text to Workflow. Workflows initiated from the SMS Pipeline page are configured like other types of workflows described in this guide. The only difference is that these workflows will need to be configured to receive information about the SMS message from the pipeline. We'll walk you through that process below. Workflow Configuration for SMS Pipeline As you've learned throughout this guide, there are lots of different ways to configure your workflow types. The example below is not intended to be a set of instructions that you must follow exactly for your workflow to function. We'll go over other options a little later. For now, we'll walk through an example just to explain the features. First, keep in mind that the pipeline can send the information it has to your workflow automatically. For instance, your workflow configuration doesn’t require an action to identify the person. You’ll still need workflow attributes to store that information, so that’s where we’ll start. In this example we’ve set up only a few attributes that the pipeline can populate. See below for the full list. These attributes allow the person, their phone number and the content of their SMS text message to be sent directly to the workflow. From there, you can perform any number of Actions or Activities using those attributes. In the example pictured below, we’ll add a Person Note that contains the person’s name and the text of the SMS message they sent. As you can see in the above example, your workflow configuration for pipelines won’t be very different from other kinds of workflows. Actions and Attributes are set up and used in the same ways. However, there is some configuration you’ll need within the SMS Pipeline itself to make it all work. We’ll cover that in the next section. Working with the SMS Pipeline After your workflow has been configured, you're ready to add it to the SMS Pipeline. In this section we'll highlight the pipeline configuration related to workflows. For information on SMS Pipelines in general, see the SMS Pipeline chapter of our Communicating with Rock guide. Pictured below is a basic example of a workflow configuration in the pipeline. Keep in mind the workflow configuration that was described in the prior section, because it will be referenced here. Workflow Type - This is the workflow type that we want to launch for an SMS message.Pass Nameless Person - You can disable this setting to prevent Nameless People records from being sent to your workflow. We’ll talk more about working with Nameless People below.Workflow Name Template - This field lets you dynamically assign the name of each launched workflow, for each SMS message received. In this example, the workflow name would be "SMS From Ted Decker" if Ted Decker sent the message.Workflow Attributes - This is where you can feed information from the SMS message directly into your workflow. You'll use theKeyvalue of the workflow's attribute in the first field. In the second field you'll add the Lava that identifies how you want to fill in that attribute's value. As described above, your pipeline configuration can send attribute values directly to your workflow's attributes. In the next section, we'll look at the details of how this works and the different attributes you can set. SMS Pipeline - Workflow Merge Fields The SMS messages that you receive have more information associated with them than you might think. You can use Lava to send that information directly from the pipeline to the workflow. In the example pipeline above we used {{ FromPerson.PrimaryAlias.Guid }} in the Workflow Attributes Merge Template field. Using {{ FromPerson.PrimaryAlias.Guid }} identifies the person who sent the SMS message in a way that the workflow can receive it. This will be assigned to the 'Person' workflow attribute when the workflow is launched, using the attribute's Key as a reference point between the pipeline and the workflow. Similarly, we used {{ FromPerson.FullName }} to set the name of the launched workflow. Adding .FullName gives you the name of the person, as text. WarningWarning: FromPhone is automaticDon't add an attribute called FromPhone to the Workflow action in the pipeline unless you are intentionally trying to overwrite it. The one that is automatically placed there is the 'raw' value which has the '1' (country code) prepended onto it. If you manually add FromPhone, it will overwrite the value and use the one without the country code. That could lead to unexpected behavior in your workflow. The table below lists other merge fields you can use to pass different types of information from the pipeline to your workflow's attributes. Merge FieldDescriptionField Type {{ FromPerson.PrimaryAlias.Guid }}The pipeline uses the person's phone number to look up the first person with that phone number. If it finds a match, it assigns that individual's record to FromPerson. If the phone number is used in more than one profile, the pipeline defaults to the first record of an adult with children.Person {{ FromPhone }}The person's phone number, pulled from the inbound message, from the SMS gateway. This will automatically get added to the workflow as FromPhone and will include the country code (i.e., the raw phone number 18645555555).Phone Number {{ ToPhone }}The SMS gateway number where the message was sentPhone Number {{ ReceivedDate }}The date the message was received.Date {{ ReceivedTime }}The time the message was received.Time {{ ReceivedDateTime }}The date and time the message was received.Date Time {{ MessageBody }}The content of the SMS message that was received.Text or Memo {{ MatchedGroups }}If the RegEx expression provided contains matched groups, they are loaded into an array here. This is an advanced feature, so if you’re not sure what this means, don’t worry. You probably don’t need it.Typically, you fill in a text field with a merge expression of a single result from the MatchedGroups array. In your workflow, avoid naming any attributes SMSResponse. If the workflow type that is initiated by the pipeline has an attribute with a key of SMSResponse, the contents of that attribute will be immediately sent to the person who texted in, bypassing any workflow processing. Using Attribute Set to Initiator There are some reasons why you might want to have the workflow find values for its attributes instead of sending them from the pipeline. The first consideration is maintenance. The workflow attributes and the pipeline configuration must be kept in sync to work properly. Using the Attribute Set to Initiator approach instead, you don't have to worry about changes to the pipeline impacting your workflow's functionality as long as your workflow accounts for different scenarios. The above point leads to the second consideration, which is flexibility. Using a method like Attribute Set to Initiator means the workflow can be launched from a variety of different sources. It will be more difficult to use the workflow in other contexts if it's designed to rely on specific data from the pipeline. Attribute Set to Initiator - The person who sent the SMS message is the initiator. By assigning the initiator to the "Person" attribute, we now have the person’s record in the workflow.Attribute Set Value - Here we'll use some Lava to get the name of the person we identified above. We'll use the name in the next workflow action (see below) to see if the person has a record in Rock. Let's pause here for a moment to mention Nameless People. When an SMS message is received, Rock will automatically try to identify the person. If the person isn't in Rock, a Nameless Person record is created. This special type of record gives Rock a way to keep track of the person even though all we have is their phone number. For more details, see the Nameless People section of our Communicating with Rock guide. The next workflow action, pictured below, is where we'll check for a Nameless Person. Your workflow options are limited if you don’t have a person’s record to work with. However, that doesn’t mean your process needs to exclude Nameless People. For instance, you can send the person a link to create a profile as pictured in the example below. Action Filter - This workflow action filter checks the name of the initiator, which we obtained in the prior action. If the person's name is "Nameless Person" then we know the sender of the SMS message doesn't have a record in Rock.Send SMS Message - In this case, we'll send an SMS message to the person. We can do that because the Nameless Person record contains the phone number the person used to send their original message.Message Attribute - The content of the SMS message the person receives is maintained as a workflow attribute in this example. The message encourages the person to visit the website to create a profile, so we'll know who they are going forward. If it's not a Nameless Person record, then the workflow action described above wouldn't run. Instead, we now know the workflow has a complete person record in-hand. You can use that information to perform any other actions or activities you need. At this point in the workflow configuration, we've left the pipeline behind. From here, the same tools and features described earlier in this guide can be used to build the rest of your workflow according to your needs.