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:

nametyperequireddescription
connectionstringyesThe 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.

nametyperequireddescription
actionstringyesMust be SEND_EMAIL.
sendFromstringyesThe sender email address.
sendTostringyesThe recipient email address. Supports mapping placeholders.
subjectstringyesThe email subject line. Supports mapping placeholders.
messagestringyesThe email body content. Supports mapping placeholders.
attachmentsarraynoOptional file attachments. See Attachments below.

SEND_DYNAMIC_EMAIL

Sends a pre-built SendGrid dynamic template, filling in template variables with per-session values.

nametyperequireddescription
actionstringyesMust be SEND_DYNAMIC_EMAIL.
templatestringyesThe SendGrid template ID to use.
templateVariablesarrayyesKey-value pairs to inject into the template. Each entry is an object with key and value string properties.
sendFromstringyesThe sender email address.
sendTostringyesThe recipient email address. Supports mapping placeholders.
attachmentsarraynoOptional file attachments. See Attachments below.

Attachments

Each entry in the attachments array defines a file to include in the email.

nametyperequireddescription
sourcestring or objectyesThe 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.
namestringyesThe 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"
    }
  ]
}