Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

chriswb's avatar

Dynamic Slack webhook and/or Storing Slack webhook URL per user or team

Hi All,

I've been smashing my head against the wall for a while on this.

At first I was trying to access to Auth:user() object from the routeNotificationForSlack() which in hindsight, makes sense why this wouldn't work from a queue.

After some googling and playing around I found this post https://laracasts.com/discuss/channels/laravel/sending-notification-to-multiple-slack-webhooks# but this is still relying on known configuration settings, which I just won't have.

I tried to change it to pass the webhook url itself as below;

    public $webhook;

    public function routeNotificationForSlack() {
        if($this->webhook){
            return $this->webhook;
        }
    }
    
    public function slackWebhook($teamhook){
        $this->webhook = $teamhook;
        return $this;
    }

This runs, but the webhook url doesnt appear to be available, nor does the slack message arrive.

To be clear, this notification will be used by multiple users/teams in my system, each of which will have their own webhook url.

Any help would be greatly appreciated

Chris

0 likes
5 replies
chriswb's avatar

Oh and if I hardcode the webhook_url in routeNotificationForSlack() everything works as expected

chriswb's avatar

Thanks @rin4ik this pointed me in the right direction (although it was a quick throwaway "make this dynamic" line haha)

My issue ended up being an unneeded "teamcheck" scope.

Juancruzmartino's avatar

Having the same problem. If I don't queue the notification then it workds perfectly.

How did you manage to solve this @chriswb ?

Please or to participate in this conversation.