PostProcessors modify or enhance AI-generated responses before they’re sent to users. They allow you to add disclaimers, apply formatting, inject dynamic content, or transform the output in any way.
Think of it as:
A final editor - reviews and enhances responses before they go to users
New in v3.0.0: Response postprocessing for consistent formatting, branding, and enhancement.
import { PostProcessor, UserDataInstance } from 'lua-cli';const addDisclaimer = new PostProcessor({ name: 'add-disclaimer', description: 'Add legal disclaimer to responses', execute: async (user: UserDataInstance, message: string, response: string, channel: string) => { return { modifiedResponse: response + "\n\n_Disclaimer: This is AI-generated content for informational purposes only._" }; }});
Tip: You can also access the channel via Lua.request.channel, the user via User.get(), and raw webhook data via Lua.request.webhook?.payload. See the Lua API for details.
PostProcessors run in order of their priority value (lowest first). Priority is set when creating the postprocessor via the API.
Copy
AI Agent Response ↓PostProcessor 1 (priority: 1) → Runs first ↓PostProcessor 2 (priority: 10) → Runs second ↓PostProcessor 3 (priority: 100) → Runs last ↓Final Response to User
Default priority: 100 (if not specified)Each postprocessor receives the output of the previous one in the chain.