Skip to main content
skill CX Codex GP ChatGPT official · OpenAI

twilio-sendgrid-inbound-parse — Claude skill: receive inbound email

A skill that walks your agent through SendGrid Inbound Parse: MX records, parsed vs raw mode, attachments and the usual pitfalls.

Install into Codex · Skills CLI (Vercel) All methods and platforms ↓
npx skills add openai/plugins --skill twilio-sendgrid-inbound-parse -a codex
Open on GitHub

What twilio-sendgrid-inbound-parse does

Inbound Parse turns an incoming email into an HTTP POST to your webhook. SendGrid receives the message at your domain's MX records and forwards the parsed content to your app. The skill covers the whole path: where to point MX, how to add a host and URL in the SendGrid console, and how parsed mode differs from raw.

Parsed mode posts ready form fields — from, to, subject, text, html, envelope, an attachment count and the files themselves as attachment1, attachment2. A Flask handler example reads those fields and loops over the attachments. Raw mode puts the whole message in rawEmail, which you want when full headers or DKIM signatures matter, but then you parse MIME yourself.

You need a SendGrid API key with the SG. prefix, and it will not work with the Twilio Email API on comms.twilio.com. MX records have to change, so Inbound Parse cannot run on a domain that already receives mail — the skill suggests a subdomain like inbound.yourdomain.com to keep Google Workspace or Microsoft 365 untouched. Messages over 30MB are rejected, delivery order is not guaranteed, and there is no way to filter mail before it reaches your endpoint. Treat every field as untrusted input: sanitize HTML, and keep email text away from system prompts when you feed it to an LLM.

What it helps with

  • receive mail on your own domain and turn it into HTTP requests
  • create support tickets from incoming email
  • extract attachments from a message and store them
  • set up MX records without breaking existing mail
  • verify webhook authenticity with a signature instead of IP allowlisting

Example prompts for the agent

  • Set up Inbound Parse for the subdomain inbound.example.com and write a Flask handler
  • Show me how to pull attachments out of an email in parsed mode
  • Why does my webhook get nothing after I changed the MX records?

How to install twilio-sendgrid-inbound-parse

1Skills CLI (Vercel)

npx skills add openai/plugins --skill twilio-sendgrid-inbound-parse -a codex

2Manually: put the files in place

.agents/skills/twilio-sendgrid-inbound-parse/SKILL.md

For all projects use ~/.agents/skills/

Step by step, with commands for each platform: Codex skills: how to install, where they live, how to call them

Questions about twilio-sendgrid-inbound-parse

How do I install twilio-sendgrid-inbound-parse in Claude?

Run npx skills add openai/plugins --skill twilio-sendgrid-inbound-parse -a codex. The skill then lives at .agents/skills/twilio-sendgrid-inbound-parse/SKILL.md.

What does twilio-sendgrid-inbound-parse do?

It documents receiving inbound email through SendGrid Inbound Parse: MX record setup, adding the webhook, parsed vs raw mode, attachment handling and common mistakes.

How is parsed mode different from raw?

In parsed mode SendGrid parses the message for you and posts form fields with text, HTML and attachments. Raw mode sends the entire message in the rawEmail field, and you parse the MIME yourself.

Source text

SKILL.md · MIT
---
name: twilio-sendgrid-inbound-parse
description: >
  Receive inbound email via SendGrid Inbound Parse webhook. Covers MX
  record setup, parsed vs raw mode, handling attachments, and common
  pitfalls. Use when building email-to-app workflows like support ticket
  creation or email processing pipelines. Requires a SendGrid API key
  (SG.-prefix) — not applicable to the Twilio Email API (comms.twilio.com).
---

## Overview

Inbound Parse converts incoming email into HTTP POST requests to your webhook endpoint. SendGrid receives the email at your domain's MX records and forwards the parsed content to your application.

---

## Setup

1. **Configure MX records:** Point your domain (or subdomain) to `mx.sendgrid.net`
2. **Add webhook:** SendGrid Console > Settings > Inbound Parse > Add Host & URL
3. **Choose mode:** Parsed (default) or Raw

**Subdomain recommended:** Use `inbound.yourdomain.com` to avoid disrupting existing email on `yourdomain.com`.

---

## Parsed Mode (Default)

SendGrid extracts fields and POSTs them as form data:

| Field | Description |
|-------|-------------|
| `from` | Sender address (`"Name <[email protected]>"`) |
| `to` | Envelope recipient |
| `subject` | Email subject line |
| `text` | Plain text body |
| `html` | HTML body |
| `envelope` | JSON string with `to` array and `from` |
| `attachments` | Number of attachments (as string) |
| `attachment-info` | JSON metadata for each attachment |
| `attachment1`, `attachment2`... | Actual attachment files |

**Python (Flask)**
```python
from flask import Flask, request
import json

app = Flask(__name__)

@app.route("/inbound", methods=["POST"])
def handle_inbound():
    sender = request.form.get("from")
    subject = request.form.get("subject")
    text_body = request.form.get("text")
    html_body = request.form.get("html")
    envelope = json.loads(request.form.get("envelope", "{}"))
    attachment_count = int(request.form.get("attachments", "0"))
    
    print(f"From: {sender}, Subject: {subject}")
    
    for i in range(1, attachment_count + 1):
        attachment = request.files.get(f"attachment{i}")
        if attachment:
            print(f"Attachment: {attachment.filename}, {attachment.content_type}")
    
    return "", 200
```

> **Security:** All inbound email content (`from`, `subject`, `text`, `html`, attachments) is untrusted external input. Sanitize HTML to prevent XSS before rendering. If feeding content to an LLM, isolate it as user input — never concatenate into system prompts. Verify webhook authenticity using signed webhooks (see Security section below).

---

## Raw Mode

Posts the entire MIME message as `rawEmail` field. Use when you need full headers, DKIM signatures, or non-standard MIME parts. You must parse the MIME message yourself.

---

## Signed Inbound Parse Webhook (Security)

SendGrid supports ECDSA signature verification for Inbound Parse, the same mechanism used for Event Webhooks. Enable it to cryptographically verify that payloads originate from SendGrid.

**Strongly recommended over IP allowlisting** — SendGrid's webhook traffic comes from dynamic cloud infrastructure where IPs change frequently. Signature verification is more reliable and secure.

---

## CANNOT

- **Cannot use Inbound Parse on a domain that already receives email** — MX records must point to `mx.sendgrid.net`. Use a subdomain to avoid disrupting existing email (e.g., Google Workspace, Microsoft 365).
- **Cannot receive email without MX record changes** — DNS access is required. If you can't modify MX records, you can't use Inbound Parse.
- **Cannot receive emails larger than 30MB** — Inbound messages exceeding 30MB are rejected.
- **Cannot filter inbound email before it hits your webhook** — All email sent to the configured domain reaches your endpoint. Implement filtering in your handler.
- **Cannot route to different endpoints per address** — All mail for the configured domain/subdomain goes to a single webhook URL.
- **Cannot guarantee delivery order** — Emails may arrive at your webhook out of order, especially under high volume.
- **No built-in rate limiting** — All email to your configured domain reaches your endpoint. Implement rate limiting, payload size validation, and content sanitization in your handler.

---

## Next Steps

- **Send email:** `twilio-sendgrid-email-send`
- **Delivery tracking:** `twilio-sendgrid-webhooks`
- **Account setup:** `twilio-sendgrid-account-setup`

© Twilio · MIT · openai/plugins

Similar skills

All skills for Backend and APIs →

From the same set337

The whole set →
performance-optimizer A subagent that walks slow Vercel pages through diagnostic trees: LCP, INP, CLS, rendering strategy, bundle size. Use it when Lighthouse scores disappoint. CX Codex GP ChatGPT ★ 7,596repo stars twilio-voice-twiml A skill for building voice call logic with TwiML: Say, Play, Gather, Dial, Record and Conference verbs, plus a full inbound IVR example. CX Codex GP ChatGPT ★ 7,596repo stars twilio-verify-send-otp A skill that walks your agent through the full OTP lifecycle in Twilio Verify: create a service, send a code, check the submitted one. CX Codex GP ChatGPT ★ 7,596repo stars twilio-isv-sms-best-practices A skill for teams embedding SMS into a SaaS platform where customers message their own end users. Covers A2P 10DLC and toll-free onboarding, subaccounts and billing. CX Codex GP ChatGPT ★ 7,596repo stars twilio-sendgrid-email-send A skill that shows the agent how to send mail through the SendGrid v3 Mail Send API: single sends, batch sends with templates, scheduled sends and attachments. Requires an SG-prefixed API key. CX Codex GP ChatGPT ★ 7,596repo stars twilio-security-api-auth Walks you through Twilio's four auth methods and helps you wire up the right one before shipping API calls to production. CX Codex GP ChatGPT ★ 7,596repo stars twilio-rcs-messaging A Claude and Claude skill that walks you from RCS sender onboarding to sending rich cards and carousels through Twilio. CX Codex GP ChatGPT ★ 7,596repo stars twilio-notifications-alerts-advisor Walks you through channel choice, urgency, delivery confirmation and fallback chains for transactional messages. CX Codex GP ChatGPT ★ 7,596repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor