This Slackbot is built using Node.js and TypeScript, and it utilizes the API from usaspending.gov to retrieve data on awarded contracts. The bot is designed to track the recipients of these contracts, allowing users to easily stay informed about which companies are receiving funding from the government. The bot can be configured to send regular updates to specific channels or users, providing them with real-time information on contract awards. The bot's user-friendly interface allows users to easily search for contract award data by various criteria, such as the awarding agency, the location of the recipient, and the date range of the award. Overall, this Slackbot is a valuable tool for anyone looking to stay up-to-date on government contract awards and the companies that are benefiting from them.
- nodejs v18.10
- npm
/set-slack-channel [channel-id]
- Set a general slack channel to output when a tracked recipient receives a new award/add-recipient [uuid] [shortname]
- Add a recipient to the database along with storing all of their contract awards./list-latest-awards [shortname]
- List the 5 latest contract awards.
1.Clone the repository
git clone https://github.com/coforma/UsaSpendingBot.git
2.Install dependencies
cd UsaSpendingBot
npm install
3.Create a .env file in the root of the project and set the following environment variables:
DB_HOST=localhost
DB_PORT=3050
DB_NAME="local.db"
SLACK_SIGNING_SECRET=""
SLACK_BOT_TOKEN=""
LOG_LEVEL="silly"
4.Start the application in development mode
npm run dev
The structure below shows where to place specific new files and where to find specific types of files. All new commands should have its own file under the commands
directory.
├── .env
├── src
│ ├── commands
│ │ ├── command-name.ts
│ │ └── ...
│ ├── entity
│ │ ├── entity-name.ts
│ │ └── ...
│ ├── types
│ │ ├── type-name.ts
│ │ └── ...
│ ├── utils
│ │ ├── util-name.ts
│ │ └── ...
│ ├── migration
│ │ ├── migration-name.ts
│ │ └── ...
│ ├── config.ts
│ ├── index.ts
│ └── data-source.ts
This will start the application using nodemon and ts-node, allowing for quick code changes and immediate feedback.
@slack/bolt got npmlog typeorm better-sqlite3 reflect-metadata
TODO: Add testing instructions
TODO: Add deployment instructions
- Do not run with .env file in production.
- nodejs - JavaScript runtime
- typescript - TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
- @slack/bolt - A powerful framework for building Slack apps using Node.js
- got - Simplified HTTP requests
- npmlog - A logging framework for Node.js with support for custom log levels and colored console output
- typeorm - ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL databases.
- better-sqlite3 - The fastest and simplest library for SQLite3 in Node.js.
- reflect-metadata - A polyfill for the Metadata Reflection API, part of the ECMAScript (ES) 2017 specification.
- nodemon - Utility that will monitor for any changes in your source and automatically restart your server.
- ts-node - TypeScript execution environment and REPL for node.