Reader small image

You're reading from  Automate It with Zapier and Generative AI - Second Edition

Product typeBook
Published inAug 2023
PublisherPackt
ISBN-139781803239842
Edition2nd Edition
Tools
Right arrow
Author (1)
Kelly Goss
Kelly Goss
author image
Kelly Goss

Kelly Goss is a process automation specialist and company director for Solvaa, a cloud-based automation consultancy. She has worked across multiple industry verticals for providing Zapier consultancy, digital process improvement, process mapping and process automation solutions. Kelly is a Zapier Certified Expert and a speaker at multiple events related to automation.
Read more about Kelly Goss

Right arrow

Text Formatting Functions in Zapier – Part 2

In Chapter 16, Text Formatting Functions in Zapier – Part 1, we introduced several of the Formatter by Zapier built-in app text transform options. In this chapter, we will continue to discuss the functionality that Zapier has available to format text.

First, we will explore how to create a superhero name, split text into segments, and truncate text. Then, we will cover how to remove HTML to leave plain text, how to assign a default value, and how to transform text with a spreadsheet-style formula. After that, we will discuss the possibilities of how to extract email addresses, numbers, URLs, and phone numbers from blocks of text. Lastly, we will briefly discuss the more advanced functions of how to extract patterns, convert HTML into Markdown and vice versa, convert text into ASCII, and finally, encode and decode URLs.

We will cover the following key topics in this chapter:

  • Converting a name into the name of a...

Technical requirements

To make the most of the content in this chapter, you will need access to a Zapier account. The Zapier Starter plan will be required for you to create multi-step workflows using the Formatter by Zapier built-in app.

Converting a name into the name of a superhero

So far in this book, we’ve covered plenty of useful, although quite formal, formatting functions that can be used for various business cases. Zapier is not all just about being formal. Sometimes, you might want to have a bit of fun and be playful with text formatting. Zapier can convert any name or a short string of text into a randomly chosen name of a superhero by using the Formatter by Zapier Text action event with the Superhero Name transform function. For example, if the name that you wanted to convert was Kelly Goss, the transformed text might be Space Fury. This text transform function is great to use when you want to do something fun and outside of the norm with your data.

Here are a few examples of when you can use this transform option:

  • You might want new subscribers to be randomly assigned superhero names that you will address them by in your email communications. So, when John Smith signs up for your email...

Splitting characters or words into segments

Being able to manipulate text with a splitting function is possibly one of the most versatile functions of all the Formatter by Zapier text transform options. There will be many occasions where data is presented as a string of text and you will want to extract one or more words from that string to then use in other parts of your workflows. A common example of this is the need to use either the first or last name when only the full name is presented. You can use the Formatter by Zapier Text action event with the Split Text transform function to split the word string to return the two values.

You can use words or characters to split text, and the Split Text transform function allows you to split words or strings of words that are separated by special characters using special character syntax, as follows:

  • Space characters: The [:space:] syntax is used to match space (\s) characters
  • Tab characters: The [:tab:] syntax is used to...

Truncating text to a specified character length

There may be times when you want to reduce the character length of a block of text so that you can use it as a summary, or you might have restrictions on the number of characters. A typical example of this is when posting content on social media where you have a fixed character length, such as reposting a Facebook post (which could have over 60,000 characters) to Twitter, which has a maximum character length of 280. You can use the Formatter by Zapier Text action event with the Truncate transform function to reduce the number of characters in a block of text and optionally replace the last three characters with .

Here are a few examples of when you can use this transform option:

  • When you publish a new blog post on WordPress, you can truncate the blog post’s content to produce a teaser summary suitable to use on social media
  • When you post a new Facebook post, you can truncate it to a shorter character length...

Removing HTML tags to leave plain text

As HyperText Markup Language (HTML) is used to customize the way data is displayed on the web, such as on websites, digital documents, and emails, there will be occasions when you will want to view just the plain text without any coding. You can use the Formatter by Zapier Text action event with the Remove HTML Tags transform function to achieve this by stripping out all the HTML coding to leave just the plain text behind.

Here are a few examples of when you can use this transform option:

  • When you want to extract the body of an email, but the data is only presented in HTML
  • When you publish a new blog post on WordPress, and you want to remove any HTML before posting a teaser summary on social media

Let’s review how to set up an action step with the Remove HTML Tags transform option.

Setting up the Text action event with the Remove HTML Tags transform option

You can use the Text action event once you have set up...

Assigning a default value

You might encounter situations where data has not been entered for whatever reason, therefore leaving a field blank. In some cases, this lack of data may cause problems later in your workflow. To prevent such problems, you might want to conditionally assign a value that acts as the default where data might be missing from a specific field. You can use the Formatter by Zapier Text action event with the Default Value transform function to achieve this by assigning a default value when a field contains no data.

Here are a few examples of when you can use this transform option:

  • When new deals are created in Zoho CRM, but an owner has not been assigned, you may want to automatically assign these deals to a specific user who can then reassign the deal to a member of the team
  • When new cards are created in Trello but members have not been assigned, you may want to automatically assign these cards to a manager who then assigns the card to someone in...

Transforming text with a spreadsheet-style formula

In Chapter 15, Formatting Numbers, we explored how to use the Formatter by Zapier Numbers action event and the Spreadsheet-Style Formula transform option to do complex calculations with numbers. You can use the Formatter by Zapier Text action event and the Spreadsheet-Style Formula transform option to do the same with text.

An example of this situation would be when you want to use complex IF, AND, or OR conditions – for example, if two text values match then output one result, otherwise output another. In this case, you could use IF("value1"="value2", "same", "different").

Important note

When using text strings with this transform option, you must use quotation marks around the string, as shown in the preceding example.

Let’s review how to set up the Spreadsheet-Style Formula transform option.

Setting up the Text action event with the Spreadsheet-Style Formula transform...

Extracting data from blocks of text

Another brilliant feature of the Formatter by Zapier’s Text action is its ability to extract data from blocks of text. This is especially useful if you have large strings of text and you want to return the first expressed value of an email address, number, phone number, or URL.

For example, your web form may not integrate with Zapier, but you receive a confirmation email with the submission details. The form asks the person submitting to add three email addresses, and you only want to extract the first email address entered. Alternatively, you may want to retrieve a phone number, URL, or number from this web form submission. You can use the Formatter by Zapier Text action event with the following transform functions to achieve this:

  • Extract Email Address
  • Extract Number
  • Extract URL
  • Extract Phone Number

To illustrate how to use each of these transform functions, we will use the trigger data highlighted in the following...

Advanced text formatting features

As you have learned so far, the Formatter by Zapier built-in app allows you to manipulate text in many versatile ways without having any knowledge of coding or any technical background whatsoever. There are, however, a few transform functions that allow you to manipulate text using programming languages. As these are advanced topics, we will only provide a brief overview of their functionality, without going into too much detail.

The following transform options can be used to manipulate text with programming languages:

  • Extract Pattern: You can use this transform option when you need to extract partial data from a field with more specificity than the other Extract transform options we have covered. This allows you to use Python regular expressions (regexes). You can find out more about Python regexes here: https://developers.google.com/edu/python/regular-expressions.
  • Convert HTML to Markdown: You can use this transform option when you...

Summary

In this chapter, we continued to focus on the versatile Formatter by Zapier built-in app and the extensive functionality available to format text. First, we explored how to create a superhero name, split text into segments, truncate text, remove HTML, and use a default value. Then, we covered how to extract data from text – specifically, how to extract URLs, phone numbers, numbers, and email addresses. Lastly, we briefly discussed the more advanced functions for extracting patterns, converting Markdown into HTML and vice versa, converting text into ASCII, and encoding or decoding URLs.

In the next chapter, you will learn how to use the Utilities functions within the Formatter built-in app. We will cover line item creation and customization, converting text into line items and vice versa, using lookup tables and picklists, and importing CSV files.

Questions

  1. Which transform option of the Formatter by Zapier built-in app could you use if you wanted to separate the full name of a person into first name and last name presented as two values?
  2. When might you want to use the Truncate transform option of the Text action event of Formatter by Zapier?
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Automate It with Zapier and Generative AI - Second Edition
Published in: Aug 2023Publisher: PacktISBN-13: 9781803239842
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Kelly Goss

Kelly Goss is a process automation specialist and company director for Solvaa, a cloud-based automation consultancy. She has worked across multiple industry verticals for providing Zapier consultancy, digital process improvement, process mapping and process automation solutions. Kelly is a Zapier Certified Expert and a speaker at multiple events related to automation.
Read more about Kelly Goss