lib.praqma.toggl-bot
Tag 0
Scripts querying Toggl and applying certain rules on Praqma's workspace
  Published by praqma on Dec 4th 2017, 3:24 PM
  # toggl-rules Scripts querying Toggl and applying certain custom rules on Praqma's workspace Read more about the project seed provided by `stdlib` [here](stdlib.md) ## Functions The following functions can be invoked in a number of ways. ### Daily-checkup This function fetches all time entries for the day before and runs a check on them to see if they have a task and project properely assigned. The users who did not enter their time registration correctly will be mentioned the next morning in a Slack post in the timelogging channel. Later the day, an evening check will follow up to make sure people fixed thier registrations. ✔ No time entry without a Praqma client -> post to Slack ✔ No time entry without a task -> post to Slack ✖ No project without client -> notify project manager ## Getting started ### Getting a running project on your computer 1. Clone this repository 1. Install project dependenciec - inside the project run the command: ```sh npm install ``` 3. Duplicate the file `credentials.example.json` and fill in the credentials from a pinned post in the Slack channel called `#toggl-rules` 1. Rename the file to `credentials.json` to make it work ### Deploying the changes This project is deployed to `StdLib.com`, a funcion as service platform becoming popular after Amazons's Lambda service. First make sure you have the npm package `lib` installed globally ```sh sudo npm install -g lib ``` #### Running the function locally To test the `daily_checkup` function, run this command in your terminal in the root of your project: ```sh lib .daily_checkup ``` If the execution was successful it will return the following message potentially with some logs on top ```sh { "ok": true, "message": "Message delivered to Slack channel." } ``` #### Deploying for testing in the cloud ```sh lib up dev ``` #### Releasing a production version - First, up the version number in `package.json` - Publish to stdlib with the command: ```sh lib release ``` # Roadmap The roadmap for this project is simple: > Make checks for what-ever internal time logging rules we have and we want to verify automatically And yes, some of the things we check and automate is paid features in Toggl, but we have a pretty good business case in saved license costs by implementing them ourselves. We have a few design changes we want to do later, that was not done in this first MVP November 2017: * A general rule engine so we can easily describe time logging rules in a common language so the serve both and input to our automated verification but also as documentation in easy human readable format on how we log time in Praqma. See [`#33`](https://github.com/Praqma/toggl-rules/issues/33) * Yes, there is currently not that much testing, and we discussed that logging might as well be a good thing to have first as this will reveal what fails in case we need to debug.
# toggl-rules Scripts querying Toggl and applying certain custom rules on Praqma's workspace Read more about the project seed provided by `stdlib` [here](stdlib.md) ## Functions The following functions can be invoked in a number of ways. ### Daily-checkup This function fetches all time entries for the day before and runs a check on them to see if they have a task and project properely assigned. The users who did not enter their time registration correctly will be mentioned the next morning in a Slack post in the timelogging channel. Later the day, an evening check will follow up to make sure people fixed thier registrations. ✔ No time entry without a Praqma client -> post to Slack ✔ No time entry without a task -> post to Slack ✖ No project without client -> notify project manager ## Getting started ### Getting a running project on your computer 1. Clone this repository 1. Install project dependenciec - inside the project run the command: ```sh npm install ``` 3. Duplicate the file `credentials.example.json` and fill in the credentials from a pinned post in the Slack channel called `#toggl-rules` 1. Rename the file to `credentials.json` to make it work ### Deploying the changes This project is deployed to `StdLib.com`, a funcion as service platform becoming popular after Amazons's Lambda service. First make sure you have the npm package `lib` installed globally ```sh sudo npm install -g lib ``` #### Running the function locally To test the `daily_checkup` function, run this command in your terminal in the root of your project: ```sh lib .daily_checkup ``` If the execution was successful it will return the following message potentially with some logs on top ```sh { "ok": true, "message": "Message delivered to Slack channel." } ``` #### Deploying for testing in the cloud ```sh lib up dev ``` #### Releasing a production version - First, up the version number in `package.json` - Publish to stdlib with the command: ```sh lib release ``` # Roadmap The roadmap for this project is simple: > Make checks for what-ever internal time logging rules we have and we want to verify automatically And yes, some of the things we check and automate is paid features in Toggl, but we have a pretty good business case in saved license costs by implementing them ourselves. We have a few design changes we want to do later, that was not done in this first MVP November 2017: * A general rule engine so we can easily describe time logging rules in a common language so the serve both and input to our automated verification but also as documentation in easy human readable format on how we log time in Praqma. See [`#33`](https://github.com/Praqma/toggl-rules/issues/33) * Yes, there is currently not that much testing, and we discussed that logging might as well be a good thing to have first as this will reveal what fails in case we need to debug.
The "Add to Slack" landing page for your app. To modify the template, check out /pages/index.ejs.
  info
context
disabled
bg
info
pricing
free
rate limits
  parameters
(no parameters expected)
  code
Slack Actions (Interactive Messages) Response Handler This function receives actions (interactive messages) from Slack and dispatches the appropriate handler. You should use this function as the endpoint for all actions, and place action handlers in /functions/actions/NAME.js, where NAME is the name of your action. You can test from the command line using: lib .actions.NAME [username] [channel name] For more about interactive messages and how to respond to them, see Slack's documentation: https://api.slack.com/docs/message-buttons
  info
context
enabled
bg
info
pricing
free
rate limits
  parameters
(no parameters expected)
  code
example.js Basic example action handler. Called in response to an input from an interactive message. All Actions in response to interactive messages use this template, simply create additional files with different names to add actions. See https://api.slack.com/docs/message-buttons for more details.
  info
context
disabled
bg
info
pricing
free
rate limits
  parameters (click to modify)
{string}
user
(required)
The user id of the user that invoked this command (name is usable as well)
{string}
channel
(required)
The channel id the command was executed in (name is usable as well)
{object}
action
= {}
The full Slack action object
{string}
botToken
= null
The bot token for the Slack bot you have activated
  code
Authorization HTML page to grant Slack App OAuth Permission To modify the template, check out /pages/auth.ejs.
  info
context
disabled
bg
info
pricing
free
rate limits
  parameters (click to modify)
{string}
code
= null
Slack-provided authorization code
{string}
error
= ""
Slack-provided error
  code
Slack Slash Command Handler: This function receives slash commands from Slack and dispatches the appropriate handler. You should use this function as the endpoint for all commands, and place commands in /functions/commands/NAME.js, where NAME is the name of your command. You can test individual slash commands from the command line with: $ lib .commands.NAME [username] [channel] [text]
  info
context
enabled
bg
info
pricing
free
rate limits
  parameters
(no parameters expected)
  code
/hello Basic "Hello World" command. All Commands use this template, simply create additional files with different names to add commands. See https://api.slack.com/slash-commands for more details.
  info
context
disabled
bg
info
pricing
free
rate limits
  parameters (click to modify)
{string}
user
(required)
The user id of the user that invoked this command (name is usable as well)
{string}
channel
(required)
The channel id the command was executed in (name is usable as well)
{string}
text
= ""
The text contents of the command
{object}
command
= {}
The full Slack command object
{string}
botToken
= null
The bot token for the Slack bot you have activated
  code
  info
context
disabled
bg
info
pricing
free
rate limits
  parameters (click to modify)
{string}
channel
= ""
(no description)
{boolean}
isEveningReminder
= false
(no description)
  code
Slack Event Handler: This function receives events from Slack and dispatches the appropriate handler. If an event has no subtype, it will invoke /functions/events/TYPE.js or /functions/events/TYPE/__main__.js, otherwise it will invoke /functions/events/TYPE/SUBTYPE.js. You can test individual events from the command line with: $ lib .events.TYPE.SUBTYPE [username] [channel] [text] The "@bg params" line below tells StdLib that when this function is invoked as a background function over HTTP it should just respond with whatever parameters were passed in as a JSON object. (This handles Slack's "challenge" parameter.)
  info
context
enabled
bg
params
pricing
free
rate limits
  parameters
(no parameters expected)
  code
message event All events use this template, simply create additional files with different names to add event responses See https://api.slack.com/events-api for more details.
  info
context
disabled
bg
info
pricing
free
rate limits
  parameters (click to modify)
{string}
user
(required)
The user id of the user that invoked this event (name is usable as well)
{string}
channel
(required)
The channel id the event was executed in (name is usable as well)
{string}
text
= ""
The text contents of the event
{object}
event
= {}
The full Slack event object
{string}
botToken
= null
The bot token for the Slack bot you have activated
  code
channel_join event See https://api.slack.com/events-api for more details.
  info
context
disabled
bg
info
pricing
free
rate limits
  parameters (click to modify)
{string}
user
(required)
The user id of the user that invoked this event (name is usable as well)
{string}
channel
(required)
The channel id the event was executed in (name is usable as well)
{string}
text
= ""
The text contents of the event
{object}
event
= {}
The full Slack event object
{string}
botToken
= null
The bot token for the Slack bot you have activated
  code