{"id":22743116,"url":"https://github.com/rikas/slack-poster","last_synced_at":"2025-08-20T08:31:58.166Z","repository":{"id":13431412,"uuid":"16120326","full_name":"rikas/slack-poster","owner":"rikas","description":"Simple gem to post messages on Slack using web hooks.","archived":false,"fork":false,"pushed_at":"2021-06-21T09:22:12.000Z","size":68,"stargazers_count":51,"open_issues_count":0,"forks_count":19,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-28T15:51:33.865Z","etag":null,"topics":["bot","message-attachment","poster","ruby","slack","slack-api","slackbot"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rikas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-21T21:58:48.000Z","updated_at":"2023-12-19T17:32:42.000Z","dependencies_parsed_at":"2022-09-22T14:25:43.616Z","dependency_job_id":null,"html_url":"https://github.com/rikas/slack-poster","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/rikas/slack-poster","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rikas%2Fslack-poster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rikas%2Fslack-poster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rikas%2Fslack-poster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rikas%2Fslack-poster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rikas","download_url":"https://codeload.github.com/rikas/slack-poster/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rikas%2Fslack-poster/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271287628,"owners_count":24733424,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","message-attachment","poster","ruby","slack","slack-api","slackbot"],"created_at":"2024-12-11T01:16:38.324Z","updated_at":"2025-08-20T08:31:57.928Z","avatar_url":"https://github.com/rikas.png","language":"Ruby","funding_links":[],"categories":[":hammer_and_wrench: \u0026nbsp; Libraries and SDKs"],"sub_categories":["Ruby"],"readme":"[![Build Status](https://travis-ci.org/rikas/slack-poster.svg?branch=master)](https://travis-ci.org/rikas/slack-poster)\n\n# Slack Poster\n\nslack-poster is a simple gem to make your integration with Slack easier. It supports only incoming communications (from you to Slack).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```console\n$ gem 'slack-poster'\n```\n\nAnd then execute:\n\n```console\n$ bundle\n```\n\nOr install it yourself as:\n\n```console\n$ gem install slack-poster\n```\n\n## Slack setup\n\nThis gem will use a Incoming WebHook integration on Slack. First, you need to create a new Incoming Webhook integration at `https://team-name.slack.com/services/new/incoming-webhook` (where \"team-name\" should be your own team name).\n\n![](http://cl.ly/image/2D2Y0x2B2847/slack_setup1.png)\n\nHit \"Add Incoming WebHooks Integration\" and go to the next screen. Here you can add a name to your\nintegration, customize the username that will post and the icon.\n\n![](http://cl.ly/image/2s3r343K0w3T/slack_setup2.png)\n\nCopy the Webhook URL, because you'll need it. Click \"Save Settings\" and you're done.\n\n## Usage\n\nFirst you have to initialize your poster and then you can use `send_message` to send your message.\n\n```ruby\nposter = Slack::Poster.new(YOUR_WEBHOOK_URL)\nposter.send_message('Hello world!')\n```\n\nYou can use an options array if you don't want to use the default settings:\n\n```ruby\noptions = {\n  icon_url: 'http://example.com/image.png',\n  # or icon_emoji: 'emoji_name',\n  username: 'Tester',\n  channel: '#random'\n}\n```\n\nAnd then use it as a second parameter. Note that every option is optional (no pun intended!).\n\n```ruby\nposter = Slack::Poster.new(YOUR_WEBHOOK_URL, options)\nposter.send_message('Hello with options')\n# posts message 'Hello with options' to #random with the username 'Tester'\n```\n\nOr you can change the options whenever you want\n\n```ruby\nposter = Slack::Poster.new(YOUR_WEBHOOK_URL)\nposter.username = 'TestUser'\nposter.icon_emoji = ':ghost:'\nposter.send_message('Hello World') # =\u003e \"ok\"\n# posts message 'Hello World' to #random with the username 'TestUser' and ghost emoji as avatar\n```\n\nYou can also send a `Slack::Message` object instead of `String`:\n\n```ruby\nmessage = Slack::Message.new('hello slack')\nposter.send_message(message)\n```\n\n### Message attachments\n\nSlack Poster supports message attachments. To do so you have to create `Slack::Attachment` objects\nand then attach them to a `Slack::Message` object. Read the [official documentation](https://api.slack.com/docs/attachments) to understand how attachments work and see different examples of attachments in practice.\n\nYou can build a basic attachment and them attach it to a message and use a poster to post that\nmessage for you:\n\n```ruby\n# As an alternative you could also initialize the attachment with all the fields\n# Slack::Attachment.new(fallback: 'fallback', pretext: 'pretext', ....)\nattachment = Slack::Attachment.new\n\n# This text will be used in clients that don't show formatted text (eg. IRC, mobile notifications)\nattachment.fallback = \"You wouldn't believe who's a mighty pirate!\"\n\nattachment.pretext = 'Arrrgh'\nattachment.color = 'danger' # good, warning, danger, or any hex color code (eg. #439FE0)\n\nattachment.image_url = 'https://pbs.twimg.com/profile_images/446438045945180162/KH34Nkuq.jpeg'\n# you can use thumb_url instead for a small thumb pulled to the right\n\nattachment.text = 'To become a mighty pirate Guybrush had to go through the three trials.'\nattachment.title = 'Mighty pirate'\nattachment.title_link = 'http://scummbar.com/'\n\n# If you want to include author information you can use the following methods:\n# attachment.author_name\n# attachment.author_icon\n# attachment.author_link\n# Check Slack documentation for more info.\n\nmessage = Slack::Message.new('Monkey island news', attachment)\n\n# You can also add the attachment after initializing the message:\n# message = Slack::Message.new('Monkey island news')\n# message.attachments \u003c\u003c attachment\n\nposter = Slack::Poster.new(YOUR_WEBHOOK_URL)\nposter.username = 'Monkey Island Daily'\nposter.icon_emoji = ':monkey_face:'\nposter.send_message(message) # =\u003e \"ok\"\n```\n\nThis will create a message like this one:\n\n![](http://f.cl.ly/items/2S0E03450f2d3h2Y2w26/guybrush1.png)\n\n#### Fields\n\nSlack attachment can contain fields that will be displayed in a table inside the message attachment.\nYou can add fields with `Slack::Attachment#add_field`:\n\n```ruby\nattachment = Slack::Attachment.new\nattachment.add_field('Name1', 'Value1')\nattachment.add_field('Name2', 'Value2')\nattachment.add_field('Name3', 'Value3')\nattachment.add_field('Name4', 'Value4')\n\nmessage = Slack::Message.new('What a beautiful table of names and values', attachment)\n\nposter = Slack::Poster.new(YOUR_WEBHOOK_URL)\nposter.send_message(message) # =\u003e \"ok\"\n```\n\nYou may notice that the message will display with a vertical list of fields. You can have them side\nby side giving a third boolean parameter (is it a short field?).\n\n```ruby\nattachment = Slack::Attachment.new\nattachment.add_field('Name1', 'Value1', true)\nattachment.add_field('Name2', 'Value2', true)\nattachment.add_field('Name3', 'Value3')\nattachment.add_field('Name4', 'Value4')\n```\n\nThis way the first two field will be displayed in the same row.\n\n## Contributing\n\n1. Fork it ( http://github.com/rikas/slack-poster/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frikas%2Fslack-poster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frikas%2Fslack-poster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frikas%2Fslack-poster/lists"}