{"id":13697433,"url":"https://github.com/karlpokus/trobot","last_synced_at":"2025-12-30T03:01:28.633Z","repository":{"id":57380095,"uuid":"56588019","full_name":"karlpokus/trobot","owner":"karlpokus","description":"Make your own trello bot in node.js","archived":false,"fork":false,"pushed_at":"2020-09-13T19:29:17.000Z","size":27,"stargazers_count":23,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-25T05:07:09.348Z","etag":null,"topics":["bot","trello","trello-api","webhooks"],"latest_commit_sha":null,"homepage":"https://developers.trello.com/community","language":"JavaScript","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/karlpokus.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":"2016-04-19T10:36:50.000Z","updated_at":"2025-04-23T12:51:23.000Z","dependencies_parsed_at":"2022-09-02T20:22:19.863Z","dependency_job_id":null,"html_url":"https://github.com/karlpokus/trobot","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlpokus%2Ftrobot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlpokus%2Ftrobot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlpokus%2Ftrobot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlpokus%2Ftrobot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karlpokus","download_url":"https://codeload.github.com/karlpokus/trobot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252252479,"owners_count":21718748,"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":["bot","trello","trello-api","webhooks"],"created_at":"2024-08-02T18:00:58.024Z","updated_at":"2025-12-30T03:01:28.525Z","avatar_url":"https://github.com/karlpokus.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/trobot.svg)](https://badge.fury.io/js/trobot)\n[![Build Status](https://travis-ci.org/karlpokus/trobot.svg?branch=master)](https://travis-ci.org/karlpokus/trobot)\n\n# 3.x\nSince 2.x trobot has a new api consisting of a pub/sub system which is much simpler to use and maintain. Just add webhooks and subscribe to trello model events. Note: Major versions includes breaking changes.\n\n# What it is\nTrobot is (1) a cli to manage webhooks from Trello and (2) a new and shiny bot to respond to said webhooks. Now featured on the [official Trello developer community page](https://developer.atlassian.com/cloud/trello/guides/community/community-projects/).\n\n### What you need\n- a trello user (to be the bot)\n- a node.js server. Note: Trello webhooks require node 6.x\n\n### What you need to do\nGet user data (username, userId, token, key, secret) from Trello.\n\n- `username` is in user profile\n- `userid` by tacking `.json` unto any board url and start digging.\n- `token`, `secret` and `key` at `https://trello.com/app-key`\n\nAdd user data to `process.env[key]` in ALL CAPS for the bot and webhooks to work. These will also be available in lowercase under `bot.data` (see below). Remember - this is sensitive data - so keep it safe.\n\n```\n{\n  \"key\": \"...\", // request to Trello\n  \"token\": \"...\", // request to Trello\n  \"secret\": \"...\", // verify Trello as origin\n  \"userid\": \"...\", // interactions\n  \"username\": \"...\", // interactions\n  \"webhookcallbackurldefault\": \"...\" // handy helper\n}\n```\n\n# install\n```\n$ npm install trobot\n```\n\n# webhooks\n- Add `webhooks: webhooks` to `scripts` in your `package.json`\n- Add user to any model on Trello (boards, lists, and cards etc.) you wish to monitor.\n- Manage webhooks via `npm run webhooks` called from root.\n- Make sure you return a 200 for a quick HEAD to any callbackUrl you will provide before adding a new webhook. Trello checks this.\n- There are multiple ways to build webhooks i.e 1+ callbackURLs for 1+ responses to 1+ model actions. You may also add query params to your callbackURL if it helps. Read more at `https://developers.trello.com/apis/webhooks`.\n\nAfter creating webhooks - do `require('trobot')` somewhere, add custom event handlers and apply them in routes.\n\nAll done!\n\n# usage\n```javascript\n/*\nEVENT HANDLER\nevent: trello model event\ndata: trello event payload. Includes action and model\nres: nodes http.ServerResponse to end the response when done\n[this] is bot inside the callback\n*/\nbot.on(event, cb(data, res))\n\n/*\nTRIGGER EVENT\ndata and res are passed to the event handlers callback when the 'request' event is called.\nInclude as many args as you like for custom events.\n*/\nbot.emit(event [, args]);\n\n// Events that have built-in event handlers that the user needs to trigger.\n// parses payload, checks origin is trello, emits the model event and passes the payload and res to the event handler\nbot.emit('request', req, res);\n// posts a comment to a card\n// event handler will end response\nbot.emit('reply', cardId, answer, res);\n\n// built-in events\n// add an event handler to listen to the logs. Great for debugging.\nbot.emit('log', msg);\n// logs to the console by default and ends the response.\nbot.on('error', err, statusCode, res);\n```\n\n# example\n```javascript\n// bot.js\nvar Bot = require('trobot'),\n    bot = new Bot();\n\nbot.on('commentCard', function(data, res){\n  var comment = data.action.data.text,\n      authorId = data.action.memberCreator.id,\n      authorUsername = data.action.memberCreator.username,\n      cardId = data.action.data.card.id,\n  \t\tanswer;\n\n  if (!/@/g.test(comment) \u0026\u0026 authorId !== this.data.userid) {\n    answer = \"@\" + authorUsername + \" include @username to notify the user of your comment by e-mail.\";\n    this.emit('reply', cardId, answer, res);\n  }\n});\n\nmodule.exports = bot;\n```\n\n```javascript\n// server.js\nvar http = require('http'),\n    server = http.createServer(),\n    port = process.env.PORT || 8080,\n    bot = require('./bot.js');\n\nserver\n  .on('request', function(req, res){\n    if (req.method === 'HEAD') {\n      res.statusCode = 200;\n      res.end();\n    } else if (req.method === 'POST') {\n      bot.emit('request', req, res);\n    } else {\n      res.statusCode = 403;\n      res.end();\n    }\n  })\n  .listen(port);\n```\n\nCheckout [Max](https://github.com/karlpokus/max) for a complete example with a node server.\n\n# test\n```bash\n# run basic tests\n$ npm test\n# run basics tests and server requests\n$ npm run test:server -- [remote url | http://localhost:8080]\n```\n\n# TODOs\n- [x] 2.0 api\n- [ ] option `addDefaultWebhookOnAddMemberToBoard`\n- [ ] option `avoidBotRespondingToBot` to omit events where `data.action.memberCreator.id` is bot\n- [ ] option to disable `originIsTrello`\n- [ ] option to disable error handler\n- [x] update simple error handler\n- [x] let error handler end response\n- [x] add a 200 to HEAD in example\n- [ ] maybe add some details on the trello model data obj\n- [x] remove option to pass user data to constructor in trobot and webhooks and in the readme\n- [x] emit `log` for debugging and let user add listeners as necessary\n- [x] Add log to tests and readme\n- [x] add note on trello webhooks require node 6.x\n- [ ] remove surplus api keys in webhooks\n- [x] 3.0 user data is lowercase on `bot.data`\n- [x] log `response end` on `res.end`\n\n# License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarlpokus%2Ftrobot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarlpokus%2Ftrobot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarlpokus%2Ftrobot/lists"}