Example Workflow: Slack Command Assistant
This workflow enables Slack slash commands to trigger documentation generation, Notion updates, or ad-hoc code analysis via DocuWriter.ai. It handles parsing, validation, routing, and contextual responses—all within an n8n workflow.
Workflow Overview
The Slack Command Assistant uses a webhook to receive /docuwriter commands. It then:
- Parses the command payload
- Validates the action
- Routes to the appropriate process (GitHub, Notion, Analysis, or Help)
- Responds back to Slack with real-time feedback
flowchart TD
A[Slack Slash Command<br/>(/docuwriter)] --> B[Slack Doc Command Trigger]
B --> C[Parse Slack Command]
C --> D{Validate Command}
D -->|Valid| E[Route by Action]
D -->|Invalid| F[Respond Invalid Command]
E --> G[GitHub Flow]
E --> H[Notion Flow]
E --> I[Analyze Flow]
E --> J[Help Response]
F --> K[Respond Invalid Command]
J --> L[Respond Help Command]
Commands & Syntax
Users invoke the workflow via Slack slash commands. Available commands include:
| Command | Description |
|---|---|
/docuwriter github <repo-url> |
Generate documentation for a GitHub repository |
/docuwriter notion <database-id> |
Update a Notion database with generated docs |
/docuwriter analyze <code> |
Perform code quality analysis on provided code |
/docuwriter help |
Show usage guidance and feature list |
The help response is formatted as an ephemeral Slack message with command details and examples .
Node Breakdown
Below is a table of the core nodes in this workflow:
| Node Name | Type | Responsibility |
|---|---|---|
| Slack Doc Command Trigger | webhook | Listens for /docuwriter POST requests |
| Parse Slack Command | code | Extracts action, target, options, user |
| Validate Command | if | Checks if action ∈ {github, notion,...} |
| Route by Action | switch/if | Branches flow based on parsed action |
| Respond Help Command | respondToWebhook | Sends command usage and feature list |
| Respond Invalid Command | respondToWebhook | Alerts user of invalid syntax |
| GitHub Branch | various (HTTP, code, DocuWriter) | Processes GitHub docs generation |
| Notion Branch | notion, code, DocuWriter | Retrieves pages & updates with docs |
| Analyze Branch | DocuWriter | Runs ad-hoc code analysis |
| Respond to Slack (X) | respondToWebhook | Returns formatted Slack JSON for each flow |
Parse Slack Command
This code node extracts key data from Slack’s webhook payload:
// Parse Slack slash command for documentation request
const slackPayload = $json;
const command = slackPayload.text || '';
const parts = command.split(' ');
return {
json: {
action: parts[0]?.toLowerCase() || 'help',
target: parts[1] || '',
options: parts.slice(2).join(' '),
user: { id: slackPayload.user_id, name: slackPayload.user_name },
channel: { id: slackPayload.channel_id },
timestamp: Date.now(),
isValidCommand: ['github','notion','analyze','help'].includes(parts[0]?.toLowerCase())
}
};
Validate Command
An If node ensures only supported actions proceed:
- True → continue to Route by Action
- False → invoke Respond Invalid Command
{
"conditions": {
"leftValue": "={{ $json.isValidCommand }}",
"operation": "equal",
"rightValue": true
}
}
Route by Action
This Switch/If logic directs valid commands:
- github → GitHub Flow
- notion → Notion Flow
- analyze → Analyze Flow
- help → Respond Help Command
GitHub Flow
- Parse GitHub Repository Info
- Get GitHub Repository Files → Filter GitHub Code Files → Download GitHub File
- Generate GitHub Documentation
- Format GitHub Slack Response
- Respond to Slack (GitHub)
Notion Flow
- Get Notion Database
- Extract Code from Notion
- Generate Notion Documentation
- Update Notion Page
- Respond to Slack (Notion)
Analyze Flow
- Analyze Code Quality (DocuWriter.ai)
- Format Analysis Slack Response
- Respond to Slack (Analysis)
Help Response
- Respond Help Command sends usage details .
Respond Help Command
Sends an ephemeral Slack JSON payload with:
- 📚 DocuWriter.ai Help
- Commands: list with backticks
- Examples: sample invocations
- Features: ✅ bullet list
{
"response_type": "ephemeral",
"text": "📚 **DocuWriter.ai Help**\n\nGenerate documentation and analyze code using Slack commands:\n\n**Commands:**\n• `/docuwriter github <repo-url>` - Generate documentation for GitHub repository\n• `/docuwriter notion <database-id>` - Update Notion database with documentation\n• `/docuwriter analyze <code>` - Perform code quality analysis\n\n**Examples:**\n• `/docuwriter github https://github.com/user/repo`\n• `/docuwriter notion abc123def456`\n• `/docuwriter analyze function calculateTotal() { ... }`\n\n**Features:**\n✅ Multi-platform integration\n✅ Real-time documentation generation\n✅ Code quality analysis\n✅ Team notifications\n✅ Email reports"
}
Adapting This Workflow
To tailor this assistant:
- Add new commands: Extend
isValidCommandand Route by Action branches. - Customize responses: Modify code nodes or
respondToWebhookbodies. - Integrate additional platforms: Insert new sub-flows after parsing (e.g., Bitbucket, GitLab).
- Adjust limits: Change file filtering logic in Filter GitHub Code Files.
Use this pattern as a template for multi-platform, interactive Slack automations.
Updated