Back to Novu

Edit sent messages

docs/agents/custom-code-agent/building-blocks/edit-sent-messages.mdx

3.19.02.1 KB
Original Source

ctx.reply() returns a ReplyHandle so that you can edit the message you just sent on the provider. This is useful when you post "Processing..." and replace it with the final text.

That is not a reply type; it updates a message you already sent.

Channel support

CapabilitySlackTeamsWhatsAppTelegramEmail
Message edits in placeYesYesYesYesNo
Plan card via edit-in-placeNative plan cardMarkdown edit-in-placeNoMarkdown edit-in-placeNo
Outbound file attachments on editYesYesNot yetNot yetNot yet

See Channels overview for the full matrix.

Basic edit

The following example sends a placeholder message, does work, then updates the same message in place:

tsx
const sentMessage = await ctx.reply('Processing...');
// ... do some work ...
await sentMessage.edit('Done! Here are your results.');

Edit with attachments

You can attach files when editing plain text or markdown content. Outbound files are delivered on Slack and Microsoft Teams; other channels do not support them yet. See Sending attachments.

tsx
await sentMessage.edit('Updated report attached.', {
 files: [{ filename: 'report.pdf', url: 'https://example.com/report.pdf' }],
});

Edits update the existing platform message rather than posting a new one. Not every provider supports message editing. See Channels overview and the Channel support strip above.

<Columns cols={2}> <Card icon="layout-grid" href="/agents/custom-code-agent/building-blocks/reply" title="Reply"> Send plain text, markdown, attachments, and interactive cards. </Card> <Card icon="mouse-pointer-click" href="/agents/custom-code-agent/building-blocks/handle-events" title="Handlers and context"> Event handlers and the context object your agent receives on every turn. </Card> </Columns>