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.
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.
Just include the main class file and then set up Shooker like so:
```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();