-
Hi, first thanks for the gem! I am using noticed -v # To deliver this notification:
#
# CarModel::GeneratorNotifier.with(message: "message").deliver_later(Current.system_account)
class CarModel::GeneratorNotifier < ApplicationNotifier
deliver_by :slack do |config|
config.url = -> {
if params[:error]
Rails.application.credentials.dig(:slack, :errors_webhook_url)
else
Rails.application.credentials.dig(:slack, :wins_webhook_url)
end
}
config.json = -> {
{
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: params[:message]
}
},
{
type: "context",
elements: [
{
type: "mrkdwn",
text: "Environment: #{Rails.env}"
}
]
}
]
}
}
end
# If you need to perform any additional setup or have helper methods,
# you can define them here
# Example of a helper method
def message
params[:message]
end
end The first hurdle I had to figure out was to include a default recipient, as It was not getting far without one. But then after that, the job is enqueued but nothing get's sent to Slack. This is the result object I get from calling the notifier on rails console #<CarModel::GeneratorNotifier:0x000000012561e5b0
id: 72,
account_id: 2,
type: "CarModel::GeneratorNotifier",
record_type: nil,
record_id: nil,
params: {:message=>"message"},
created_at: "2024-09-12 03:08:52.788541000 +0000",
updated_at: "2024-09-12 03:08:52.788541000 +0000",
notifications_count: 1> Anything I need to do to send messages to a Slack channe? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You should use a bulk delivery since this doesn't need any recipients. Delivery enqueues a job, so make sure your jobs are being processed and check them for errors. |
Beta Was this translation helpful? Give feedback.
-
Thanks Chris, for bulk deliveries, I need to set it this way? |
Beta Was this translation helpful? Give feedback.
Should be
bulk_deliver_by
. Our docs are wrong on those so I just updated them.