1.0.1 • Published 6 years ago

hubot-slash-command v1.0.1

Weekly downloads
9
License
MIT
Repository
github
Last release
6 years ago

hubot-slash-command

It redirects slash command of Slack and Mattermost to Hubot.
Outgoing webhook can not be used on the private channel, so use the slash command to accomplish the same thing.

See src/hubot-slash-command.js for full documentation.

Installation

In hubot project repo, run:

npm install hubot-slash-command --save

Then add hubot-slash-command to your external-scripts.json:

[
  "hubot-slash-command"
]

And restart Hubot.

Add Slash command

Add Slash command to Slack or Mattermost.

Request URLRequest Method
http(s)://(your hubot hostname):(port)/hubot-slash-commandPOST

Please write down token.

Environment variables

  • HUBOT_RESPONSE_TYPE default: in_channel - in_channel(Show a response message to all member) or ephemeral(Visible to ther user that issued the command).
  • HUBOT_RESPONSE_MESSAGE default: Okey, ${user_name} orders `${command} ${text}` - Format response message to chat.
  • HUBOT_RECEIVE_MESSAGE default: ${robot_name} ${text} - Format send message to Hubot.
  • HUBOT_SLASH_COMMAND_TOKENS default:none - Your tokens of slash command(comma separated).

Example for Environment variables

# the response messages will only be visible to the user that issued the command 
export HUBOT_RESPONSE_TYPE=ephemeral
# Response message format to Chat.
export HUBOT_RESPONSE_MESSAGE='${user.name} execute command on ${channel_name}'
# Send message format to Hubot.
export HUBOT_RECEIVE_MESSAGE='${robot_name} ${text}'
# Your tokens of slash command.
export HUBOT_SLASH_COMMAND_TOKENS=fpf9t5snkirmmyxanjj15o3uoh,ff33opd7q3nktx3jkoee17kbya

Variables for message

  • Variables from Hubot Robot object.
Variable nameParameterExample
${robot_name}robot.nameHubot
${robot_alias}robot.aliasmybot
  • Variables from request parameter of slash command.
Variable nameParameterExample
${channel_id}channel_idC2147483705
${channel_name}channel_namegeneral
${command}command/some_command
${response_url}response_urlhttps://hooks.slack.com/commands/12345678
${team_domain}team_domainexample
${team_id}team_idT0001
${text}textweater Tokyo
${token}tokengIkuvaNzQIHg97ATvDxqgjtO
${user_id}user_idU2147483697
${user_name}user_nameSteve

Usage

When executing the slash command, redirects arguments of slash command to Hubot.
If you input /some_command ping, send hubot ping to Hubot.

So you can get message by robot.respond(/ping/).

License

MIT

1.0.1

6 years ago

1.0.0

6 years ago