01_slack_bot

command module
v0.0.0-...-3c93cf4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 16 Imported by: 0

README

Slack Bot

This is a simple Slack bot.

Features

The bot can be used to automate tasks in a Slack workspace. It can be used to:

  • calculate the age of a person based on their year of birth 🎥,
  • upload a "lorem ipsum" file to a Slack channel 🎥,
  • answer (philosophical) questions with the help of the Wolfram Alpha API and the wit.ai API 🎥.

Technologies

The application is built using the following technologies, libraries, frameworks, and tools:

Setup

Before running the application, you need to create a .env file in the root directory of the project with the following content:

SLACK_BOT_TOKEN=PUT_YOUR_SLACK_BOT_TOKEN_HERE
SLACK_APP_TOKEN=PUT_YOUR_SLACK_APP_TOKEN_HERE
WOLFRAM_APP_ID=PUT_YOUR_WOLFRAM_APP_ID_HERE
WIT_AI_TOKEN=PUT_YOUR_WIT_AI_TOKEN_HERE

or set the environment variables directly in your environment.

To know how to get the SLACK_BOT_TOKEN and SLACK_APP_TOKEN, please refer to the official documentation.

To get the WOLFRAM_APP_ID, please refer to the official documentation.

To get the WIT_AI_TOKEN, please refer to the official documentation.

To run this application:

go build . && ./01_slack_bot

If you want to add some extra dependencies to the project, you might need to run the following command (as we are using Go modules and vendoring) afterwards:

go mod tidy && go mod vendor

Provided that you've configured Slack properly, you should be able to interact with the bot in your Slack workspace.

In my case, I've created a bot called simple-slack-bot and I can interact with it by mentioning it in a message.

Usage

To calculate the age of a person based on their year of birth, you can use the following command:

@simple-slack-bot my yob is 2000

The bot will respond with the age of the person.

You are 24 years old

To upload a "lorem ipsum" file to a Slack channel, you can use the following command:

@simple-slack-bot upload lorem ipsum file with 42 words

The bot will respond with a file containing 42 words of "lorem ipsum".

To ask a (philosophical) question, you can use the following command:

@simple-slack-bot answer question: "What is the meaning of life?"

The bot will respond with an answer to the question (if it can find one):

42

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL