- How do I send a basic Slack notification in Laravel using this package?
- First, configure your Slack webhook URL in `config/services.php` under the `slack` key. Then, create a notification class extending `SlackMessage` and use Laravel’s `Notification::send()` method to dispatch it to users or channels. Example: `Notification::send($user, new DeploymentNotification());`.
- Does this package support Slack’s interactive messages (buttons, modals, etc.)?
- Yes, the package supports Slack’s Block Kit for interactive messages. Extend `SlackMessage` and use the `toSlack()` method to define blocks for buttons, modals, or dynamic content. Refer to Slack’s [Block Kit documentation](https://api.slack.com/block-kit) for syntax.
- Which Laravel versions and PHP versions are officially supported?
- This package is officially compatible with Laravel 8 through 13 and PHP 8.0 to 8.4. Check the [Laravel documentation](https://laravel.com/docs/notifications#slack-notifications) for version-specific setup instructions.
- How do I handle Slack API rate limits in production?
- Slack enforces rate limits (e.g., 1 message/sec per channel). To mitigate this, use Laravel’s queue system (e.g., Redis or database queues) to batch notifications. Implement exponential backoff in your queue worker if needed.
- Can I send notifications to specific Slack users instead of channels?
- Yes, configure the `toUser()` method in your `SlackMessage` class to target individual users by their Slack ID. Ensure your Slack app has the `users:read` scope for user-specific permissions.
- How do I test Slack notifications in my Laravel app?
- Use Slack’s [Mock API](https://api.slack.com/mock-api) or mock the `SlackWebhookChannel` with Guzzle middleware in PHPUnit/Pest. For UI testing (e.g., BlockKit interactions), use Laravel Dusk to verify message rendering.
- What’s the difference between `SlackWebhookChannel` and `SlackChannel`?
- `SlackWebhookChannel` sends messages via a direct webhook URL (simpler, no OAuth). `SlackChannel` uses Slack’s API (requires OAuth) and supports advanced features like user-specific messages or interactive components. Choose based on your Slack app setup.
- How do I log failed Slack notifications?
- Override the `failed()` method in your notification class to log failures to Laravel’s log system or a monitoring tool. Example: `Log::error('Slack notification failed', ['exception' => $exception]);`.
- Is there a way to skip notifications for certain environments (e.g., local)?
- Yes, implement the `shouldSend()` method in your notification class to conditionally skip notifications. Example: `return app()->environment('production');` to disable in non-production environments.
- What are the alternatives to this package for Slack notifications in Laravel?
- Alternatives include third-party packages like `spatie/laravel-slack-notification` or custom solutions using Guzzle to call Slack’s API directly. However, this official package offers deeper Laravel integration, BlockKit support, and async queue handling out of the box.