Skip to main content
Resend Docs

Search documentation

Type to search this documentation.

On this pageOverview

Chat SDK Proactive Outreach

By default, the Chat SDK adapter responds to inbound emails. With openDM, you can go the other way and start a new email thread with any address, without waiting for them to email you first.

Call openDM on the adapter to create a new thread, then post a message to it.

TypeScript
const threadId = await chat.adapters.resend.openDM('user@example.com');
const thread = await chat.thread('resend', threadId);
await thread.post('Hello from the bot!');

You can also send card emails in proactive threads. The same card structure from Card Emails works here.

A common pattern is exposing an HTTP endpoint that triggers outbound emails. This lets external systems (cron jobs, webhooks from other services, admin dashboards) send emails through your bot.

TypeScript
async function handleNotify(req, res) {
  const { to, message } = JSON.parse(await readBody(req));

  const threadId = await chat.adapters.resend.openDM(to);
  const thread = await chat.thread('resend', threadId);
  await thread.post(message);

  res.writeHead(200, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify({ ok: true, threadId }));
}

Then call it:

Bash
curl -X POST http://localhost:3000/notify \
  -H "Content-Type: application/json" \
  -d '{"to": "user@example.com", "message": "Your order has shipped!"}'
  • Welcome emails when a user signs up
  • Order confirmations and shipping updates
  • Alert notifications (monitoring, billing, security)
  • Scheduled digests or reminders

If the recipient replies, the response arrives through the normal onNewMention or onSubscribedMessage handlers, and the threading is handled automatically.

Notifications Example

Proactive outbound emails via openDM and an HTTP POST endpoint

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu