I am developing a bot for slack. I am implementing a notification functionality, where it will send a notification for every one hour. Currently, I am sending normal text in notification, but I need to send an image along with text. Is it possible to send an image?
Slack bots are limited by the Slack API to specific formats: text, images, and special controls.
Hover over the message you'd like to share. Click the three dots icon and choose Copy link. Paste the link into the message field, add text of your own if you'd like, and press Enter to send it.
You may see Slackbot in channels throughout your workspace, delivering reminders and automated messages for you and your teammates. When there's a reminder or a message just for you, Slackbot will send you a DM. You can access your DM with Slackbot the same way you would find a DM with anyone else in your workspace.
You can send images as part of the attachments of a message. That can be either a full image or a thumbnail.
Just add the image_url
property for full images or the thumb_url
property for a thumbnail image with a url to an image to your attachment and it will be displayed under your message. You can also send multiple images through adding multiple attachments.
Example attachment: (based on official Slack documentation example)
{
"attachments": [
{
"fallback": "Required plain-text summary of the attachment.",
"text": "Optional text that appears within the attachment",
"image_url": "http://my-website.com/path/to/image.jpg",
"thumb_url": "http://example.com/path/to/thumb.png"
}
]
}
This works with all approaches for sending message, e.g. API method, Incoming webhook, response to slash commands etc.
See here for the official Slack documentation for attachments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With