Skip to main content

Extract Strings

The Extract Strings action extracts multiple named values from text in a single step, storing all results together in one object. Each definition in the action specifies what to extract, how to extract it, and what to do if nothing is found.

When to Use This Action

Use this action when:

  • You need to pull several distinct values out of a piece of text at once
  • You want to build structured data from an email body or other unstructured text
  • Some of your extractions are best done with text expressions and others with regex patterns
  • You want independent control over what happens when each individual extraction returns empty

Don't use this action for:

How It Works

When this action runs, it processes each definition in order:

  1. For each definition, the action evaluates the extraction using either the text expression or the regular expression you configured.
  2. The extracted value is stored on a result object under the property name you specified in the Variable field.
  3. If the extraction returns an empty value, the action applies the If Empty behavior you configured for that definition.
  4. Once all definitions are processed, the result object is stored and accessible to subsequent actions.

Configuration

Definitions

Each definition extracts one value. Add as many definitions as you need. Definitions with no Variable name are skipped.

Extraction Type

Choose how the value is extracted:

OptionDescription
Text ExpressionEvaluates a handlebars expression against the workflow context
Regular ExpressionMatches a regex pattern against an input string you provide

Text Expression Mode

When Extraction Type is set to Text Expression, configure:

Text

The handlebars expression to evaluate. This can reference any available workflow variable and supports all text helpers.

Examples:

  • {{after_string email.body "First Name:" flags="tn"}} - Extract the text following "First Name:" in the email body
  • {{email.from.address}} - Capture the sender's email address directly
  • {{uppercase email.subject}} - Transform and store the email subject

Regular Expression Mode

When Extraction Type is set to Regular Expression, configure:

Pattern

The regular expression pattern to match. Must be a valid PCRE2 pattern including delimiters (e.g., /pattern/flags). The pattern must have exactly 0 or 1 capture group:

  • 0 capture groups: The full match is returned
  • 1 capture group: The value inside the capture group is returned
  • 2 or more capture groups: The action stops with an error

Examples:

  • /T20[0-9]{6}\.[0-9]{4}/ - Match an Autotask ticket number (full match returned)
  • /Ticket:\s*(T20[0-9]{6}\.[0-9]{4})/ - Match and capture just the ticket number (capture group returned)
  • /\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/ - Match a US phone number

Input

The text to search using the pattern. Supports {{variable}} syntax.

Examples:

  • {{email.body}} - Search the email body
  • {{email.subject}} - Search the email subject
  • {{custom.previousResult}} - Search a value from a previous action

Variable

The property name used to store this extracted value on the result object. For example, entering FirstName stores the result at {{custom.<actionVariable>.FirstName}}.

Variable names with no value are skipped entirely.

If Empty

Controls what happens when an extraction returns an empty string (no match or blank result):

OptionBehavior
Continue processingStore an empty string for this variable and continue with remaining definitions
Stop current ruleStop processing this rule's remaining actions, but continue other matched rules
Stop all rulesStop processing all rules entirely
Generate an exception and stop processingHalt execution, mark the run as failed, and send a failure notification
Bounce email to senderReturn the message to the sender (email workflows only)

Returned Variables

The action stores a single object with one property per definition. Each property is named after the Variable value you configured.

VariableTypeDescription
<Variable>stringThe extracted value for that definition, or an empty string if nothing was found

Access syntax: {{custom.<actionVariable>.<Variable>}}

For example, if your action is stored as Extracted and you defined variables FirstName and Phone, access them as {{custom.Extracted.FirstName}} and {{custom.Extracted.Phone}}.

Example: Extract Contact Info from an Email Body

Given an email body like:

First Name: Jane
Last Name: Smith
Phone: 555-867-5309

Configure three definitions:

VariableExtraction TypeExpression / Pattern
FirstNameText Expression{{after_string email.body "First Name:" flags="tn"}}
LastNameText Expression{{after_string email.body "Last Name:" flags="tn"}}
PhoneRegular ExpressionPattern: /\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/, Input: {{email.body}}

After the action runs (stored as ContactInfo), the values are available as:

  • {{custom.ContactInfo.FirstName}}Jane
  • {{custom.ContactInfo.LastName}}Smith
  • {{custom.ContactInfo.Phone}}555-867-5309

Notes

  • Definitions are processed in order. If a definition triggers a stop action (anything other than "Continue processing"), remaining definitions are not evaluated.
  • If the regex pattern is missing for a Regular Expression definition, the action stops with an error.
  • An invalid regex pattern (one that fails to compile) stops the action with an error.
  • If the input text or text expression resolves to a non-string value (such as an object or array), it is serialized to JSON before extraction.