Lark Bots Beyond Webhooks: Identity Binding and Group Subscription Lifecycles
A fixed custom group webhook is enough when I only want a research briefing in one test group. If authorized users later need direct-message binding, or an approved test group wants to subscribe to new reports, an application bot and a separate subscription lifecycle become necessary.
This is an advanced personal-Agent integration design. No application was created, live message sent or event received. See Lark notifications for the fixed-group starting point.
From application identity to the intended recipient
Create an application in an authorized Lark test tenant, enable the bot, request only required sending and event scopes, configure availability and publish the appropriate version. The official application bot tutorial illustrates tenant_access_token and open_id. The official message example also describes chat_id for groups.
An email string is not an authenticated Lark identity. Let an authorized application account verify and bind its identity. Store the platform identifier together with application, tenant, recipient type and revision. Unbinding disables future sends. Email is an auxiliary manual check only. This is a synthetic internal binding projection:
{
"appRef": "research-demo",
"tenantRef": "test-tenant",
"targetType": "open_id",
"targetRef": "bound-user-001",
"bindingRevision": 3
}The direct-message adapter reads an approved binding and constructs the provider request. This fragment shows the payload shape only, not a real request:
// Resolve the recipient and token from authorized server-side state.
const payload = {
receive_id: authorizedRecipient.openId,
msg_type: 'text',
content: JSON.stringify({ text: 'Synthetic research report ready' }),
uuid: stableDeliveryAttemptId
}
// POST /open-apis/im/v1/messages?receive_id_type=open_id
// Authorization: Bearer <server-side tenant access token>Inspect both HTTP and business response codes; preserve necessary receipts. Use provider deduplication parameters such as uuid only within documented scope and time; they do not replace durable application delivery identity.
Group membership is not permanent send permission
Configure a protected HTTPS callback following the official event subscription guide. Use the official SDK or current protocol to verify raw-request signatures, encryption, Verification Token, app and tenant; handle URL challenge separately from membership events. Accept only authorized groups. Confirm exact event names and required scopes in the developer console during implementation.
Each membership addition creates a subscription round; removal or administrator revocation invalidates it. Deduplicate by event identity. Arrival time is not reliable event order. If reliable ordering is unavailable, reconcile current platform membership or pause until verified.
| Situation | Handling |
|---|---|
| First addition to approved test group | New subscription revision; optional synthetic welcome |
| Repeated addition callback | No second round or duplicate welcome |
| Report committed, subscription active | Queue delivery bound to that revision |
| Removal or revocation | Cancel undispatched records; reconcile already dispatched effects |
| Late old event or delivery | Check current revision and membership; do not resurrect old subscriptions |
If joining should send the latest public report, commit the subscription and catch-up delivery together. A uniqueness contract covering target, report revision and subscription round prevents a concurrent live publication and catch-up from sending the same content twice.
Qualify the real client
In a future integration test, bind two synthetic accounts separately and check each receives only its own notification. Add the bot to an authorized test group, publish a synthetic report, remove it and verify cancellation of future notifications. Simulate duplicate and reordered callbacks, queued delivery after revocation and direct-message unbinding. Report links still require application authorization.
Group push, subsequent direct messages and event triggers are Planned in the Open ETF Agent application roadmap. This design neither claims live Lark support nor treats membership events as authorization to invoke a model.