core icon indicating copy to clipboard operation
core copied to clipboard

reliable "member added to chat id" event for bots

Open Simon-Laux opened this issue 4 months ago • 2 comments

I have a bot that needs a reliable "member added to chat id" event that works in all cases. I currently use "chat modified", but that fires also in other cases, I would like to have a more specific event for this case to re-send my "welcome message".

workaround idea

The closest you can currently get to a more specific event is to listen to incoming "member added"-system-messages and also to "secure join progress 1000 events", because secure join doesn't trigger a member added message.

But the problem with the secure join events is that you only get a contact id, not which chat was joined. https://github.com/chatmail/core/pull/7181 adds the chat type as property to the event, but it is not possible to easily get the chat id in that event, especially on other devices on multi device setups. (https://github.com/chatmail/core/pull/7181#issuecomment-3267809167)

Anyways this workaround would still be bad bot developer UX, even if it worked, so I propose that we should add a new "member added to chat id" event for bots that is emitted in all cases.

Simon-Laux avatar Sep 08 '25 20:09 Simon-Laux

Do you want to always know that the member was added, e.g. by someone else, or only about the case when scanning a QR code resulted in your bot adding a member?

There is an edge case of implicit member addition if someone else added a member, but explicit "member added" message was lost, I guess you want to get an event in this case too?

Adding an event for only the case of your bot adding someone via securejoin would be easy. Addition by someone else, implicit addition and addition by your other device (in a case the developer using bot account manually to add someone) maybe should be another event.

link2xt avatar Sep 09 '25 02:09 link2xt

I just want a single event for all cases, that my bot can rely on.

(just simple from a user perspective, not what's technically most correct, but personally I would be fine with multiple events, as long as I can find out easily what events my bot needs to listen to)

Simon-Laux avatar Sep 09 '25 22:09 Simon-Laux