jclg / php-slack-bot

Slack bot user written in PHP
MIT License
169 stars 61 forks source link

How to use the library #15

Closed vaibhav-kaushal closed 7 years ago

vaibhav-kaushal commented 7 years ago

Hello @jclg

I have installed this library into my application (using composer) but I do not know where to go now! I have replaced the token given to me by Slack (a bot token). I am not sure how to make the app listen for incoming connections.

Sorry if that sounds like a newbie question.

jclg commented 7 years ago

Hello,

You have to create a bot.php file with the following content :

<?php
require 'vendor/autoload.php';
use PhpSlackBot\Bot;

$bot = new Bot();
$bot->setToken('xoxb-**************'); // Replace token
$bot->loadInternalCommands();
$bot->run();

Then run php bot.php from the command line (terminal). Inside Slack, the bot should turn online (green dot). Direct message him by typing ping, the bot should answer "pong".

Please let me know if it works.

vaibhav-kaushal commented 7 years ago

This worked. Few suggestions:

  1. You should put this in the README. Especially the fact that we have to run it from the terminal.
  2. When we do run it from the terminal, the script has to keep running. Which means on a server, we have to do something like php bot.php &.
  3. There should be a way to stop the bot except killing the process, ideally. But I am not complaining. I can manage my processes.

And many thanks for this library. You can close the issue if you want, but I really recommend you to update the README; will help other newcomers to this repo who are new to Slack's APIs.

jclg commented 7 years ago

You're welcome. I updated the documentation to explain how to run the bot.