Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slack webhooks integration #536

Open
beauthi opened this issue Sep 5, 2024 · 3 comments
Open

Slack webhooks integration #536

beauthi opened this issue Sep 5, 2024 · 3 comments

Comments

@beauthi
Copy link

beauthi commented Sep 5, 2024

Slack webhooks require a specific format, e.g., body should look like

{ "text" : "content of the message" }

ref: https://api.slack.com/messaging/webhooks#advanced_message_formatting
It would be nice to have specific integration for Slack, as it's difficult to use them as is right now.

@light-bit
Copy link

What is not working for you right now? I struggled a bit at first, but got everything working with WebHook integration to my Slack.

@beauthi
Copy link
Author

beauthi commented Sep 13, 2024

@light-bit What's your configuration?
I currently have something like

    - WEBHOOK=true
    - WEBHOOK_URL=https://hooks.slack.com/services/ABC/DEF/ghi
    - WEBHOOK_METHOD=POST
    - WEBHOOK_TIMEOUT=60
    - WEBHOOK_TYPE=application/json

I'm still unsure how to use WEBHOOK_BODY.

@light-bit
Copy link

@beauthi
This is my config:

    - WEBHOOK=true
    - WEBHOOK_URL=https://hooks.slack.com/services/XXXX/XXXX/XXXXX
    - WEBHOOK_METHOD=POST
    - 'WEBHOOK_BODY={"attachments": [{"color": "78cfa4","fallback": "$${{items_available}} at $${{store_name}} for €$${{price}}","title": "$${{store_name}}","thumb_url": "$${{item_logo}}","mrkdwn_in": ["text","attachments","fields","value"],"fields": [{"value": "Quantity: $${{items_available}}\n\n","short": false},{"value": "Price: $${{price}} $${{currency}}\n\n","short": false},{"value": "Pick-up: $${{pickupdate}}\n\n","short": false},{"value": "<https://share.toogoodtogo.com/item/$${{item_id}}|Order>","short": false}]}]}'
    - WEBHOOK_TYPE=application/json
    - WEBHOOK_TIMEOUT=60

That will result in the following:
IMG_7626
IMG_7628

Note: I have hardcoded € for the notification, because I think it looks better, you could use $${{currency}} as well. Also, the environment variables inWEBHOOK_BODY need to be escaped, thus using the 's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants