{"id":34599608,"url":"https://github.com/ontanj/slack-build","last_synced_at":"2026-04-16T14:43:01.387Z","repository":{"id":57031849,"uuid":"119842651","full_name":"ontanj/slack-build","owner":"ontanj","description":"Helper for constructing messages to send to Slack through integrations.","archived":false,"fork":false,"pushed_at":"2018-02-21T23:25:39.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-31T18:53:27.050Z","etag":null,"topics":["constructing-messages","slack","slack-api"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ontanj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-01T13:55:42.000Z","updated_at":"2020-03-11T13:43:21.000Z","dependencies_parsed_at":"2022-08-23T20:50:12.118Z","dependency_job_id":null,"html_url":"https://github.com/ontanj/slack-build","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ontanj/slack-build","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ontanj%2Fslack-build","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ontanj%2Fslack-build/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ontanj%2Fslack-build/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ontanj%2Fslack-build/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ontanj","download_url":"https://codeload.github.com/ontanj/slack-build/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ontanj%2Fslack-build/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31891038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T11:36:10.202Z","status":"ssl_error","status_checked_at":"2026-04-16T11:36:09.652Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["constructing-messages","slack","slack-api"],"created_at":"2025-12-24T12:23:01.761Z","updated_at":"2026-04-16T14:43:01.375Z","avatar_url":"https://github.com/ontanj.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Build\n\nA helper for constructing messages to send to Slack through integrations. Build is a static class that helps you add the parts of your message in the right way. Pass an empty array to start building. Before sending it back to Slack you need to convert it to json using for example `json_encode()`.\n\n## Installation\n\n`composer require ontanj/slack-build`\n\n\n## Usage \n\nThe static class is called Build and are located in the namespace `SlackBuild`.\n\nTo start building your message you pass an empty array to the desired function. The array is passed by reference and everything is added as it goes.\n\nBefore sending it to Slack it needs to be converted to a json string, using for example `json_encode()`.\n\n### Available functions \n```\n/**\n * Adds an attachment to the message\n * @param array $data message to add the attachment to\n * @param string $fallback message to show if display is unavailable\n * @param string $callback_id id for interactive messages\n * @return int index of added attachment\n */\npublic static function add_attachment(array \u0026$data, string $fallback, string $callback_id=null) : int\n\n/**\n * Adds a button to a message\n * @param array $data message to add the button to\n * @param int $att_index index of the attachment to add to\n * @param string $name identifiable name for the button\n * @param string $text text shown on the button\n */\npublic static function add_button(array \u0026$data, int $att_index, string $text, string $name)\n\n/**\n * Adds a field to message\n * @param array $data message to add the field to\n * @param int $att_index index of the attachment to add to\n * @param string $title title of the field\n * @param string $value value of the field\n * @param bool $short whether the field should be short, true for short\n */\npublic static function add_field(array \u0026$data, int $att_index, string $title, string $value, bool $short=true)\n\n/**\n * Adds a list menu to a message\n * @param array $data message to add the menu to\n * @param int $att_index index of the attachment to add the menu to\n * @param string $name identifiable name for the menu\n * @param string $text text for the menu\n * @return int index of added menu\n */\npublic static function add_menu(array \u0026$data, int $att_index, string $text, string $name) : int\n\n/**\n * Adds a full list to a list menu, using the text also as value\n * @param array $data message to add the list to\n * @param int $att_index index of the attachment to add to\n * @param int $act_index index of the menu to add to\n * @param array $list array with list entries as element\n */\npublic static function add_menu_list(array \u0026$data, int $att_index, int $act_index, array $texts, array $values)\n\n/**\n * Adds an option to a list menu\n * @param array $data message to add the option to\n * @param int $att_index index of the attachment to add to\n * @param int $act_index index of the menu to add to\n * @param string $text text of the option\n * @param string $value key of the option\n */\npublic static function add_menu_option(array \u0026$data, int $att_index, int $act_index, string $text, string $value)\n\n/**\n * Adds a color to an attachment\n * @param array $data message to add the color to\n * @param int $att_index index of the attachment to add the color to\n * @param string $color the color, coded as hex-color with hashtag \"#FFFFFF\" or \n * using predefined constants\n */\npublic static function attachment_color(array \u0026$data, int $att_index, $color=self::random)\n\n/**\n * Adds an attachment text to a message\n * @param array $data message to add the attachment text to\n * @param int $att_index index of the attachment to add to\n * @param string $title\n */\npublic static function attachment_text(array \u0026$data, int $att_index, string $text)\n\n/**\n * Adds an attachment title to a message\n * @param array $data message to add the attachment title to\n * @param int $att_index index of the attachment to add to\n * @param string $title\n */\npublic static function attachment_title(array \u0026$data, int $att_index, string $title)\n\n/**\n * Gets one of predefined constant colors\n * @param int $color\n * @return string\n */\nprivate static function get_color(int $color)\n\n/**\n * Adds top-level text to a message\n * @param array $data array to add the text to\n * @param string $text\n */\npublic static function message_text(array \u0026$data, string $text)\n\n/**\n * Sets the message to replace the original posted message \n * @param array $data message to set\n * @param bool $replace true is replace, false is don't replace\n */\npublic static function replace_original(array \u0026$data, bool $replace)\n\n/**\n * Sets the message to delete the original message and post as new\n * @param array $data message to se\n * @param bool $delete true is delete, false is don't\n */\npublic static function delete_original(array \u0026$data, bool $delete)\n```\n### Predefined colors\n\n```\nconst random = 0;\nconst black = 1;\nconst white = 2;\nconst yellow = 3;\nconst blue = 4;\nconst green = 5;\nconst red = 6;\n```\n\n## Future\n\nThe aim is to include more functions. Feel free to contribute.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fontanj%2Fslack-build","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fontanj%2Fslack-build","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fontanj%2Fslack-build/lists"}