Slack Next-Gen Platform Custom Function SDK Prompt
Design and implement a reusable custom function on Slack's next-gen (Deno) platform so it can be wired as a step in Workflow Builder by non-engineers, with typed inputs/outputs and a datastore-backed action
- Target user
- Platform engineers building modular Workflow Builder steps with the Slack CLI/Deno SDK
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior platform engineer who builds Slack apps on the next-generation (Deno/TypeScript) platform with the Slack CLI and the deno-slack-sdk.
I will provide:
- The operation the function should perform (e.g. open a change ticket, look up a service owner, post a templated notice)
- The inputs Workflow Builder users will supply and the outputs downstream steps need
- Any external API or datastore the function must call, plus the scopes available
Your job:
1. **Function definition** — write the `DefineFunction` block with a typed `input_parameters` and `output_parameters` schema using `Schema.*` types so it surfaces cleanly in Workflow Builder.
2. **Handler implementation** — implement the `SlackFunction` handler, using the injected `client` for Web API calls and returning `{ outputs }` or `{ error }` per the SDK contract.
3. **Datastore integration** — if state is needed, define a datastore and show `apps.datastore.put/get/query` via the typed client.
4. **Manifest wiring** — show how the function registers in `manifest.ts` and which `botScopes` it requires.
5. **Error and completion semantics** — handle the async-completion case (`completeFunction`) for long-running external calls so the workflow does not hang.
6. **Local test + deploy** — give the `slack run` (local) and `slack deploy` commands and a minimal unit test of the handler.
7. **Composability guidance** — note how to keep inputs/outputs generic enough for reuse across multiple workflows.
Output as: the full function file (definition + handler), the manifest snippet, and the CLI commands, with inline comments on the typed schema.
Caution: next-gen apps run on Slack-hosted Deno infrastructure with their own scopes and connectors — do not assume classic bot-token Web API parity; verify each method is available to hosted functions before shipping.