Fakultas Ilmu Komputer UI

README.md 4.01 KB
Newer Older
ZAKI RAIHAN's avatar
ZAKI RAIHAN committed
1
2
3
4
5
6
# FASILKOM UI TELEGRAM BOT NOTIFICATION

## Table of Content
1. Requirements
2. Application Structure
3. Application Configuration
ZAKI RAIHAN's avatar
ZAKI RAIHAN committed
7
4. Features
ZAKI RAIHAN's avatar
ZAKI RAIHAN committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

## Requirements
1. Python 3.7
2. PostgreSQL 11.5

## Application Structure
```
ossd-notification-bot
│   env
└───migrations    
└───models
    │   AccountModel.py
└───navigation
    │   navigation.py
└───sso
    │   csui_helper.py
    │   utils.py
└───static
    └───css
        │   default.css
└───telebot
    │   mastermind.py
    │   sisuratNotif.py
    │   utils.py
└───templates
    │   accountExist.html
    │   authPhoneNumber.html
    │   changePhoneNumber.html
    │   failedChangePhoneNumber.html
    │   failedToLoginSSO.html
    │   failedToLogoutSSO.html
    │   loginSSO.html
    │   successChangePhoneNumber.html
    │   successToLoginSSO.html
    │   successToLogoutSSO.html
│   app.py
│   config.py
│   manage.py
│   README.md
│   requirements.txt
```

## Application Configuration
Make sure to have those environment variable before running the app:
- APP_SETTINGS=\<which config that you want to use\>
- BOT_TOKEN=\<your bot token that acquired from telegram bot father\>
ZAKI RAIHAN's avatar
ZAKI RAIHAN committed
54
55
56
57
58
59
60
61
62
63
64
- BOT_USER_NAME=\<your telegram bot username\>
- URL=\<your server url name\>
- SSO_UI_URL=\<SSO UI CAS URL\>
- DATABASE_URL=\<your postgre database URL\>
- API_CS_CLIENT_SECRET=\<akun.cs client secret key\>
- API_CS_CLIENT_ID=\<akun.cs client id key\>

## Features
### 1. Authentification Using akun.cs.ui.ac.id
Authentication Flow:
- User use command /login from their notification bot
ZAKI RAIHAN's avatar
ZAKI RAIHAN committed
65
- Bot will send authentication link to User, the link will be used to authenticate user SSO account using akun.cs.ui.ac.id (link example: https://\<yourServerUrl\>/loginsso)
ZAKI RAIHAN's avatar
ZAKI RAIHAN committed
66
67
68
69
- User will login to akun.cs.ui.ac.id using their SSO account
- If User account registered to akun.cs.ui.ac.id, User could fill their phone number that associated with his/her telegram account
- User phone number saved in database, the notification settings still deactivted
- If User account not registered (maybe wrong username or password) they could retry to login again
ZAKI RAIHAN's avatar
ZAKI RAIHAN committed
70

ZAKI RAIHAN's avatar
ZAKI RAIHAN committed
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
### 2. Activate and Deactivate Notification (From Telegram Bot APP)
Activate Account Notification:
- User use command /activateNotif in telegram bot chat room
- Chat bot will ask User if they want to share their contact to bot
- User share their contact, then server will save the chatId from contact to database associated with phone number that has been registered through authentification process
- User will recieve notification that being push by Information System in Fasilkom UI
  
Deactivate Account Notification:
- User use command /deactivateNotif in telegram bot chat room
- Chat bot will automatically delete chatId in database, so User won't recieve any notification

### 3. Push Notification Custom Message
If any information system want to send custom push notification to specific User, they could this API:
- URL: https://\<your server main url\>/sendNotification/custom
- Method: POST
- Request Body:
  
        {
            "username": <User SSO username>,
            "message": <Custom massage that want to be given to the User>
        }   

After that user will recieve notification based on custom message that being send

### 4. Push Notification for surat.cs.ui.ac.id Using Template
If surat.cs.ui.ac.id want to send notification to user that request to make Letter, they could use this API:
- URL: https://\<your server main url\>/sendNotification/sisurat
- Method: POST
- Request Body:

        {
            "username": <User SSO username>,
            "type": <Enum type of letter creation status, see definition below>,
	        "judulSurat": <The letter tittle>
        }
- Letter creation status enum:
  - 0 : "Diajukan"
  - 1 : "Ditolak"
  - 2 : "PersetujuanDosen"
  - 3 : "Proses"
  - 4 : "Selesai"

ZAKI RAIHAN's avatar
ZAKI RAIHAN committed
113
After that user will recieve notification based on their letter creation status, using template that has been configured. See files at "./telebot/sisuratNotif.py" to see messages template