Using multiple webhooks | laravel-slack-alerts-go | Spatie       

 SPATIE  

laravel-slack-alerts-go
=======================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-slack-alerts-go](https://spatie.be/docs/laravel-slack-alerts-go/v1)  Using multiple webhooks

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-slack-alerts-go/v1) 

  Using multiple webhooks    
- [ Introduction ](https://spatie.be/docs/laravel-slack-alerts-go/v1/introduction)
- [ Installation ](https://spatie.be/docs/laravel-slack-alerts-go/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/laravel-slack-alerts-go/v1/usage)
- [ Sending blocks ](https://spatie.be/docs/laravel-slack-alerts-go/v1/sending-blocks)
- [ Using multiple webhooks ](https://spatie.be/docs/laravel-slack-alerts-go/v1/using-multiple-webhooks)
- [ Queuing ](https://spatie.be/docs/laravel-slack-alerts-go/v1/queuing)
- [ Formatting ](https://spatie.be/docs/laravel-slack-alerts-go/v1/formatting)
- [ Testing ](https://spatie.be/docs/laravel-slack-alerts-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/laravel-slack-alerts-go/v1/releasing)
- [ Changelog ](https://spatie.be/docs/laravel-slack-alerts-go/v1/changelog)
- [ Support us ](https://spatie.be/docs/laravel-slack-alerts-go/v1/support-us)

 Using multiple webhooks
=======================

Add per-channel webhook URLs in your package configuration:

```
slackalerts.New(func(cfg *slackalerts.Config) {
    cfg.WebhookURLs["marketing"] = "https://hooks.slack.com/services/XXXXXX"
})
```

Choose the webhook with `To`:

```
err := slackalerts.From(ctx).To("marketing").Message(ctx, "You have a new subscriber!")
```

### Using a custom webhooks

`To` also supports direct HTTP(S) webhook URLs. Only pass trusted URLs, not unvalidated user input.

```
err := slackalerts.From(ctx).To("https://custom-url.com").Message(ctx, "You have a new subscriber!")
```

### Sending message to an alternative channel

```
err := slackalerts.From(ctx).ToChannel("subscription_alerts").Message(ctx, "New subscriber!")
```

Modern Slack incoming webhooks ignore channel overrides and always deliver to their installed channel. `ToChannel` only affects legacy webhooks. Use a separate webhook per channel with `To`, or use Slack's Web API with a bot token.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
