{"id":18081174,"url":"https://github.com/thundergolfer/library-management-slack-bot","last_synced_at":"2025-07-25T15:09:43.393Z","repository":{"id":42343740,"uuid":"175333770","full_name":"thundergolfer/library-management-slack-bot","owner":"thundergolfer","description":":books: Slack bot that helps facilitate tracking of books and borrowers in your office/home library","archived":false,"fork":false,"pushed_at":"2023-01-03T17:58:20.000Z","size":2139,"stargazers_count":5,"open_issues_count":27,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T12:55:25.416Z","etag":null,"topics":["aws-lambda","jsonnet","slack-bot","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thundergolfer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-13T02:45:25.000Z","updated_at":"2024-06-17T21:59:56.000Z","dependencies_parsed_at":"2023-02-01T08:31:00.442Z","dependency_job_id":null,"html_url":"https://github.com/thundergolfer/library-management-slack-bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thundergolfer%2Flibrary-management-slack-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thundergolfer%2Flibrary-management-slack-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thundergolfer%2Flibrary-management-slack-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thundergolfer%2Flibrary-management-slack-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thundergolfer","download_url":"https://codeload.github.com/thundergolfer/library-management-slack-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586229,"owners_count":21128995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","jsonnet","slack-bot","typescript"],"created_at":"2024-10-31T13:13:19.581Z","updated_at":"2025-04-12T14:52:50.957Z","avatar_url":"https://github.com/thundergolfer.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Library Management Slack Bot [![Build Status](https://travis-ci.com/thundergolfer/library-management-slack-bot.svg?branch=master)](https://travis-ci.com/thundergolfer/library-management-slack-bot)\n\nSlack bot that helps facilitate tracking of books and borrowers in your office/home library. This bot was built to support the office library @ [Canva Sydney](https://www.canva.com/careers/), but is general in nature and with simple hosting on [AWS Lambda](https://aws.amazon.com/lambda/) and [Google Sheets](https://www.twilio.com/blog/2017/03/google-spreadsheets-and-javascriptnode-js.html) can solve the same problems in your office. \n\n-----\n\n## How It Works\n\nThis bot exists to manage an index of physical books in an office library, and \nalso track borrows and returns of the library users. Via simple Slack interactions, \nusers can search for available books, record their borrow, and record their return. \n\n### Commands \n\n\u003e *Note:* This is currently an MVP. In future, the bot will *not* require the user manually inputting an ISBN.\n\n##### **[@librarybot](/README.md) (with a scanned image of the book's barcode)** - Borrow, add, or return a book without having to manually type its ISBN. \n##### **[@librarybot](/README.md) `\u003cISBN\u003e`** - Borrow, add, or return a book with the ISBN of value `\u003cISBN\u003e`\n##### **[@librarybot](/README.md) `list`** - List all books registered in the library database\n##### **[@librarybot](/README.md) `borrow`** - List all books _you_ have borrowed.\n##### **[@librarybot](/README.md) `search \"\u003cQuery\u003e\"`** - Search books\n\n## Development\n\n### Prerequisites \n\n- **Access to API Gateway and Lambda on the AWS Account where this bot is deployed** \n- **Jsonnet** ([`brew install jsonnet`](https://formulae.brew.sh/formula/jsonnet))\n\n### Installation \n\n`npm install`\n\n### Configuration\n\nCopy `.env.default` to `.env` and fill in the slack tokens and google sheet id.\n\n### Testing \n\n#### Unit\n\nAll unit tests are contained in [`tests/`](tests/). Run them with:\n\n`npm run test`\n\n#### Integration: `serverless` Local Testing\n\nUsing `serverless invoke local -f \u003cfunction name\u003e -p \u003cpath to JSON payload\u003e` we can test the Lambda locally\nbefore deploying to AWS.\n\nCurrently the function name is `hello` and the JSON payloads live in [`tests/data/`](/tests/data). The payloads\nare generated by _Jsonnet_ (see [**Generating Mock Event Payloads**](#generating-mock-event-payloads)).\n\nFor example this command will execute a borrow against the [development Google Sheets DB](https://docs.google.com/spreadsheets/d/1Vbvys2uiSyJWPKsFWjMyHeZ-1mTWDTZCyeFfYCkemuQ/edit#gid=0): \n\n`npx serverless invoke local -f hello -p  tests/data/book_message.json`\n\nIt won't actually send a message to Slack. It will just `console.log` what would be sent 😊.\n\n#### Generating Mock Event Payloads \n\nFrom repository root, run `jsonnet -m tests/data tests/data/jsonnet/api_gateway_base.jsonnet`. Valid AWS API Gateway payloads\n*containing* Slack Event API payloads as strings (`event.body`) will be generated in `test/data`.\n\n## Running Locally\n\nTo start the server locally run:\n\n`npx serverless offline`\n\nTo create an external URL accessible from slack run:\n\n```\nnpm install -f localtunnel\nlt --port 3000 --subdomain \u003cdomain name\u003e\n```\n\n1) [Create a Slack app](https://api.slack.com/apps)\n2) Enable event subscriptions, with the URL from localtunnel\n3) Create a bot user\n4) Install the app with the `chat:write:user` scope\n5) In the slack workspace you installed to, message the bot with `@\u003cbotname\u003e list`\n\n## Deployment \n\nCurrently deployment involves manually uploading the `.zip` artifact for the \nfunction at [https://console.aws.amazon.com/lambda/](https://console.aws.amazon.com/lambda/). \nThis can be automated using **Serverless**, and will be soon. For the moment: \n\n1. `npm run package` (creates `library-management-slack-bot.zip` in `artifact/`)\n2. Go to AWS Lambda console and upload `.zip` for `slack-library`\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthundergolfer%2Flibrary-management-slack-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthundergolfer%2Flibrary-management-slack-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthundergolfer%2Flibrary-management-slack-bot/lists"}