Skip to content
Switch branches/tags
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time



golang backend for a super-handy Slack /slash command that searches the team directory. i install as /dir. example use:

user enters: /dir ric

response that users sees:

Your Company Team Directory Bot [04:41] Only you can see this message
   rick tait: :phone: (213) NNN-NNNN :email: :slack: @rickt
   Richard Richardson: :phone: (213) NNN-NNNN :email: :slack: @richard

a screenshot/example of what your Slack users might see in response to typing /dir account to look for someone in the accounting department:



backend basics:

  • you configure a slack /slash command to POST to URI /slack with appropriate payload token=TOKEN and text=SEARCHSTRING
  • the best match & phone number is returned to the user
  • if the expected Slack "challenge" token (get this from your /slash command setup) is not sent along with the request, the request is dropped
  • requires a separate Slack OAuth2 bearer token (get a quickie from to establish backend connection into your Slack to retrieve user data & POST response to request into Slack
  • both tokens are configured as environment variables in the app.yaml

written specifically to run in Google App Engine. should be plug-n-play for you.

  1. deploy to App Engine using goapp deploy once you've setup goapp
  2. setup your /slash command in Slack
  3. profit
  • this is written specifically for Google App Engine, hence no main() and requirement
  • change values as appropriate in the environment variable section in your app.yaml
  • none of your Slack user, group or indeed any kind of Slack data is ever stored in Google App Engine!
  • all data is queried from Slack and passed back to the requestor in real time via https
  • Overview:
$ curl -XPUT --data "token=REDACTED&text=john"`
  • Example run:
$ curl -XPUT --data "token=REDACTED&text=tait"
{"channel":"","username":"","text":"rick tait: :phone: (213) NNN-NNNN :email: \|\u003e :slack: \u003c@REDACTED|rickt\u003e\n","response_type":"","icon_emoji":"","u

what's happening here

  • Slack intercepts the user request, lets use an example of a Slack user entering
/dir foo
  • Slack then makes a call to our directory bot (assuming the /slash command is setup correctly), effectively doing the equivalent of:
$ curl -XPUT --data "token=REDACTED&text=foo"
  • the directory bot checks to see if the token sent along with the request is valid, and assuming it is, the bot then:

    • calls a few Slack APIs searching for the user's searchstring foo
    • receives JSON data from Slack in response to those API calls
    • assuming a positive search match, massages the data a bit so it looks pretty
    • packs it up all and sends a JSON message back to Slack, which is displayed to the OG requesting user
  • an unauthenticated request to the directory bot (one without a valid key) will receive a response back as below

	"channel": "",
	"username": "",
	"text": "unauthenticated request, tsk tsk!",
	"response_type": "",
	"icon_emoji": "",
	"unfurl_links": false,
	"link_names": 1,
	"attachments": null
  • a properly authenticated request (to use the above "foo" example) will receive a response like below
	"channel": "",
	"username": "",
	"text": "*Users matching \"foo\":*\nFoo McFooerson: :dir_phone: (213) 555-1212 :dir_email: \|\u003e :slack: \u003c@U111111|foo\u003e\n",
	"response_type": "",
	"icon_emoji": "",
	"unfurl_links": false,
	"link_names": 1,
	"attachments": null


Golang backend for an App Engine-based Slack /slash command to quickly get phone numbers from the Slack Team Directory



No releases published


No packages published