{"product_id":"n8n-workflow-explain-pasted-code-with-gpt-4-1-to-slack","title":"n8n Workflow: Explain Pasted Code with GPT-4.1 to Slack","description":"\u003ch3\u003eTurn pasted code into a clear explanation—then share it to Slack with approval\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow receives a code snippet via webhook, uses \u003cstrong\u003eGPT-4.1\u003c\/strong\u003e to generate a structured, line-by-line explanation, and posts the final report to a specified \u003cstrong\u003eSlack\u003c\/strong\u003e channel—after an approval step. Perfect for teams that want fast, consistent code reviews without manual formatting.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eAccept code via webhook:\u003c\/strong\u003e Sends a POST request containing the code snippet, optional language, and an optional focus question.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eDetect and measure the snippet:\u003c\/strong\u003e Determines the most likely programming language, extracts basic structure (e.g., function names), and counts code\/comment\/blank lines. It also estimates rough cyclomatic complexity.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eAsk GPT for a JSON explanation:\u003c\/strong\u003e Passes the code and computed metrics to an OpenAI chat model to produce a \u003cem\u003eJSON\u003c\/em\u003e explanation including a summary, selected notes, complexity analysis, issues, and suggestions.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eParse and score quality:\u003c\/strong\u003e Reads the model’s JSON, calculates a composite quality score from complexity and flagged issues, and builds a consolidated report.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eOptional follow-up:\u003c\/strong\u003e Pauses execution for a submitter-provided follow-up question, then queries the model again using a trimmed code excerpt around any referenced line number.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eApproval gate + delivery:\u003c\/strong\u003e Pauses again for delivery confirmation; once approved, posts the final explanation (and follow-up answer, if provided) to the configured \u003cstrong\u003eSlack\u003c\/strong\u003e channel.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eHelp developers understand unfamiliar code by sending snippets to a centralized Slack review channel.\u003c\/li\u003e\n  \u003cli\u003eStandardize “code explanation” requests for SaaS support and engineering teams.\u003c\/li\u003e\n  \u003cli\u003eCreate a lightweight internal workflow for deterministic analysis + GPT-assisted review with human approval.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eNodes\/logic:\u003c\/strong\u003e \u003ccode\u003ewebhook\u003c\/code\u003e, \u003ccode\u003eif\u003c\/code\u003e, \u003ccode\u003eset\u003c\/code\u003e, \u003ccode\u003ecode\u003c\/code\u003e, \u003ccode\u003ewait\u003c\/code\u003e, \u003ccode\u003eslack\u003c\/code\u003e\n\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eIntegrations:\u003c\/strong\u003e OpenAI (or compatible) Chat Model for explanation and follow-up; \u003cstrong\u003eSlack\u003c\/strong\u003e for posting results\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eRequirements:\u003c\/strong\u003e Add an OpenAI credential for the Chat Model and a Slack credential with permission to post messages and target the correct channel\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":45830459326643,"sku":"N8N-18211","price":27.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/vwd_CYruYrbLk1qRL6jF8_edLFzHol.png?v=1786699011","url":"https:\/\/buyflowscripts.com\/products\/n8n-workflow-explain-pasted-code-with-gpt-4-1-to-slack","provider":"N8N Commerce","version":"1.0","type":"link"}