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.
You’ll need:
- Functions activated for your project, on runtime v6 (the current version — see Runtime versions).
- The session summary plugin enabled for the project, so a summary is produced when a session ends.
- A Mailjet account with a verified sender address.
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. Mark the credentials with
isSecret: true so they are encrypted at rest and masked in the dashboard. Pick any names you
like — except the reserved CORTEX_ prefix:
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 event’s data. For a session annotation that is theannotationId, thesessionId, the annotationtype(summaryhere) and the plugin-definedcontent— for a summary, ready-madeshareableHtmlandshareablePlainTextversions.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. (The function also keeps its HTTP handler, reachable at
the invokeUrl returned by deploy().)
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. If nothing arrives, check that the project is on runtime v6 and that the function is deployed — and remember that a summary needs a session with some transcript to summarize.
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.