Skip to content

bots: return local context in event listeners#4678

Draft
miguel-nascimento wants to merge 1 commit intomainfrom
miguel/bot-return-context
Draft

bots: return local context in event listeners#4678
miguel-nascimento wants to merge 1 commit intomainfrom
miguel/bot-return-context

Conversation

@miguel-nascimento
Copy link
Contributor

@miguel-nascimento miguel-nascimento commented Dec 10, 2025

this pr

This PR changes bot event listeners from returning a handler to returning a context.
The bot context is specialized towards the event that the bot received.

This allow us to do stuff like

bot.onMessage(ctx => ctx.react("🔥"))

Currently, that would be

bot.onMessage((handler, event) => handler.sendReaction(event.eventId, "🔥"))

If you want to act with a message outside our context, you can use the bot global context.

bot.onMessage((handler, event) => {
   bot.sendReaction(totallyDifferentEventId, "🔥")
})

This API allow us to better model actions that the bot can do without a app registry event being send.

questions

  1. Do we want to create a new client on every context? i.e make a global client and make a new client per request?

@vercel
Copy link

vercel bot commented Dec 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
river-sample-app Skipped Skipped Dec 10, 2025 8:10pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant