Translation-Bot

Phillip England_

translation-bot

Does your team use groupme? Are you constantly having to use google translate to ensure everyone on your team can read messages? Introducing: translation-bot! A quick and easy way to auto-translate groupme messages using deepl.com's translation API.

Usage

translation-bot enables your groupme memeber to auto-translate their messages by prefixing a message with $spanish or $english depending on what lanugage they want to translate their message to. Codebase can be modified to fit more languages if needed.

Installation

  1. Clone the repository
1git clone https://github.com/phillip-england/translation-bot <target-directory>
  1. Install Go Packages
1go mod tidy
  1. Create a .env in the root of the project
1touch .env
  1. Add the required environment varialbes to .env
1DEEPL_API_KEY=your deepl.com api key for translation (they offer a free tier)
2PORT=port to serve on
3YOUR_BOT_ID=your groupme bot ID (more on this in next section)
4YOUR_GROUP_ID=your groupme group ID (more on this in next section)
  1. Modify the following section in main.go to fit your requirements. In my case, I am using this bot on multiple different groupme channels.
 1var groupmeBotID string
 2if groupID == os.Getenv("TESTING_GROUP_ID") {
 3    groupmeBotID = os.Getenv("TESTING_BOT_ID")
 4}
 5if groupID == os.Getenv("SOUTHROADS_LEADERSHIP_GROUP_ID") {
 6    groupmeBotID = os.Getenv("SOUTHROADS_LEADERSHIP_BOT_ID")
 7}
 8if groupID == os.Getenv("KITCHEN_LEADERSHIP_GROUP_ID") {
 9    groupmeBotID = os.Getenv("KITCHEN_LEADERSHIP_BOT_ID")
10}
11if groupID == os.Getenv("FOH_OPERATIONS_GROUP_ID") {
12    groupmeBotID = os.Getenv("FOH_OPERATIONS_BOT_ID")
13}
14if groupID == os.Getenv("SUPPLY_ORDER_GROUP_ID") {
15    groupmeBotID = os.Getenv("SUPPLY_ORDER_BOT_ID")
16}

To fit based on the .env file I provided above, modify to the following:

1var groupmeBotID string
2if groupID == os.Getenv("YOUR_GROUP_ID") {
3    groupmeBotID = os.Getenv("YOUR_BOT_ID")
4}

Simply add more .env varialbes to add additional groups your bot can post to.

  1. Serve the Application
1go run main.go

Third-Party Documentation

For more information on how to use the groupme api or the deepl translation api, check the following links: