Checklists
Checklists let users track tasks in a chat. Use sendChecklist with a title and an array of InputChecklistItem objects.
Sending a Checklist
const message = await client.sendChecklist(chatId, "Release checklist", [
{ text: "Run the tests" },
{ text: "Update the documentation" },
{ text: "Publish the release" },
]);
Within an update handler, use ctx.replyChecklist to send a checklist to the current chat.
Letting Others Update a Checklist
By default, only the creator can add or complete items. Set isExtendableByOthers and isCompletableByOthers to let other users do so.
await client.sendChecklist(chatId, "Trip planning", [
{ text: "Book accommodation" },
{ text: "Choose activities" },
], {
isExtendableByOthers: true,
isCompletableByOthers: true,
});
Reading a Checklist
Checklist messages contain their title, items, and permissions in message.checklist.
client.on("message:checklist", (ctx) => {
console.log(ctx.msg.checklist.title);
for (const item of ctx.msg.checklist.items) {
console.log(item.id, item.text, item.type);
}
});
An item’s type is either "checked" or "unchecked". Checked items also include the user who completed them and the completion time.
Updating a ChecklistUSER-ONLY
User clients can check and uncheck items by their identifiers.
const itemId = message.checklist.items[0].id;
await client.checkChecklistItem(chatId, message.id, itemId);
await client.uncheckChecklistItem(chatId, message.id, itemId);
Use checkChecklistItems and uncheckChecklistItems to update multiple items. Use addToChecklist to append items.
await client.addToChecklist(chatId, message.id, [
{ text: "Announce the release" },
]);