diff --git a/README.md b/README.md new file mode 100644 index 0000000..779d0bf --- /dev/null +++ b/README.md @@ -0,0 +1,324 @@ +# Intratime slack app + +![Status](https://img.shields.io/badge/Version-2.0-blue.svg) +![Status](https://img.shields.io/badge/Status-stable-green.svg) + +Application to clock in intratime app using using slack. + +
+ +
+ + +# Introduction + +Intratime slack app is an application that allows you to clock in the [Intratime](https://www.intratime.es/) +application using the slack client and get this related info. + +You only need to enter your intratime credentials (they will be stored in an encrypted database) and write a single +command to clock your actions or get information about them. + +This application has the following capabilities: + +- Clock your entry, pause, return or out action. +- Get your total worked time (clocked). +- Get your clock history. +- Get your worked time history. + +--- + +# How to use + +## Considerations before starting + +- All messages generated as a result of any command are of **private visibility**, thus avoiding flooding public +conversations and preventing the rest of the users from seeing your information or actions. + +- When the account is created using the intratime credentials, the **password is stored in encrypted form**. + +- **Requests and slack content** to the server (where the application is running) **are encrypted**. (This encryption is +external to the application, using NGINX as reverse proxy). + +- The _intratime-bot_ service will **only deal with requests made by slack**, using a signature key. This prevents +unwanted access in external applications. + +- **Most commands can be launched via user interface or directly with parameters**. Commands without parameters will +activate the GUI. See the `/help` command for more information available command parameters. + +## User management + +**Register your app user** + +First of all, it is necessary to have an intratime and slack account. From here, we will have to sign up in this app +using the `/sign_up` command in the slack chat and then introducing **your intratime credentials** in the related +fields. + ++ +
+ +>**Note**: There are no password type fields, so the password will be written in raw in the field. Be careful with this. + +**Update your app user** + +If you have ever modified your credentials in intratime (in the intratime application), then you will need to +update your credentials in this app as well, to do so use the `/update_user` command and enter your new credentials: + ++ +
+ +**Delete your app user** + +In case you want to delete your user in this app, you can do it with the command `/delete_user`. + +## Clock your actions + +Once the user is registered (you only need to do it once), you can clock your action (_IN_, _PAUSE_, _RETURN_ or _OUT_) +in the intratime application using the `/clock` command. + ++ +
+ +It is also possible to activate this command directly by passing it one of the following actions: _IN_, _PAUSE_, +_RETURN_ _OUT_. + +``` +/clock+ +
+ +This functionality also filters out possible inconsistent clockings, such as trying to clock a _RETURN_ without a +previous _PAUSE_. In this case, we can see messages like the following: + ++ +
+ +## Check your total worked time + +A very useful feature is to check how long we have been working, making the calculation based on the clockings we +have made. We can do this calculation on a daily, weekly or monthly basis. + +For this you can use the `/time` command. + ++ +
+ +It is also possible to activate this command directly by passing it one of the following parameters: _today_, _week_, +_month_. + +``` +/time+ +
+ +## Check your clock history + +Do you need to check the clocks made? This command shows you all the information of the clockings made in the current +day, week or month. + +For this you can use the `/clock_history` command. + ++ +
+ +It is also possible to activate this command directly by passing it one of the following parameters: _today_, _week_, +_month_. + +``` +/clock_history+ +
+ + +## Check your worked time history + +Do you want to know how many hours you worked each day? This commands shows you a list of time worked for each day in +the specified range, on the current day, week or month. + +For this you can use the `/time_history` command. + ++ +
+ +It is also possible to activate this command directly by passing it one of the following parameters: _today_, _week_, +_month_. + +``` +/time_history+ +
+ + +## Check your current day summary + +If you want to get a summary of the time worked and clockings made today, you can use directly the `/today` command. +This command has not parameters. + +``` +/today +``` + ++ +
+ +## Get help info + +In case you need information about the available commands and parameters, you can run the command `/help`, to +display the following help menu: + ++ +
+ +--- + +# App components + +This application consists of the following services: + +- **intratime-bot**: Main service that attends to all slack requests and communicates with the rest of services and +components to carry out the request. + +- **mongo-service**: Storage and database service. + +- **mongo-express**: Service to visualize and make queries in a graphic way in the database service. + +The implemented structure can be seen in the following figure: + ++ +
+ +--- + +# How to deploy + +## Configure your slack app + +First you will have to create a slack application. You can create one from this website +[https://api.slack.com/](https://api.slack.com/). + + +**Get slack app credentials** + +Once created, you will have to obtain your **app tokens**. You can find it in `OAuth & Permissions section`. +It will have a format like the following: + +_OAuth Access Token_ +``` +xoxp-xxxxxxxxxxxxx-xxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx +``` + +_Bot User OAuth Access Token_ + +``` +xoxb-xxxxxxxxxxxxx-xxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx +``` + +It will also be necessary to obtain the **signing secret key** to verify that the requests come from our slack app. You +can find this key in _Basic information_ section. + +**Set your token scopes** + +A Slack app's capabilities and permissions are governed by the scopes it requests. You can configure them in + _OAuth & Permissions_ section. The current token scopes are as follows: + +- **Bot token scopes**: _channels:history_, _commands_, _groups:history_ +- **User Token Scopes**: _chat:write_ + +**Set your interactivity endpoint** + +All the interactions with the graphic slack components (in this case the modal windows and forms are used) have to be +attended from a specific endpoint. + +This endpoint belongs to the _intratime-bot_ service with the `/interactive` URI , so it will be necessary to indicate +in the _Interactivity & Shortcuts_ section the _Request URL_ for this endpoint. For example: + +``` +https://