Quick overview
This workflow receives a code snippet via webhook, performs deterministic static analysis, uses an OpenAI chat model to generate a structured explanation and optional follow-up answer, then sends the final report to a Slack channel after an approval step.
How it works
- Receives a POST request to a webhook containing a code snippet plus optional language and focus question.
- Detects the most likely programming language, extracts basic structure (such as function names), counts code/comment/blank lines, and estimates rough cyclomatic complexity.
- Sends the code and computed metrics to an OpenAI chat model to produce a JSON explanation with a summary, selected line-by-line notes, complexity analysis, issues, and suggestions.
- Parses the model’s JSON output, calculates a composite quality score from complexity and flagged issues, and builds a consolidated explanation report.
- Pauses execution to allow the submitter to provide one follow-up question, and if provided, asks the OpenAI chat model again using a trimmed code excerpt around any referenced line number.
- Pauses again for delivery confirmation and, if approved, posts the final explanation (and follow-up answer if present) to the configured Slack channel.
Setup
- Add an OpenAI (or compatible) credential for the OpenAI Chat Model used by both explanation and follow-up steps.
- Add a Slack credential with permission to post messages and set or confirm the target channel name in the workflow configuration.
- Update the webhook path as needed and configure your source app to POST the code payload (and optional language/focusQuestion) to the webhook URL.
- Configure the two wait/resume webhook URLs in your UI or process to submit the optional follow-up question and to send the final delivery approval (sendApproved).