AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

cloudflare-deploy

Deploy applications and infrastructure to Cloudflare using Workers, Pages, and related platform services. Use when the user asks to deploy, host, publish, or set up a project on Cloudflare.

Original source
openai
License
Apache-2.0
Pinned revision
49f948faa9258a0c61caceaf225e179651397431

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

This skill also requires local files or dependencies. Remote reading alone may not be enough.

Ask your assistant

Use Agentic Memory skills to read openai--cloudflare-deploy at revision 49f948faa9258a0c61caceaf225e179651397431, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 309

references/email-workers/patterns.md

Email Workers Patterns

Parse Email

import PostalMime from 'postal-mime';

export default {
  async email(message, env, ctx) {
    const buffer = await new Response(message.raw).arrayBuffer();
    const email = await PostalMime.parse(buffer);
    console.log(email.from, email.subject, email.text, email.attachments.length);
    await message.forward('[email protected]');
  }
};

Filtering

// Allowlist from KV
const allowList = await env.ALLOWED_SENDERS.get('list', 'json') || [];
if (!allowList.includes(message.from)) {
  message.setReject('Not allowed');
  return;
}

// Size check (avoid parsing large emails)
if (message.rawSize > 5_000_000) {
  await message.forward('[email protected]'); // Forward without parsing
  return;
}

Auto-Reply with Threading

import { EmailMessage } from 'cloudflare:email';
import { createMimeMessage } from 'mimetext';

const msg = createMimeMessage();
msg.setSender({ addr: '[email protected]' });
msg.setRecipient(message.from);
msg.setSubject(`Re: ${message.headers.get('Subject')}`);
msg.setHeader('In-Reply-To', message.headers.get('Message-ID') || '');
msg.addMessage({ contentType: 'text/plain', data: 'Thank you. We will respond.' });

await message.reply(new EmailMessage('[email protected]', message.from, msg.asRaw()));

Rate-Limited Auto-Reply

const rateKey = `rate:${message.from}`;
if (!await env.RATE_LIMIT.get(rateKey)) {
  // Send reply...
  ctx.waitUntil(env.RATE_LIMIT.put(rateKey, '1', { expirationTtl: 3600 }));
}

Subject-Based Routing

const subject = (message.headers.get('Subject') || '').toLowerCase();
if (subject.includes('billing')) await message.forward('[email protected]');
else if (subject.includes('support')) await message.forward('[email protected]');
else await message.forward('[email protected]');

Multi-Tenant Routing

// [email protected] → tenant123
const tenantId = message.to.split('@')[0].match(/\+(.+)$/)?.[1] || 'default';
const config = await env.TENANT_CONFIG.get(tenantId, 'json');
config?.forwardTo ? await message.forward(config.forwardTo) : message.setReject('Unknown');

Archive & Extract Attachments

// Archive to KV
ctx.waitUntil(env.ARCHIVE.put(`email:${Date.now()}`, JSON.stringify({
  from: message.from, subject: email.subject
})));

// Attachments to R2
for (const att of email.attachments) {
  ctx.waitUntil(env.R2.put(`${Date.now()}-${att.filename}`, att.content));
}

Webhook Integration

ctx.waitUntil(
  fetch(env.WEBHOOK_URL, {
    method: 'POST',
    body: JSON.stringify({ from: message.from, subject: message.headers.get('Subject') })
  }).catch(err => console.error(err))
);