Botman: How to use slack slash commands?

Created on 22 Dec 2016  路  3Comments  路  Source: botman/botman

https://api.slack.com/slash-commands#triggering_a_command

<?php
require_once "../vendor/autoload.php";

header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json; charset=utf8');


use Mpociot\BotMan\BotManFactory;
use Mpociot\BotMan\BotMan;
// create an instance
$config = [
    'slack_token' => '-hidden-'
];

$botman = BotManFactory::create($config);

$botman->hears("/srv", function (BotMan $bot)
{
    $bot->reply("Tell me more!");
});

$botman->fallback(function(BotMan $bot)
{
    $trigger = $bot->getMessage()->getPayload()['command'];
    $bot->reply("'".$trigger."' is an unknown command");
});
// start listening
$botman->listen();

Replies to /srv:
'/srv' is an unknown command

what am I missing?

Most helpful comment

Slack slash commands are now supported! 馃帀

All 3 comments

Slash commands do not work right now.

Slack slash commands are now supported! 馃帀

You are amazing!

Was this page helpful?
0 / 5 - 0 ratings