# How to quickly act on incoming emails with microfn

2 min read
Table of Contents

Microfn comes with a built-in email connector, so you can forward any message into a function and respond automatically.

With a few clicks you can triage, forward, or archive email directly from a microfn workflow. Here’s how to wire it up:

1. Create a new function

In microfn, tap the “+” button to create a new function and give it a name that matches the job you want it to do.

export async function main(input) {
return {
message: "Hello from Microfn!",
timestamp: new Date().toISOString(),
receivedInput: input
};
}

2. Enable the Email trigger

Once the function is saved, open the Triggers tab and enable the Email Trigger.

The email trigger generates a unique address for your function. Every message sent to that inbox calls your function with the email’s contents.

Need more detail? Check out the Microfn email trigger docs.

Email trigger configuration in microfn

Microfn also adds a new email() export to your workspace so each incoming message is dispatched automatically. Here’s a complete example you can drop into a new function:

export async function main(input) {
return {
message: "Hello from Microfn!",
timestamp: new Date().toISOString(),
receivedInput: input
};
}
export async function email(emailPayload) {
// handle email trigger
console.log("email received");
console.log(emailPayload);
return {
status: "processed",
receivedSubject: emailPayload.email.subject
};
}

2.1 Check executions for incoming email data

Send a message to the generated address and watch it appear in the Executions panel.

Hit Replay to resend the same payload while you iterate, so you can verify your function behaves the way you expect.

3. Forward, categorize, save

From here, the workflow is yours to design—forward high-priority mail to Discord, store attachments in cloud storage, or build filters that only alert you when it matters.

Email trigger input shape

Here’s an example payload delivered to email() when a message arrives:

{
"email": {
"body": "Hi team, we just received a new inbound lead from the website. Can you follow up today?",
"from": "alerts@example.com",
"rawSize": 4821,
"subject": "New lead: Acme Corp",
"timestamp": "2025-09-20T15:46:14.515Z",
"to": "fn-cdmixwn7kw7p@mail.microfn.dev"
}
}

Built with microfn, your toolbox for composable functions

Microfn is a tiny cloud runner for composable JavaScript functions. Write your function, hit save, and microfn deploys it instantly.

Ready to automate your inbox? Get started for free—no credit card required.

https://microfn.dev - deploy JavaScript functions into the cloud in seconds


More Posts