SendGrid Step
Send emails via SendGrid as part of your workflow. Use this step to deliver transactional messages, attach documents, or render dynamic templates with per-session variables.
The SendGrid step sends an email using a named SendGrid connection. You can choose between two actions: sending a plain email with an optional message body and attachments, or sending a dynamic template email where SendGrid renders the content using variables you provide.
Configuration
All configurations share one common field:
| name | type | required | description |
|---|---|---|---|
connection | string | yes | The name of the SendGrid connection to use, as configured in Integrations. |
The remaining fields depend on the action you choose.
Actions
SEND_EMAIL
Sends an email with a subject, message body, and optional attachments.
| name | type | required | description |
|---|---|---|---|
action | string | yes | Must be SEND_EMAIL. |
sendFrom | string | yes | The sender email address. |
sendTo | string | yes | The recipient email address. Supports mapping placeholders. |
subject | string | yes | The email subject line. Supports mapping placeholders. |
message | string | yes | The email body content. Supports mapping placeholders. |
attachments | array | no | Optional file attachments. See Attachments below. |
SEND_DYNAMIC_EMAIL
Sends a pre-built SendGrid dynamic template, filling in template variables with per-session values.
| name | type | required | description |
|---|---|---|---|
action | string | yes | Must be SEND_DYNAMIC_EMAIL. |
template | string | yes | The SendGrid template ID to use. |
templateVariables | array | yes | Key-value pairs to inject into the template. Each entry is an object with key and value string properties. |
sendFrom | string | yes | The sender email address. |
sendTo | string | yes | The recipient email address. Supports mapping placeholders. |
attachments | array | no | Optional file attachments. See Attachments below. |
Attachments
Each entry in the attachments array defines a file to include in the email.
| name | type | required | description |
|---|---|---|---|
source | string or object | yes | The file to attach. Accepts an object with id and downloadUrl, a generated file descriptor with name and optional metadata, or a plain string URL. See the Amazon S3 step for full source format details. |
name | string | yes | The file name to use as the attachment name in the email. |
Examples
Here's the configuration for a SEND_EMAIL action. The recipient and subject can use mapping placeholders from earlier steps; in this example they use static values alongside a PDF attachment.
{
"connection": "sendgrid-prod",
"action": "SEND_EMAIL",
"sendFrom": "[email protected]",
"sendTo": "[email protected]",
"subject": "Your receipt",
"message": "Thank you for your purchase.",
"attachments": [
{
"source": {
"id": "file-901",
"downloadUrl": "https://files.example.com/download/file-901"
},
"name": "receipt.pdf"
}
]
}The next example uses SEND_DYNAMIC_EMAIL. Template variables are passed as an array of key-value pairs that SendGrid uses to personalize the rendered template.
{
"connection": "sendgrid-prod",
"action": "SEND_DYNAMIC_EMAIL",
"template": "d-1234567890abcdef1234567890abcdef",
"templateVariables": [
{ "key": "firstName", "value": "Marc-Andre" },
{ "key": "plan", "value": "Pro" }
],
"sendFrom": "[email protected]",
"sendTo": "[email protected]",
"attachments": [
{
"source": {
"name": "details.txt",
"metadata": { "contentType": "text/plain", "size": 64 }
},
"name": "details.txt"
}
]
}Updated 20 days ago
