Giter VIP home page Giter VIP logo

slackwebhook's Introduction

Shooker - Slack WebHooks made crazy simple

Incoming & Outgoing Webhooks are now supported!

Setup on Slack

Incoming

Navigate to https://TEAMNAME.slack.com/services/new and choose to add a new incoming WebHook.

You only really need the Webhook URL but feel free to adjust the default username and image.

Outgoing

alt example

Navigate to https://TEAMNAME.slack.com/services/new and choose to add a new outgoing WebHook.

For this page note the following fields:

  • Channel: You can use any or select a specific channel. The benefit of choosing a channel is that you will not have to specify trigger words in the next field.
  • Trigger Word(s): If you chose a specific channel, you can skip this setup, otherwise place all words you plan on using for triggers in this field with commas separating them.
  • URL(s): Place the location of the PHP file you are going to include Shooker on here.
  • Token: Note this value because you will need to add it within the class initialization.
  • Descriptive Label: Optional and only used to provide context within Slack integrations list.
  • Customize Name: Use whatever name you want to display within the Slack client along with your responses from PHP.
  • Customize Icon: Again, whatever you want here.
  • Attachments: An array of additional information to attach files or style more information. See documentation.

Setup within PHP

Just include the main class file and then set up Shooker like so:

Incoming

```php //Initialize class with the token from Slack $shkr = new SlackWebhook();

$shkr->setupIncoming('');

//Send a message (message, channel, username, icon, array $attachments) $shkr->sendMessage("Your message here", "Random","Mr. Bot", ":ballot_box_with_check:");


<h4>Outgoing</h4>
```php
//Initialize class with the token from Slack
$shkr = new Shooker();

$shkr->setupOutgoing('<YOUR TOKEN HERE>');

//Add a trigger based on keyword "test"
$testTrigger = $shkr->addTrigger("test");

//When this trigger is hit, perform this function
$testTrigger->addAction(function($paramString, $user, $channel){
return "params: ".$paramString." user: ".$user." channel: ".$channel;
});

//This function is required to listen for triggers within Slack client, make sure to call after all triggers are added
$shkr->listen();

Examples

More examples here with source code »

THAT'S IT!

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.