/go-wiki

Slack Wikipedia Bot written in Go

Primary LanguageGo

go-wiki

Go-Wiki is a Slack Bot written in Golang that retrieves Wikipedia information.

Setup


Dependencies

Configuration

export GOWIKI_SLACK_TOKEN='xoxb-123456789012-123456789012-50rQ8TcaSdUoZDyAbHb0hjqs'
export GOWIKI_DB_CONFIG="user=postgres dbname=bot host=db port=5432 sslmode=disable"

Build

  • Once your environment variables are properly configured, go to your terminal and run
docker-compose up

This will enable your server to run with a postgres db. You will beable to see the logs.

Optionally if you prefer to use Docker swarm you can run this using

docker swarm init
docker build -t go-wiki .
docker stack deploy --compose-file=docker-compose.yml go-wiki

Go to your slack channel and click on + Add App

Search go-wiki and add to channel

Use the command gowiki to search a topic you would like to share with your team! 🚀

gowiki Toronto

go-wiki stores each call to a database for caching so the next time around it will show up without the need to call Wikipedia. :squirrel:

How to acquire a Slack Token


Below are steps to aquire a slack token necessary for this golang application to work.

  1. Create a Slack App https://api.slack.com/apps?new_app=1

  1. Create a bot user

  1. Install your app to your workplace

  1. Now go to OAuth & Permissions and copy the Bot User OAuth Access Token

👏 Congratulations! 🎊 Now you have your Slack Token! Now go back up to Setup!

Further Development


I have left the entire struct of a wikipedia page in main.go. Please feel free to call anything that your heart desires from Wikipedia to your Slack Channel ❤️. Just remember to add the rows to the pages table in the database, update the db query and response!

References