2017 © Pedro Peláez
 

project slack-bundle

This bundle provides the basic functionality to quickly connect your Slack Bot with your symfony project via slash commands.

image

gotoemma/slack-bundle

This bundle provides the basic functionality to quickly connect your Slack Bot with your symfony project via slash commands.

  • Thursday, May 17, 2018
  • by gotoemma
  • Repository
  • 0 Watchers
  • 0 Stars
  • 225 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 88 % Grown

The README.md

SlackBundle - Basic implementation for Slack Slash Commands

This bundle provides the basic functionality to quickly connect your Slack Bot with your symfony project via slash commands., (*1)

Simply create a class, implement the provided CommandInterface and tag it as "slack.command" and your slash command is ready to go!, (*2)

SlackBundle validates the token sent with the request to ensure this request comes authorized and from Slack. Then it searches for an service tagged with slack.command which tells to supported a given request. After collecting data from all suppported services it will respond to slack., (*3)

The default list command, (*4)

Dependencies

  • Symfony 3.1
  • PHP 7.0

Setup

  • Create your own command class and implement Gotoemma\SlackBundle\Service\CommandInterface
  • Tag your service with "slack.command"
  • Go to https://api.slack.com/apps and create an app
  • Add the clientId, clientSecret and token to your the config.yml
  • Setup your first slash command and set https://your.url/webhook/slack as webhook url (use POST request)

Your projects main composer.json

"repositories": [
        {
            "type": "git",
            "url": "https://bitbucket.org/gotoemma/slack-bundle.git"
        }
    ],

Then type composer require gotoemma/slack-bundle, (*5)

app/config/config.yml

slack:
  client_id:      "%slack_client_id%"
  client_secret:  "%slack_client_secret%"
  token:          "%slack_token%"

app/config/routing.yml

Load the routing for upload action that is configured in UploadAction class as annotation on __invoke() method., (*6)

slack_action:
    resource: '@SlackBundle/Action/'
    type:     'annotation'

Your first command provider

With SlackBundle ships one default command: /list This command lists all registered commands in slack. The only thing you need to do is to add the slash command on api.slack.com/apps., (*7)

This command can be used as a basis for your first custom command also., (*8)

<?php

namespace YourNamespace\YourBundle\Provider;

use Doctrine\Common\Collections\ArrayCollection;
use Gotoemma\SlackBundle\Dto\Attachment;
use Gotoemma\SlackBundle\Dto\Field;
use Gotoemma\SlackBundle\Provider\CommandProviderInterface;

class YourCommandProvider implements CommandProviderInterface
{

    /**
     * Return true if this CommandProviders handleCommand() method should be called for the given arguments
     *
     * @param string $command
     * @param array $parameters
     * @return boolean
     */
    public function supportsCommand(string $command, array $parameters);

    /**
     * Return true if the registeredCommands argument should be set on handleCommand() call
     *
     * @return boolean
     */
    public function injectRegisteredCommands();

    /**
     * @param string $command
     * @param array $parameters
     * @param ArrayCollection $registeredCommands ArrayCollection of all CommandProviders that registered for SlackBundle
     * @return Attachment
     */
    public function handleCommand(string $command, array $parameters, $registeredCommands = null);

    /**
     * Return a Field object containing some user instructions how to use your command
     * which will be shown in slack if one uses the ListCommand
     *
     * @return Field
     */
    public function getDescription();
}

The Versions

17/05 2018

dev-master

9999999-dev https://www.gotoemma.de

This bundle provides the basic functionality to quickly connect your Slack Bot with your symfony project via slash commands.

  Sources   Download

17/05 2018

0.4.0

0.4.0.0 https://www.gotoemma.de

This bundle provides the basic functionality to quickly connect your Slack Bot with your symfony project via slash commands.

  Sources   Download

23/01 2018

0.3.0

0.3.0.0 https://www.gotoemma.de

This bundle provides the basic functionality to quickly connect your Slack Bot with your symfony project via slash commands.

  Sources   Download

17/12 2017

0.2.0

0.2.0.0 https://bitbucket.org/gotoemma/slack-bundle

This bundle provides the basic functionality to quickly connect your Slack Bot with your symfony project via slash commands.

  Sources   Download

16/12 2017

0.1.0

0.1.0.0 https://bitbucket.org/gotoemma/slack-bundle

This bundle provides the basic functionality to quickly connect your Slack Bot with your symfony project via slash commands.

  Sources   Download

The Requires