Configure an automation bot to send an email to one or more recipients based on an event by using the Send an email task. For example, if an employee sends a request for a new chair (the event), you can configure the bot to send an email to their manager requesting approval before fulfilling the request.
To send an email from a bot, add and configure the Send an email task as described in the following sections:
- Add and configure the Send an email task
- Add email recipients
See also Tasks: The Essentials.
Email types
There are currently two types of emails that you can configure:
Email type | Description |
Embedded app view (dynamic) | Embedded app view emails enable you to embed supported app views within an email and allow Gmail recipients to interact directly with your app from within the email, without leaving their inbox. To configure an embedded app view email, see Send embedded app view emails from a bot. |
Custom template | Custom template emails allow you to configure emails with text, HTML, or variables from app data. Configuration details are provided below. |
Add and configure the Send an email task
Add and configure the Send an email task by performing the following steps:
Add the Send an email task to a bot, as described in Add a task to a bot.
Configure the Send an email task by using the settings described in the tables below.
When you are done, save the app by selecting one of the following:
- Save - Save the app
- Save & verify data - Save the app and verify the data defined.
To preview the email, click Preview email.
The first record in the table is displayed, by default. You need to save the app to preview the latest changes.
After you save the app, you can reuse the task in other bots.
Configure the Send an email task by using the settings described in the following tables.
Setting | Description |
Linking | Enable or disable reuse of this component by expanding the Linking panel and toggling the Linking setting. See Reuse automation components.
|
Task name | Name of the task. It must be unique within your app. |
Email Type | Email type. Click Custom template. Note: To configure an Embedded app view email, see Send embedded app view emails from an automation. |
Table name | Table referenced by the task. Select an existing table in the list. You can also select a table slice but note that if the selected slice contains a row filter, you may see failures in the task. This is because the user that triggered the automation may not have access to the row because of the slice row filter. Click View definition to view the structure of the selected table. See Tables: The Essentials for more information about adding tables. |
To | List of email recipients. Enter an email address or an expression using the Expression Assistant. Click Add to add additional email recipients. See Add email recipients for more information. |
Email Subject | Subject of the email. Specify text, variables, and expressions. For example:
By default, a meaningful email subject is suggested. |
Email Body | Body of the email. To define the email body, do one of the following:
Note: The Email Body Template setting (if specified) takes precedence over this setting. By default, the Email Body includes data values from the added or updated row, excluding Hidden or Show type columns. |
Advanced settings
Expand and customize the Advanced settings, as described below.
Setting | Description |
CC | List of email recipients to carbon copy (CC). Click Add to add an email address or an expression using the Expression Assistant. Repeat to add additional email recipients. See Add email recipients for more information. |
BCC | List of email recipients to blind carbon copy (BCC). Click Add to add an email address or an expression using the Expression Assistant. Repeat to add additional email recipients. See Add email recipients for more information. |
Reply To | Email address that will receive replies to the email. Enter an email address or an expression using the Expression Assistant. See Add email recipients for more information. Defaults to |
Customize "From" name | Customize the email address displayed in the From field of the email. By default, the app creator is used (for example, ). |
PreHeader | Email preheader summary text that follows the subject line when viewed in an inbox. Specify text, variables, and expressions. For example:
To suppress the PreHeader, enter a single space character. Defaults to: <<_UPDATEMODE>> to application '<<_APPNAME>>' table '<<_TABLENAME>>' by '<<_USEREMAIL>>' at <<_NOW>> For example: Note: <<USEREMAIL>> is omitted if your app does not require authentication. See also Built-in variables. |
Email Body Template | Template to use for more precise control of the email body. See Use templates in a bot and the Email Body description (above). |
Attachment settings
Expand and customize the Attachment settings, as described below.
Setting | Description |
Attachment Content Type | Content type of the email attachment file. Valid content type values include:
Defaults to PDF which is the most often used content type for email attachments. |
Attachment Template | Template to use for more precise control of the email attachment. See Use templates in a bot and Archive email attachments for more information. |
Attachment Name | Name of attachment. Specify text, variables, and expressions. For example:
See Archive email attachments and How the archive attachment filename if formed for more information. |
Attachment Archive | Attachment file archive configuration. Valid values include:
See Archive email attachments for more information. |
Attachment File Store | File system where attachments are stored. When set to Default (the default setting), the attachment file is archived to the authentication provider file system. For example, if your authentication provider is Google, the attachment file is archived to Google Drive. If your authentication provider is Dropbox, the attachment file is archived to Dropbox. Notes:
See Archive email attachments for more information. |
Attachment Folder Path | Folder path where attachments are saved relative to the default app folder. Specify text and expressions. For example:
In the second example, email attachment files would be stored in a separate folder, based on the month. For example: MyAttachments/PurchaseOrdersByMonth_2019_02 Defaults to Attachments. See Archive email attachments and How the archive attachment folder name if formed for more information. |
Disable Timestamp? | Toggle to indicate whether to append a timestamp to attachment filenames. Appending the timestamp will ensure the filenames are unique. The timestamp contains the date and time at which the attachment file was created, formatted as follows: yyyyMMdd_HHmmss_fff indicating year, month, day, hours, minutes, seconds, and milliseconds. For example: MyAttachmentName20190207_133355_804.pdf If you disable the timestamp, you must ensure that every attachment filename is unique. Otherwise, the attachment files may be overwritten. For example, if you are archiving your attachment files to Google Drive and you disable the timestamp, only the most recent attachment file will be available. Older attachment files with the same name will have been overwritten. Disabled (timestamp is appended) by default. See Archive email attachments for more information. |
Attachment Page Orientation | Page orientation of the attachment. Valid values include: Portrait and Landscape Note: This setting is available only if you set Attachment Content Type to PDF. |
Attachment Page Size | Page size. Select a standard size or select Custom and enter the Attachment Page Width and Attachment Page Height in millimeters. Note: This setting is available only if you set Attachment Content Type to PDF. |
Use Custom Margins | Toggle to indicate whether you want to specify custom margins for the attachment. If disabled, the task uses default margins. If enabled, customize the margins using the additional settings displayed, as described below. Note: This setting is available only if you set Attachment Content Type to PDF. Disabled by default. |
Other Attachments | Other attachment files such as drawings, images, signatures, thumbnails, or files. Click Add to add other attachments to the email. Specify text or expressions. Repeat to add additional attachment files. See Add other attachments to an email for more information. |
If you enable Use Custom Margins, customize the attachment page margins using the additional settings displayed, as described below.
Setting | Description | Default (if applicable) |
Attachment Page Margin Top | Top margin for the attachment in points. | 0 |
Attachment Page Margin Right | Right margin for the attachment in points. | 0 |
Attachment Page Margin Bottom | Bottom margin for the attachment in points. | 0 |
Attachment Page Margin Left | Left margin for the attachment in points. | 0 |
Add email recipients
The following provides guidelines for adding the email recipients in To, CC, and BCC when configuring the email (described above):
Enter a specific email address, such as .
If an email address contains special characters such as hyphen or plus, you must enclose the email address in quotes. For example: ""Use a field in a record that is being modified.
For example, when a new order is received, you can send an email to the customer who created the order. In this scenario, enter the name of the field that contains the customer's email address. For example, if the CustomerEmail field in the order record contains the customer's email address, enter the following expression: [CustomerEmail]Use a field in a record that is referenced by the record being modified.
For example, when a new order is received, you can send an email to the customer who created the order. Each order record might contain a reference to a customer record that contains the customer's email address. In this scenario, enter the name of the order record field that references the customer record followed by the name of the customer record field that contains the customer's email address. For example, if the order record field that references the customer record is CustRef and the name of the customer record field containing the customer's email address is CustEmail, specify the customer's email address by entering the expression: [CustRef].[CustEmail]Use an entire column in another table.
For example, each time a new order is added, you can send an email to all of the people defined in another table. In this scenario, enter the name of the table followed by the field that contains the email address. For example, if you create a table called PeopleToInform that contains two columns, Name and EmailAddress, each time a new order is added, you can send email to all of the people in the PeopleToInform table by entering the expression: PeopleToInform[EmailAddress]Use selected rows in another table.
For example, each time a new order is added, you can send an email to all of the people in the sales department. In this scenario, enter the name of the table followed by the field that contains the email address, and set the department field to Sales. For example, if you create a table called PeopleToInform that contains three columns, Name, EmailAddress, and Department, each time a new order is added, you can send an email to all of the people in the PeopleToInform table who are in the Sales department by entering the expression: SELECT(PeopleToInform[EmailAddress], ([Department] = "Sales"), TRUE)
Note: While the app is in test mode (that is, you have not run a deployment check and deployed the app), any messages sent will be sent to the app creator only. To confirm the list of email recipients that will be included in To, CC, and BCC, check the Audit History, as described in How do I determine whether an email was delivered?
Examples of sending an email from a bot
The following provide examples of sending an email from a bot.
Send email when a row is updated to have a specific column value
You can create a workflow rule that sends an email when a row is updated to have a specific column value. For example, you might send an email when the Status column in the ServiceRequests row is updated to contain the value Active.
AND( ("Active" = [_THISROW_AFTER].[Status]), ([_THISROW_AFTER].[Status] <> [_THISROW_BEFORE].[Status]) )In this expression, note the use of [_THISROW_BEFORE] and [_THISROW_AFTER]. These are system-provided references that refer to the state of the row before and after the change was made, respectively. This is really useful in order to check if the value of a field changed from one value to another.
Because [_THISROW_BEFORE] and [_THISROW_AFTER] are references, you use a dereference expression to access the value of a specific column in the referenced row.
Send an email only after adding a parent record and all of its child records
When you add a parent record along with one or more child records, AppSheet first adds the parent record, then each of the child records. This can make it difficult to trigger an automation event only after all of the child records have been added.
You can can use the following technique to ensure that all parent and child records are added before the event is triggered. This technique uses the Form Saved event to trigger a data-change action which triggers the event only after the child records have been added.
Do this as follows:
The child table must contain a Ref field to the parent table. Enable the Is a part of?property of the Ref field. This makes it possible to add child records when the parent record is added.
Add a Text field to the parent table. Call the field Status and set its Initial value property to "" (blank). The Status column controls whether the data change event triggers.
Create a data-change action for the parent table which sets the Status column's value to "Run".
Create a second data-change action for the parent table which sets the Status column's value to "" (blank).
Create a composite action for the parent table that invokes the two data-change actions above. This composite action invokes the first data-change action to set the Status column's value to "Run", and the second data-change action to set the Status column's value to blank. These two data changes will be sent to the server as separate updates. The first update triggers the automation event, while the second update prevents further updates from triggering the automation event.
Go to the UX > Views tab. Click Show system views. Select the form for the parent table. Expand Behavior. Find Event Actions and set its Form Saved property to the compositive action created in the previous step.
Set your data change event to Updates only. Set its Condition property to: [Status] = "Run"
Was this helpful?
How can we improve it?