Code Monkey home page Code Monkey logo

slack's Introduction

Slack for PHP

Build Status Scrutinizer Code Quality StyleCI

A simple PHP package for sending messages to Slack with incoming webhooks, focussed on ease-of-use and elegant syntax. Note: this package is no longer being actively maintained.

Requirements

  • PHP 5.5, 5.6, 7.0 or HHVM

Installation

You can install the package using the Composer package manager. You can install it by running this command in your project root:

composer require maknz/slack

Then create an incoming webhook on your Slack account for the package to use. You'll need the webhook URL to instantiate the client (or for the configuration file if using Laravel).

Basic Usage

Instantiate the client

// Instantiate without defaults
$client = new Maknz\Slack\Client('https://hooks.slack.com/...');

// Instantiate with defaults, so all messages created
// will be sent from 'Cyril' and to the #accounting channel
// by default. Any names like @regan or #channel will also be linked.
$settings = [
	'username' => 'Cyril',
	'channel' => '#accounting',
	'link_names' => true
];

$client = new Maknz\Slack\Client('https://hooks.slack.com/...', $settings);

Settings

The default settings are pretty good, but you may wish to set up default behaviour for your client to be used for all messages sent. All settings are optional and you don't need to provide any. Where not provided, we'll fallback to what is configured on the webhook integration, which are managed at Slack, or our sensible defaults.

Field Type Description
channel string The default channel that messages will be sent to
username string The default username for your bot
icon string The default icon that messages will be sent with, either :emoji: or a URL to an image
link_names bool Whether names like @regan or #accounting should be linked in the message (defaults to false)
unfurl_links bool Whether Slack should unfurl text-based URLs (defaults to false)
unfurl_media bool Whether Slack should unfurl media-based URLs, like tweets or Youtube videos (defaults to true)
allow_markdown bool Whether markdown should be parsed in messages, or left as plain text (defaults to true)
markdown_in_attachments array Which attachment fields should have markdown parsed (defaults to none)

Sending messages

Sending a basic message (preview)

$client->send('Hello world!');

Sending a message to a non-default channel

$client->to('#accounting')->send('Are we rich yet?');

Sending a message to a user

$client->to('@regan')->send('Yo!');

Sending a message to a channel as a different bot name (preview)

$client->from('Jake the Dog')->to('@FinnTheHuman')->send('Adventure time!');

Sending a message with a different icon (preview)

// Either with a Slack emoji
$client->to('@regan')->withIcon(':ghost:')->send('Boo!');

// or a URL
$client->to('#accounting')->withIcon('http://example.com/accounting.png')->send('Some accounting notification');

Send an attachment (preview)

$client->to('#operations')->attach([
	'fallback' => 'Server health: good',
	'text' => 'Server health: good',
	'color' => 'danger',
])->send('New alert from the monitoring system'); // no message, but can be provided if you'd like

Send an attachment with fields (preview)

$client->to('#operations')->attach([
	'fallback' => 'Current server stats',
	'text' => 'Current server stats',
	'color' => 'danger',
	'fields' => [
		[
			'title' => 'CPU usage',
			'value' => '90%',
			'short' => true // whether the field is short enough to sit side-by-side other fields, defaults to false
		],
		[
			'title' => 'RAM usage',
			'value' => '2.5GB of 4GB',
			'short' => true
		]
	]
])->send('New alert from the monitoring system'); // no message, but can be provided if you'd like

Send an attachment with an author (preview)

$client->to('@regan')->attach([
	'fallback' => 'Keep up the great work! I really love how the app works.',
	'text' => 'Keep up the great work! I really love how the app works.',
	'author_name' => 'Jane Appleseed',
	'author_link' => 'https://yourapp.com/feedback/5874601',
	'author_icon' => 'https://static.pexels.com/photos/61120/pexels-photo-61120-large.jpeg'
])->send('New user feedback');

Advanced usage

Markdown

By default, Markdown is enabled for message text, but disabled for attachment fields. This behaviour can be configured in settings, or on the fly:

Send a message enabling or disabling Markdown

$client->to('#weird')->disableMarkdown()->send('Disable *markdown* just for this message');

$client->to('#general')->enableMarkdown()->send('Enable _markdown_ just for this message');

Send an attachment specifying which fields should have Markdown enabled

$client->to('#operations')->attach([
	'fallback' => 'It is all broken, man',
	'text' => 'It is _all_ broken, man',
	'pretext' => 'From user: *JimBob*',
	'color' => 'danger',
	'mrkdwn_in' => ['pretext', 'text']
])->send('New alert from the monitoring system');

Explicit message creation

For convenience, message objects are created implicitly by calling message methods on the client. We can however do this explicitly to avoid hitting the magic method.

// Implicitly
$client->to('@regan')->send('I am sending this implicitly');

// Explicitly
$message = $client->createMessage();

$message->to('@regan')->setText('I am sending this explicitly');

$message->send();

Attachments

When using attachments, the easiest way is to provide an array of data as shown in the examples, which is actually converted to an Attachment object under the hood. You can also attach an Attachment object to the message:

$attachment = new Attachment([
	'fallback' => 'Some fallback text',
	'text' => 'The attachment text'
]);

// Explicitly create a message from the client
// rather than using the magic passthrough methods
$message = $client->createMessage();

$message->attach($attachment);

// Explicitly set the message text rather than
// implicitly through the send method
$message->setText('Hello world')->send();

Each attachment field is also an object, an AttachmentField. They can be used as well instead of their data in array form:

$attachment = new Attachment([
	'fallback' => 'Some fallback text',
	'text' => 'The attachment text',
	'fields' => [
		new AttachmentField([
			'title' => 'A title',
			'value' => 'A value',
			'short' => true
		])
	]
]);

You can also set the attachments and fields directly if you have a whole lot of them:

// implicitly create a message and set the attachments
$client->setAttachments($bigArrayOfAttachments);

// or explicitly
$client->createMessage()->setAttachments($bigArrayOfAttachments);
$attachment = new Attachment([]);

$attachment->setFields($bigArrayOfFields);

Contributing

If you're having problems, spot a bug, or have a feature suggestion, please log and issue on Github. If you'd like to have a crack yourself, fork the package and make a pull request. Please include tests for any added or changed functionality. If it's a bug, include a regression test.

slack's People

Contributors

anahkiasen avatar drewbroadley avatar freekmurze avatar georgecoca avatar iwiznia avatar jwcobb avatar maknz avatar mvatansever avatar qmcree avatar rajabishek avatar rap2hpoutre avatar stefanzweifel avatar tzookb avatar vysinsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slack's Issues

StyleCI for better Code-Style

@maknz cause of the fallen keyword "code-style" in PR #44 why not using StyleCI? https://styleci.io/
It's free for open source and also used by laravel core - a simple config could look like:

preset: laravel

risky: false

linting: true

And you can enable auto PR & auto merge & disable CI - this will fix all CS issues in PRs on the fly and no one has to care about CodeStyle.

Nexylan namespace move (used by slack-bundle)

FYI, we move a copy of this abandoned library under the Nexylan namespace: https://github.com/nexylan/slack

The 1.x branch is not touched, with same code and release so the migration will be smooth.

The unreleased change of this library plus other ones are under the v2.0.0.

The nexylan/slack-bundle now require this package and the v2.0 release support is in progress.

Ref: https://twitter.com/soullivaneuh/status/953671333279354880

@maknz I let you update the README to add the reference if you want to.

Regards.

Adding as_user and ability to change channel topics

Are these things that would be easily done in the future. I think they'd be a great addition :) Any insight or help getting this accomplished would be hugely appreciated.

I think enabling as_user would be great so you don't see BOT for every post. (if this can't be done I apologize)

And changing channel topics would be great for Slack community mods whom want to schedule those for whatever particular reason.

Cant use \n in Message Attachment

Hi, I am not sure why new line are not working.

I added \n to my 'text' but it didn't produce a new line.

By the way, this is an awesome package.

Sending repeats infinitely

Interesting things happening if you write something like this in your errors Handler class:

public function report(Exception $e)
    {
        if (app()->environment() == 'production') {
            Slack::send('*' . \Request::url() . '* ' . (string)$e);
        }

        return parent::report($e);
    }

it starts repeats infinitely. How can I investigate if it's package or laravel or forge problem?

Having trouble installing

I ran composer require maknz/slack and all of the src was added to the vendor folder. I have created a file called slackTest.php which includes the basic usage code (with my hooks url) I am getting the error: Fatal error: Class 'Maknz\Slack\Client' not found in /home/ubuntu/workspace/vendor/maknz/slack/slackTest.php on line 3.

Alternative to autoload

Hi,

is there any option to use this script without autoload?

I only have a usual webspace ...

Thank you
Zoker

Are there markdown custom message to laravel 5.1 in this library?

I would like to use something like this.

return (new SlackMessage())
        ->from("New user request on " . config("app.name"))
        ->content(":bangbang: An user has requested a new feedback on " . config("app.name"))
        ->attachment(function ($attachment) use ($notifiable) {
            $attachment->title("Feedback ID: {$notifiable->uuid}")
                ->content("**You can moderate this feedback right away**")
                ->markdown(["title", "text"])
                ->fields([
                    "Request from" => "{$notifiable->user->name} (ID: {$notifiable->user->uuid})",
                    "Request topic" => "{$notifiable->topic->name}",
                ]);
        });

A facade root has not been set in Laravel 5.4

I really could use some help with this one.

I'm using https://github.com/maknz/slack without issue when using SYNC (queue).

When I move to production w/ REDIS queue the code does not work.

A controller fires an event. The event listener fires and calls the code, i.e.

Slack::setDefaultUsername($username);

However, I get the following error in my logs which is a result of an exception being thrown "A facade root has not been set."

[2017-02-16 04:44:26] production.WARNING: AnalyticsService failed to notify to Slack. {"message":"A facade root has not been set."}

Can somebody help me understand what "A facade root has not been set." means and why this issue is only happening when I use REDIS versus SYNC?

Thank you very much in advance!

Reques Messages

Hi, there amazing work. i made little program with your codes very good but i want to see all sent messages before on my view/messages. Can you show me any kind of thing like that or can you rotate me to a link ?

icon problems

so having some problems with the icon feature

setting it via the defaults, or with the ->withIcon() method is not setting the icon on messages sent.

Using the v1.7.0 from packagist

Send endpoint with a method

I need some way to override default endpoint, with a method, like:

Slack::endpoint($some_url)->to('#channel');

For dynamic slack messages

Make a new tag for last features!

I decided to use bundle for symfony and it use version 1.7.0 which has last commit in 2015! I even can't set ts field in attachment!
Please do it!

Missing features in attachment

The attachment is missing some features like footer, footer_icon and ts.
Also the actions (buttons) are not possible at the moment.

README improvements

I want to make a number of improvements to the README for the next major version:

  • Think about splitting the documentation out rathe than dumping it all in the README. Laravel integration could be its own md file.
  • Make the examples a bit more real world and interesting. They're a little lazy at the moment.

Slack skips messages if sending "too many"

Hi, first of all great library, we're really happy to be able to integrate it into our projects. However, we are experiencing a minor problem: if we send messages very quickly Slack seems to stumble and skip some of them.

Right now I'm getting around it by merging the messages into larger ones, but maybe this could be handled in the package itself? (Just an idea)

Add dev settings for default channel

I'm looking for a way to be able to test Slack messages from PHP without disturbing "real" channels.

I'm thinking about two options: dev_channel (string) and dev_env (bool).

  • dev_channel: Specifies a channel to post when the dev_env is enabled. Will override all channel global or local (on message) settings.
  • dev_env: Activate the dev env and the dev_channel option. Could be use with framework envs for example.

Code example:

$settings = [
    'username' => 'Cyril',
    'channel' => '#accounting',
    'dev_channel' => '#test',
    'dev_env' => true,
    'link_names' => true
];

$client = new Maknz\Slack\Client('http://your.slack.endpoint', $settings);

$client->send('Hello world!'); // Will send to #test
$client->to('#other_channel')->send('Are we rich yet?'); // Will send to #test too

What do you think? I'll work on a PR for that.

Ensure utf8

If non-utf8 data is provided, the json encoding fails and an Exception is thrown.

Instead the data should be converted to utf8, if non-utf8 data is provided.

Laravel 5 support

It's my intention to support Laravel 5 ASAP. There is some documentation about package development up, but I've yet to find any kind of upgrade guide. The only problematic thing is config publishing which has changed, I'll need to sort out a backwards-compatible way of doing that.

If there's any L5 experts, feel free to do a PR, but I'll be looking into it anyway.

can't generate config file

I have a brand new installation of Laravel 5.2 and after adding the package with composer require maknz/slack (Using version ^1.7 for maknz/slack) and then trying to run php artisan vendor:publish --provider="Maknz/Slack/SlackServiceProviderLaravel5" I get the following output:

Nothing to publish for tag [].

Did I miss something?

Preventing application slowing down

Hi Maknz,

thanks for the nice PHP package. Since yesterday I'm using it in my Laravel app.

Everything is working fine. However I'm noticing that my app is around 300ms per request slower with Slack on. In New Relic I also see higher load times due to Slack.

It seems that it is waiting for the response of the Slack webhook before continuing the rest of the code. I'm using the following code:
Slack::send($message);

Is there a way that the Laravel app doesn't have to wait till the Slack send command has finished? For example, can I queue the message?

Cheers, Klemens

Can't use with this SDK

Hi..
I get this error:

 Catchable fatal error: Argument 1 passed to React\Promise\Promise::__construct() must be callable, null given, called in /home/yakir/slack-app/vendor/react/promise/src/Deferred.php on line 25 and defined in /home/yakir/slack-app/vendor/react/promise/src/Promise.php on line 16

That's the code:

use \Maknz\Slack\Client;

include( __DIR__ . '/vendor/autoload.php' );
$settings = [];
$client = new Client( 'my.endpoint', $settings );
$client->send( 'Test msg' );

How to upload files

Hey man,

So been using your Slack Package for Laravel awhile now and been loving the simplicity of it all.

I have had a new request though that I am having a hard time figuring out how to deal with. I have been asked to send some alerts as jpg images. I know the slack API has this ability ( https://api.slack.com/methods/files.upload ) but I do not see anything in your code that deals with this. Am I just blind or does it not exist?

If it does not exist can you point me in the right direction on where to add this to your codebase.

Cheers

Ryan Stephens

(!) Abandoned! See fork php-slack/slack

Hi, @maknz !

Thank you for this great package! And for this big job!

As you say in "Maintance notice" commit: "this package is no longer being actively maintained".

But its really hard to find this message (I spend much time myself for understand, that this package abandoned).

It would be better to mark it as "abandoned" on Packagist.
And archive repo on GitHub, so it will become read-only.

I make a fork php-slack/slack & will support this great package for open source community.

.

Decouple input arrays from Slack payload format

At the time, having the input arrays into Attachment and friends be exactly the same as the Slack payload format was good, but now it's a hinderance when we want to be smarter about a few things, e.g. using timestamp rather than ts and a DateTime rather than an int UNIX timestamp.

It's made testing very difficult as a result, so I'll figure out a different way to do the functional tests, other than "these two arrays must match exactly" which is a huge PITA. It'll probably be inspecting each element individually, more verbose but no headaches.

Better attachment action features

We've got the base for attachment actions in master (yet unreleased) thanks to @janek2012. I'd like to go further and allow for developers to easily respond to actions when called back by Slack.

I'd also like to simplify the class names (including the existing ones) so things are more fluid. Action rather than AttachmentAction for example.

Support message building

I do not personally understand why the Message class is tightly coupled with the Client class. It doesn't make sense to me that it can send itself.
I think that if you want to have an explicit message you should explicitly send it.
It also makes it hard to separate the message creation logic from the sending logic since you would have to pass a useless client that you won't use everywhere.
I propose adding HeadlessMessage or a similar class that doesn't require the client in it's constructor.

Markdown options

Hi,

First, thanks for the work in this package, really nice.
Have you thought about adding the markdown formatting options (mrkdwn, mrkdwn_in) to the message and attachments?
https://api.slack.com/docs/formatting

I could do a PR, but just in a couple of weeks.

Defer service provider registration

@maknz,

Wouldn't deferring the registration by setting $defer = true be a better default for the project?
This seems to be the default behavior for most third-party providers and allows for better app performance.

As an example, we've been using your package on a big project, but only part of it should actually integrate with Slack (we're using it for debugging purposes). Most of our users won't even have the ability to trigger the Slack integration, but the service provider is being loaded nonetheless.

Thanks for your time and for a great package.

Mistake in Slack/Client.php

if (isset($attributes['channel'])) $this->setChannel($attributes['username']);

This sets the username as the channel and generates an error when posting to Slack.

Explicitly setting channel and username

When you set up a webhook on slack it asks you the username and channel to use. You only need to include those variables in the post request if you want to overwrite what you have set.

Shouldn't Client.php have them undefined by default rather than explicitly set, and then only send them if they have been set with setChannel or setUsername?

Set (default) attachment field value for every message

I would like to add a field environment to every attachment containing the environment (dev, staging, production, ...) of the app from which the message is sent. I think this cannot be done with the current codebase, does it? I don't want to add it manually for every type of message/attachment that is sent...

Use PHP HTTP instead of native Guzzle

PHP HTTP allows to handle multiple HTTP framework using PSR-7 compliant generic message building.

This avoid dependencies issues for people using your project and another version of Guzzle on their projects.

What do you think?

Success and error callbacks

This is especially important if an error has occurred, which happens frequently when the correct channel is not specified. Right now the error is just thrown, but an error callback would be a much more graceful way of handling it.

Markdown in fields option does not work

With the following message creation and sending:

public function sendNewTicket(Ticket $ticket)
{
    $message = $this->slack->createMessage();

    $fallback = sprintf(
        'Ticket #%d: %s - %s',
        $ticket->getId(),
        $ticket->getTitle(),
        $this->router->generate('ticket_show', ['id' => $ticket->getId()], UrlGeneratorInterface::ABSOLUTE_URL)
    );

    $message
        ->to(self::CHANNEL)
        ->attach(new Attachment([
            'fallback'   => $fallback,
            'title'      => sprintf('#%d: %s', $ticket->getId(), $ticket->getTitle()),
            'title_link' => $this->router->generate('ticket_show', ['id' => $ticket->getId()], UrlGeneratorInterface::ABSOLUTE_URL),
            'color'      => $this->getPriorityColor($ticket->getPriority()),
            'fields'     => [
                [
                    'title' => 'Author',
                    'value' => sprintf(
                        '<%s|%s>',
                        $ticket->getAuthor()->getFullnameWithUsername(),
                        $this->router->generate('admin_user_show', ['id' => $ticket->getAuthor()->getId()], UrlGeneratorInterface::ABSOLUTE_URL)
                    ),
                    'short' => true,
                ],
                [
                    'title' => 'Organization',
                    'value' => $ticket->getOrganization() ? $ticket->getOrganization()->getName() : 'N/A',
                    'short' => true,
                ],
                [
                    'title' => 'Category',
                    'value' => $ticket->getCategory()->getName(),
                    'short' => true,
                ],
                [
                    'title' => 'Subject',
                    'value' => $ticket->getTitle(),
                    'short' => true,
                ],
                [
                    'title' => 'Priority',
                    'value' => $this->getPriorityStr($ticket->getPriority()),
                    'short' => true,
                ],
                [
                    'title' => 'Server',
                    'value' => $ticket->getServer() ? $ticket->getServer()->getName() : 'N/A',
                    'short' => true,
                ],
            ],
            'mrkdwn_in'   => ['fields'],
        ]))
    ;

    $this->slack->sendMessage($message);
}

I got the following result:

image

The Author fields show the raw markdown instead the needed link.

Is that an issue or a misconfiguration?

Support multiple teams

We need to support multiple teams. As part of the 2.0 release, we'll be moving away from simply an 'endpoint' and have a first-class Team object. A client can be instantiated with one or more teams. Each team will have a default channel, and a name which can be used to refer to that team, e.g. 'mycompany'.

Example usage:

$team = new Team(['name' => 'mycompany', 'webhook' => 'https://hooks.slack.com/...', 'default_channel' => '#general']);
$client = new Client($team);
$client->send('Hello'); // sends to the one team configured, to the default channel of #general
$teams = [
  new Team(['name' => 'company1', 'webhook' => 'https://hooks.slack.com/...', 'default_channel' => '#engineering']),
  new Team(['name' => 'company2', 'webhook' => 'https://hooks.slack.com/...', 'default_channel' => '#devops'])
];

$client = new Client($teams);
$client->team('company1')->send('hello company1'); // #engineering in company1
$client->team('company2')->send('hello company2'); // #devops in company2

The full lead up discussion to the feature is over at #44.

I plan to work on this next weekend.

Support for php 5.4

Hi there,
I tried using this component with php 5.4 pulling it from composer like you suggested. The messages could be sent to slack but as soon as the code returned, I would get a crash on curl_reset function call.

I finally realized that the version of guzzle that composer pulled automatically in regards to the slack composer.json definition was version 6, not version 5. So I have to manually specify guzzle version 5 into MY composer.json file. No brainer.

With all this said and done, that would have been REALLY nice (READ: helpful) to have this info into the README file of your project. For example, a warning statement following the composer require maknz/slack snippet.

Regards,

Help request

Hi, first of all thanks for this easy to use package!
I want to attempt to use this to send messages with a slack app bot (via bot token) instead of using a incoming webhook.

Is this somehow supported?
I'm using a different package to handle the required websocket connection for receiving incoming messages but prefer to use this sender for outgoing messages

Thanks in advance for any help :)

Message object should be returned from send

At the moment, if you do $client->send('message') directly, you get the Message object back. But, if you do additional steps, for example $client->to('#channel')->send('message'), you don't get the Message object back, you get null. This should change -- we don't document nor test the return value of these, so it shouldn't constitute a breaking change.

If we're going to be bumping to 2.0 for multiple teams, I'll probably bundle it in with that breaking change though, just to be sure.

No way to specify a callback_id for Attachments

Currently there is no callback_id field on the Attachment class. This results in receiving "Drat! callback_id is missing, so that didn’t work." when using interactive buttons in messages.

The library caused child processes to throw cURL error

The error thrown is:

[Guzzle\Http\Exception\CurlException] [curl] 35: [url] https://someservice.com/api

This only comes if the notification is being sent from a child-process of the parent process which initially used the library. In my case, I'm running a web socket server, which starts child processes for other nodes like a load balancer or the workers for example. The Slack notification was used in the main process twice - when booting and once booted. In between those two notifications I start the child processes (so it's not the first instance causing problems but rather the child process). Whenever a child process tries to send a notification, the above error is thrown. It is not only Slack - my email provider call did throw the exact same error after calling Slack in the main process.

The project I had the trouble is built in Laravel 5.0 and I used the facade to send the notifications in each place \Slack::send('message');. Removing the Slack notifications (and the package completely) did sort the problem and I can reach out to my email provider again.

publish in Laravel5.1

php artisan vendor:publish --provider=Maknz\Slack\SlackServiceProvider not works in Laravel5.1.

php artisan vendor:publish --provider=Maknz\Slack\SlackServiceProviderLaravel5 works.

Doesn't handle Slacks rate limits.

Ran into an interesting bug tonight. I received an email from slack that said the following:

Hi there,
We're writing to let you know that one of your Incoming-Webhook integrations was automatically disabled on February 16, 2016 at 08:52 PM CST. It was sending a lot of messages – over 3,600 in the 5 minutes directly before it was disabled.

Since Slack is primarily a tool for humans to communicate with one another, this is a preventative measure to make sure that an out-of-control script doesn't compromise the quality of your archive or make it difficult for you to talk to one another.

To prevent this from happening in the future, you'll want to implement error checking in your integration. When we detect that one of your integrations might be running out of control (current thresholds are more than one message per second over a sustained period of time), we'll return an HTTP 429 and a chunk of JSON with some more details.

  {
      "ok": false,
      "count_hour_ago": 400,
      "count_minute_ago": 100,
      "count_second_ago": 5
  }

When we send one of these error messages back, it also means that your message did not make it into Slack – you'll want to queue it up and try again in a few seconds. You'll find more details about our rate limits here:

https://api.slack.com/docs/rate-limits

Our system had a hardware issue and linux went into read only mode causing thousands of exceptions to be thrown.

After the first thousand exceptions got logged, I started getting a few of these scattered in my log
'Uncaught exception with message 'Client error response [url] https://hooks.slack.com/services/REDACTED_MY_KEY/REDACTED_MY_KEY [status code] 429 [reason phrase] Too Many Requests'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.