PHP code example of portlandlabs / slackbot

1. Go to this page and download the library: Download portlandlabs/slackbot library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

portlandlabs / slackbot example snippets


$bot->commands()->addCommand(CustomCommand::class);

(new \PortlandLabs\Slackbot\Command\DefaultProvider())->register($bot);

    $this->bot->feignTyping($channel, $message)
    

    $this->bot->rtm()->sendMessage($channel, $message)
    

    $api = $this->bot->api();
    $api->getBuilder()->send($message)->to($channel)->withIcon($icon)->execute($api);
 
    // Update the previously sent message
    $api->getBuilder()->update()->withText($newText)->execute($api);
    

    $payload = new ChatPostMessagePayload();
    $this->prepare($payload);
 
    // Send the payload
    $payloadResponse = $this->bot->api()->send($payload);
    
bash
$ php slackbot.php