Download the PHP package lisennk/laravel-slack-events-api without Composer

On this page you can find all versions of the php package lisennk/laravel-slack-events-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-slack-events-api

:bell: Slack Events API for Laravel :bell:

Latest Stable Version License Build Status

Work with Slack Events API as easily as with native Laravel 7 events and event listeners.

:link: Reasons to use this package for the Slack Events API:

:earth_americas: Installation

1) Require the package with Composer

2) If you're using Laravel version 5.5 or higher, the SlackEventsServiceProvider will be automatically discovered. Get started fast!

3) If you're using a version of Laravel lower than 5.5, you'll still have to register the service provider manually. Open config/app.php and add \Lisennk\LaravelSlackEvents\SlackEventsServiceProvider::class to the providers[] array.

For example:

If you are using Laravel 5.3 or higher, you will find a comment in config/app.php with text like /* Package Service Providers... */, which can help you find the right place.

4) Publish the config file

Choose the option for the Service Provider, or find slack-events in the Tag: list at the bottom.

Next we'll configure some settings to use the Slack API.

5) Create an App or Open an Existing One If you want to work with Slack's new Workspace Apps, read over the information in the Developer Preview for Workspace Apps, and create a new workspace token App to get started.

If you're not using a Workspace App, open the Slack Apps page and create a new user token App.

If you want to modify an existing app to use with Slack-Events, you can find both Workspace Token Apps and User Token Apps on the Your Apps page.

6) Once you've created or opened your app you should see the Basic Information page. Scroll down to the "App Credentials" section, and copy the Verification Token at the bottom.

verification_token

Open .env and paste your Verification Token under the 'SLACK_EVENT_TOKEN' key:

7) Now open the "Event Subscriptions" page. Here you must enable events, add events you wish to listen for and set Request URL. Request URL is the 'route' key in your config/slackEvents.php file:

'route' works just like built-in Laravel routes, so if your site URL is https://example.com and your 'route' is /api/slack/event/fire, then your full Request URL is https://example.com/api/slack/event/fire. You can leave it as-is or set your own route instead of the default /api/slack/event/fire.

This package will do all verification and "challenge" work for you, so you only need to set your Request URL — by default it's:

request_url

:fork_and_knife: Usage

Also see: Quick Example.

Thanks to this package, working with Slack Events is the same as working with Laravel Events. So if you haven't read the Laravel Events documentation or Slack Events API documentation yet, it's highly recommended to read them before you start.

This package provides a separate Laravel Event class for every Slack event that has Slack Events API support. For example, the reaction_added event implementation is the Lisennk\LaravelSlackEvents\Events\ReactionAdded class.

Also see: Full list of supported events and their classes.

Each Event class has public fields representing the real Slack Event request:

Field Description
public $token; Verification token
public $team_id; The unique identifier for the team where this event occurred.
public $api_app_id The unique identifier for the application this event is intended for.
public $event; Contains the inner set of fields representing the event that's happening.
public $data Alias for public $event field. Makes code more clear if your event object name is $event too, so you can write $event->data instead of $event->event.
public $type; This reflects the type of callback you're receiving.
public $authed_users; An array of string-based User IDs.

For example, if you want to get the reaction name from reaction_added event, you can get it from the ReactionAdded event class like this:

So, suppose we want to make a reaction_added Slack Event listener. What do we need to do?

Example

1) Open the App/Listeners directory (or create it if it doesn't exist). Now create a new file and call it ReactionAddedListener.php. Paste in this code:

As you can see, it's a normal event listener. You might notice that the listener implements ShouldQueue — it's useful because our app must respond to the request within three seconds in order to adhere to the Slack Events API terms. If you want some long-running stuff in your event listener, you need to configure a queue.

2) Now we add this listener to /App/Providers/EventServiceProvider.php like any other event listener:

3) Profit! You are ready to go.

:cherries: Full list of supported events and their classes

Event Name Event Class
channel_archive \Lisennk\LaravelSlackEvents\Events\ChannelArchive
channel_created \Lisennk\LaravelSlackEvents\Events\ChannelCreated
channel_deleted \Lisennk\LaravelSlackEvents\Events\ChannelDeleted
channel_history_changed \Lisennk\LaravelSlackEvents\Events\ChannelHistoryChanged
channel_joined \Lisennk\LaravelSlackEvents\Events\ChannelJoined
channel_rename \Lisennk\LaravelSlackEvents\Events\ChannelRename
channel_unarchive \Lisennk\LaravelSlackEvents\Events\ChannelUnarchive
dnd_updated \Lisennk\LaravelSlackEvents\Events\DndUpdated
dnd_updated_user \Lisennk\LaravelSlackEvents\Events\DndUpdatedUser
email_domain_changed \Lisennk\LaravelSlackEvents\Events\EmailDomainChanged
emoji_changed \Lisennk\LaravelSlackEvents\Events\EmojiChanged
file_change \Lisennk\LaravelSlackEvents\Events\FileChange
file_comment_added \Lisennk\LaravelSlackEvents\Events\FileCommentAdded
file_comment_deleted \Lisennk\LaravelSlackEvents\Events\FileCommentDeleted
file_comment_edited \Lisennk\LaravelSlackEvents\Events\FileCommentEdited
file_created \Lisennk\LaravelSlackEvents\Events\FileCreated
file_deleted \Lisennk\LaravelSlackEvents\Events\FileDeleted
file_public \Lisennk\LaravelSlackEvents\Events\FilePublic
file_shared \Lisennk\LaravelSlackEvents\Events\FileShared
file_unshared \Lisennk\LaravelSlackEvents\Events\FileUnshared
group_archive \Lisennk\LaravelSlackEvents\Events\GroupArchive
group_close \Lisennk\LaravelSlackEvents\Events\GroupClose
group_history_changed \Lisennk\LaravelSlackEvents\Events\GroupHistoryChanged
group_open \Lisennk\LaravelSlackEvents\Events\GroupOpen
group_rename \Lisennk\LaravelSlackEvents\Events\GroupRename
group_unarchive \Lisennk\LaravelSlackEvents\Events\GroupUnarchive
im_close \Lisennk\LaravelSlackEvents\Events\ImClose
im_created \Lisennk\LaravelSlackEvents\Events\ImCreated
im_history_changed \Lisennk\LaravelSlackEvents\Events\ImHistoryChanged
im_open \Lisennk\LaravelSlackEvents\Events\ImOpen
link_shared \Lisennk\LaravelSlackEvents\Events\LinkShared
message \Lisennk\LaravelSlackEvents\Events\Message
message.channels \Lisennk\LaravelSlackEvents\Events\MessageChannels
message.groups \Lisennk\LaravelSlackEvents\Events\MessageGroups
message.im \Lisennk\LaravelSlackEvents\Events\MessageIm
message.mpim \Lisennk\LaravelSlackEvents\Events\MessageMpim
pin_added \Lisennk\LaravelSlackEvents\Events\PinAdded
pin_removed \Lisennk\LaravelSlackEvents\Events\PinRemoved
reaction_added \Lisennk\LaravelSlackEvents\Events\ReactionAdded
reaction_removed \Lisennk\LaravelSlackEvents\Events\ReactionRemoved
star_added \Lisennk\LaravelSlackEvents\Events\StarAdded
star_removed \Lisennk\LaravelSlackEvents\Events\StarRemoved
subteam_created \Lisennk\LaravelSlackEvents\Events\SubteamCreated
subteam_self_added \Lisennk\LaravelSlackEvents\Events\SubteamSelfAdded
subteam_self_removed \Lisennk\LaravelSlackEvents\Events\SubteamSelfRemoved
subteam_updated \Lisennk\LaravelSlackEvents\Events\SubteamUpdated
team_domain_change \Lisennk\LaravelSlackEvents\Events\TeamDomainChange
team_join \Lisennk\LaravelSlackEvents\Events\TeamJoin
team_rename \Lisennk\LaravelSlackEvents\Events\TeamRename
url_verification \Lisennk\LaravelSlackEvents\Events\UrlVerification
user_change \Lisennk\LaravelSlackEvents\Events\UserChange

:hibiscus: Contributing

Feel free to star this repository, create pull requests or issues, and report typos.

:books: Reference


All versions of laravel-slack-events-api with dependencies

PHP Build Version
Package Version
Requires illuminate/http Version ^5.4||^6.2||^7.2||^8.0
illuminate/support Version ^5.4||^6.2||^7.2||^8.0
illuminate/routing Version ^5.4||^6.2||^7.2||^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lisennk/laravel-slack-events-api contains the following files

Loading the files please wait ....