{"id":26389277,"url":"https://github.com/themashcodee/slack-blocks-ai-schema","last_synced_at":"2025-03-17T09:17:37.517Z","repository":{"id":282746500,"uuid":"949518611","full_name":"themashcodee/slack-blocks-ai-schema","owner":"themashcodee","description":"A TypeScript library providing Zod schemas for Slack Block Kit, designed to be used with AI integrations.","archived":false,"fork":false,"pushed_at":"2025-03-16T17:52:55.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T18:40:20.312Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/slack-blocks-ai-schema","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/themashcodee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-16T16:34:05.000Z","updated_at":"2025-03-16T17:52:58.000Z","dependencies_parsed_at":"2025-03-16T18:40:28.651Z","dependency_job_id":"9da0bbfc-80a2-454d-ac0c-913e4111999a","html_url":"https://github.com/themashcodee/slack-blocks-ai-schema","commit_stats":null,"previous_names":["themashcodee/slack-blocks-ai-schema"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themashcodee%2Fslack-blocks-ai-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themashcodee%2Fslack-blocks-ai-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themashcodee%2Fslack-blocks-ai-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themashcodee%2Fslack-blocks-ai-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/themashcodee","download_url":"https://codeload.github.com/themashcodee/slack-blocks-ai-schema/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244006335,"owners_count":20382443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-17T09:17:36.978Z","updated_at":"2025-03-17T09:17:37.507Z","avatar_url":"https://github.com/themashcodee.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/themashcodee"],"categories":[],"sub_categories":[],"readme":"# slack-blocks-ai-schema\n\n\u003e 🫶🏼 If you use this in your project, please consider giving a shoutout on LinkedIn (@themashcodee) or crediting the original author. Your support is much appreciated!\n\nA JSON schema for validating Slack Block Kit content, specifically designed for AI integrations. This library helps ensure that AI-generated Slack messages conform to the Block Kit format.\n\n## Installation\n`npm i slack-blocks-ai-schema`\n\n## Features\n- Complete JSON schema for Slack Block Kit validation\n- Optimized for AI integrations (OpenAI, Anthropic, etc.)\n- Simple and lightweight\n- Zero dependencies\n\n## Example Usage\n```typescript\nimport dotenv from \"dotenv\"\ndotenv.config()\nimport OpenAI from \"openai\"\nimport { json_schema } from \"slack-blocks-ai-schema\"\n\nconst client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY })\n\nasync function main() {\n\tconst completion = await client.chat.completions.create({\n\t\tmodel: \"gpt-4o-mini\",\n\t\tmessages: [\n\t\t\t{\n\t\t\t\trole: \"system\",\n\t\t\t\tcontent:\n\t\t\t\t\t\"You are a helpful assistant that creates Slack Block Kit content. Only use blocks and formats as defined in the response format schema. For text content, use plain_text or mrkdwn text objects where appropriate.\",\n\t\t\t},\n\t\t\t{\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent:\n\t\t\t\t\t\"Create a brief product announcement using Slack blocks for a new eco-friendly water bottle. Include a product image. Describe the product features and benefits, highlighting key points with markdown formatting.\",\n\t\t\t},\n\t\t],\n\t\tresponse_format: {\n\t\t\ttype: \"json_schema\",\n\t\t\tjson_schema: {\n\t\t\t\tname: \"blocks\",\n\t\t\t\tschema: json_schema,\n\t\t\t},\n\t\t},\n\t})\n\n\tconst completion_text = completion.choices[0].message.content\n\tif (!completion_text) return console.log(\"No completion text\")\n\t\n\tconst parsed = JSON.parse(completion_text) // { blocks: [...] }\n\tconsole.log(\n\t\t`https://app.slack.com/block-kit-builder#${encodeURIComponent(\n\t\t\tJSON.stringify(parsed)\n\t\t)}`\n\t)\n}\n\nawait main()\n```\n\n## Support\nLove my open source work or anything else I do? Treat me to a coffee! 😊\n\n[![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/themashcodee)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthemashcodee%2Fslack-blocks-ai-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthemashcodee%2Fslack-blocks-ai-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthemashcodee%2Fslack-blocks-ai-schema/lists"}