Email a meeting summary
This guide builds a complete serverless function that emails a formatted summary whenever a session produces one. It’s a great showcase of the three things that make functions powerful:
- a named event handler that subscribes automatically,
- the pre-authenticated
ctx.cortexclient, - an npm dependency (
node-mailjet) and environment variables for credentials.
What it does
When a session summary is generated, Cortex
emits a session.annotation.created event. Our function handles it, looks up the session to
get its title, and sends the summary by email through Mailjet.
1. Add the dependency
In the function’s settings, declare the npm package:
Once declared, its types are available in the editor and you can import it.
2. Add environment variables
Add your Mailjet API credentials as environment variables (encrypted at rest, injected into the runtime):
Read them in your code with process.env.
3. Write the function
A few things worth noting:
- The handler name is the subscription. Exporting
onSessionAnnotationCreatedis all it takes to receivesession.annotation.createdevents — there’s no separate event list. event.payload.datais the bare event payload. For a session annotation that includes thesessionIdand the plugin-definedcontent(here,shareableHtml/sharablePlainTextproduced by the summary).ctx.cortexneeds no setup —ctx.cortex.sessions.get(...)just works, and the returned object exposes its fields directly (e.g.session.title).
4. Publish and deploy
On publish, Cortex transpiles your TypeScript, snapshots it as an immutable version, and
detects that it subscribes to session.annotation.created. On deploy, it goes live on ODIN
Fleet and starts receiving events.
Test it
Generate a summary on a session and the function fires:
Check the function logs for the Mailjet status, and your inbox for the email.
Event delivery is durable and may retry, so a handler can run more than once for the same
event. If duplicate emails would be a problem, dedupe on event.id.