{"id":13828279,"url":"https://github.com/beyondcode/slack-notification-channel","last_synced_at":"2025-04-05T18:11:51.005Z","repository":{"id":34883824,"uuid":"186890389","full_name":"beyondcode/slack-notification-channel","owner":"beyondcode","description":"Laravel Slack notification channel with API token support instead of incoming webhooks.","archived":false,"fork":false,"pushed_at":"2024-02-27T20:33:08.000Z","size":37,"stargazers_count":86,"open_issues_count":2,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-05T17:38:59.600Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/beyondcode.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-05-15T19:29:49.000Z","updated_at":"2024-11-18T15:37:37.000Z","dependencies_parsed_at":"2024-08-04T09:08:13.590Z","dependency_job_id":"00e5d64e-76fa-4e77-b675-98066a6cf8a7","html_url":"https://github.com/beyondcode/slack-notification-channel","commit_stats":{"total_commits":31,"total_committers":10,"mean_commits":3.1,"dds":0.5483870967741935,"last_synced_commit":"7cd48f69f8852eabfc3464b0ebc15d632bdecd55"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondcode%2Fslack-notification-channel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondcode%2Fslack-notification-channel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondcode%2Fslack-notification-channel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondcode%2Fslack-notification-channel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beyondcode","download_url":"https://codeload.github.com/beyondcode/slack-notification-channel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378152,"owners_count":20929297,"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":"2024-08-04T09:02:39.549Z","updated_at":"2025-04-05T18:11:50.982Z","avatar_url":"https://github.com/beyondcode.png","language":"PHP","readme":"# Laravel Slack API Token Notification Channel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/beyondcode/slack-notification-channel.svg?style=flat-square)](https://packagist.org/packages/beyondcode/slack-notification-channel)\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/beyondcode/slack-notification-channel/run-tests?label=tests)\n[![Quality Score](https://img.shields.io/scrutinizer/g/beyondcode/slack-notification-channel.svg?style=flat-square)](https://scrutinizer-ci.com/g/beyondcode/slack-notification-channel)\n[![Total Downloads](https://img.shields.io/packagist/dt/beyondcode/slack-notification-channel.svg?style=flat-square)](https://packagist.org/packages/beyondcode/slack-notification-channel)\n\nThis is the Laravel Slack notification channel, but instead of using incoming webhooks, this channel makes use of OAuth access tokens. It also allows replies to thread messages.\n\n\n[![https://phppackagedevelopment.com](https://beyondco.de/courses/phppd.jpg)](https://phppackagedevelopment.com)\n\nIf you want to learn how to create reusable PHP packages yourself, take a look at my upcoming [PHP Package Development](https://phppackagedevelopment.com) video course.\n\n### Usage\n\nInstall the package via composer:\n\n```\ncomposer require beyondcode/slack-notification-channel\n```\n\nThe service provider gets registered automatically and you can use this package as a replacement of the core Laravel Slack notification channel.\n\n### Notification Routing\n\nSince this notification channel makes use of Slack API tokens instead of incoming webhook URLs, you need to return an array containing the API token and an optional channel. \nThis channel will be used, if it is not provided in the `SlackMessage` that you send:\n\n```php\npublic function routeNotificationForSlack()\n{\n    return [\n        'token' =\u003e 'xoxp-slack-token',\n        'channel' =\u003e '#general'\n    ];\n}\n```\n\n### Replying to Message Threads\n\nAssuming you want to keep track of orders and have your team/bot respond to a single thread of per order placed, this channel allows you to retrieve the API response from the chat.postMessage method inside your notifications. With this you could post messages on order paid, shipped, closed, etc. events to the same thread.\n\nIn your order placed event you can have\n\n```php\npublic function toSlack($notifiable)\n{\n    return (new SlackMessage)\n        -\u003econtent('A new order has been placed');\n}\n\npublic function response($response)\n{\n    $response = $response-\u003egetBody()-\u003egetContents();\n    $this-\u003eorder-\u003edata('slack.thread_ts', json_decode($response, true)['ts']);\n}\n```\n\nAnd in your order paid event you can have\n\n```php\npublic function toSlack($notifiable)\n{\n    $order = $this-\u003eorder;\n    return (new SlackMessage)\n        -\u003esuccess()\n        -\u003econtent('Order paid')\n        -\u003ethreadTimestamp($order-\u003edata('slack.thread_ts'))\n           -\u003eattachment(function ($attachment) use ($order) {\n               $attachment-\u003etitle(\"Order $order-\u003ereference has been paid for.\")\n                          -\u003econtent('Should now be processed.')\n                          -\u003eaction('View Order', route('orders', $order-\u003ereference));\n           });\n}\n```\n\n## Customizing the channel name\n\nLaravel ships with a slack notification channel which uses web hooks. This packages overwrites that default slack channel.\n \n Should you want to use Laravel's default Slack channel and this one inside one app, you'll need to use a different channel name. \n \n You can set the channel name using\n \n ```php\nSlackApiChannel::$channelName = 'alternativeSlackChannel'\n```\n\nMake sure you use the right method name on your notifications.\n\n```php\nclass AlternativeSlackChannelNameNotification extends Notification\n{\n    public function toAlternativeSlackChannel($notifiable) {\n        // ...\n    }\n}\n```\n \n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email marcel@beyondco.de instead of using the issue tracker.\n\n## Credits\n\n- [Marcel Pociot](https://github.com/mpociot)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyondcode%2Fslack-notification-channel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeyondcode%2Fslack-notification-channel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyondcode%2Fslack-notification-channel/lists"}