Server side for handling emoji Slack slash command request.
Type:
/pepe blood
To show an emoji
/your_command emoji_name
To show all available emojis of a command
/your_command
Just clone this project and npm start
git clone https://github.com/sontx/slack-emoji.git
npm istall
npm start
- Goto slack page.
- Login/signup if necessary.
- Click on Create New App.
- Select your app name and a workspace which you are on.
- Click on Create App -> done.
- In Basic Information section, goto Building Apps for Slack -> Add features and functionality -> Click on Slash Commands.
- In Slash Commands section -> Click on Create New Command.
- There are some fields which need to fill up:
- Command: your command in slack, ex: pepe
- Request url: when the user types your command and presses enter, a request will be sent to your sever (that why we have this repo), ex: http://your_domain:your_port/slack/command/emoji
- Short description: describe what is the purpose of this command, ex: Pepe the Frog emoji
- Usage Hint: what is the parameters, ex: emoji-name
- Click on Save -> done.
At this time, we already have a Slack slash command but it does nothing, we have to add some businesses by handling the request in our server.
All server configurations are in .env
file:
APP_VERIFICATION_TOKEN = your_slack_app_verification_token
MESSAGE_FORMAT = response message format, ex: {sender} :{emoji}:
ENDPOINT = which endpoint will handle the request, ex: /slack/command/emoji
PORT= listen port, ex: 2911
- APP_VERIFICATION_TOKEN: you can achieve this in App Credentials -> Verification Token
- MESSAGE_FORMAT: a message above responded emoji image, it can be empty, default is
{sender} :{emoji}:
, there are some available params- sender: who sent this command.
- emoji: emoji name.
- emojiLink: link to the image which matches this emoji.
- ENDPOINT: should match your Request url setting in Add a Slash command.
- PORT: should match your Request url setting in Add a Slash command.
You just take care of emoji
directory and providers.js
file.
Ex: add a new emoji bundle named meme
:
- Add file name
meme.js
inemoji
directory. - Define it in
providers.js
file.
- Goto emoji bundle which will contain the new emoji name.
- Add a pair of key and value to this file, ex:
new_emoji: "link to the emoji image"