Skip to content
This repository was archived by the owner on Mar 31, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ dist/
vendor/
.gh_token
*.min.*
.DS_Store
203 changes: 203 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@

* [Synopsis](#synopsis)
* [Build Status](#build-status)
* [Updates Roadmap for version 3.0](#updates-roadmap-for-version-3)
* [New TelegramBot Commands](#new-telegramBot-commands)
* [Installation](#installation)
* [Installation and Configuration step by step](#installation-and-configuration-step-by-step)
* [Documentation](#documentation)
* [Versioning](#versioning)
* [Contact](#contact)
Expand All @@ -31,12 +34,212 @@ This Bot for GLPI allows you to get notifications on Telegram when a ticket is c
|:---:|:---:|
|[![Travis CI build](https://api.travis-ci.org/pluginsGLPI/telegrambot.svg?branch=master)](https://travis-ci.org/pluginsGLPI/telegrambot/)|[![Travis CI build](https://api.travis-ci.org/pluginsGLPI/telegrambot.svg?branch=develop)](https://travis-ci.org/pluginsGLPI/telegrambot/)|

## Updates Roadmap for version 3.0

- [x] New Ticket.
- [x] Search ticket.
- [x] New followup.
- [x] Support group notification.
- [x] Login.

## New TelegramBot Commands:
**Commands List:**
```
/help - Show bot commands help.
/login - Login via Telegrambot for GLPI. The login command will only work on private chat.
Group chat Login Command is forbidden.
/newfollowup - Add a new followup to a ticket on GLPI via TelegramBot.
/newticket - Add a new ticket on GLPI via TelegramBot.
/searchticket - Search for a ticket on GLPI via TelegramBot.

For exact command help type: /help <command>
Or just type the command name: /<command>
```

## Installation

Click on the image to view the video preview.

[![Everything Is AWESOME](http://img.youtube.com/vi/TKqIpIaAIAE/0.jpg)](https://youtu.be/TKqIpIaAIAE)

## Installation and Configuration step by step

Here is a step by step of the video above:

- Create your Telegram BOT on Telegram App:
- Search for BotFather on Telegram.
- Start a new chat with it.
- Type /newbot and send.
- BotFather will reply:
> Alright, a new bot. How are we going to call it? Please choose a name for your bot.
- Type the name of your bot and send. Ex.: GLPI Telegrambot Demo.
- BotFather will reply again:
> Good. Now let's choose a username for your bot. It must end in `bot`. Like this, for example: TetrisBot or tetris_bot.
- Type the username of your bot and send. Ex.: glpi_telegrambot_demo_bot.
- Finally BotFather replies with:
> Done! Congratulations on your new bot. You will find it at t.me/glpi_telegrambot_demo_bot.
> You can now add a description, about section and profile picture for your bot, see /help for a
> list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support
> if you want a better username for it. Just make sure the bot is fully operational before you do this.
>
> Use this token to access the HTTP API:
> 872970295:AAFsALgD0WH9BOp-ZU282JVN_lW3l56GZEA
> Keep your token secure and store it safely, it can be used by anyone to control your bot.
>
> For a description of the Bot API, see this page: https://core.telegram.org/bots/api
- Save the token to access and the bot username to use it late.

- Config your bot to group messages:
- Now type /setprivacy to BotFather. This command can be executed any time.
- BotFather replies with:
> Choose a bot to change group messages settings.
- Type (or select) @<your_bot_username>
(change to the username you set at step 5 above, but start it with @) Ex.: glpi_telegrambot_demo_bot.
- BotFather replies with:
> 'Enable' - your bot will only receive messages that either start with the '/' symbol or mention the bot by username.
> 'Disable' - your bot will receive all messages that people send to groups.
> Current status is: ENABLED
- Type (or select) Disable to let your bot receive all messages sent to a group. This step is up to you actually.
- BotFather replies with:
> Success! The new status is: DISABLED. /help

- Download:
- Go to the [download page](https://plugins.glpi-project.org/#/plugin/telegrambot) and get the latest version (3.0) of our plugin.
- Unpack the file and put the folder /telegrambot under: /<your_server_path>/glpi/plugins
- The final path must be: /<your_server_path>/glpi/plugins/telegrambot

- Installation:
- On your GLPI application open the menu: Setup -> Plugins.
- You will see the catalog of plugins.
- Our TelegramBot for GLPI will be there on the list.
- On the column Action, click on the Install icon.
- After the installation click on the Enable icon.
- If your plugin installation didn't work, we have to make some workarounds:
**Unfortunately we have to make some changes on GLPI 9.4.x core to Telegrambot work properly:**
**Attention:** If all your Plugins folder name starts with lowercase letter, this modification has no impact at all on your GLPI Aplication.
- Go to file: **/glpi/inc/plugin.class.php**

**Plugin::load() - line 161 (GLPI 9.4.2)**
```php
static function load($name, $withhook = false) {
global $LOADED_PLUGINS;
$name = strtolower($name); //-> Add this line
...
}
```

**Plugin::loadLang() - line 193 (GLPI 9.4.2)**
```php
static function loadLang($name, $forcelang = '', $coretrytoload = '') {
// $LANG needed : used when include lang file
global $CFG_GLPI, $LANG, $TRANSLATE;
$name = strtolower($name); //-> Add this line
...
}
```

**Plugin::doHook() - line 1105 and 1124 (GLPI 9.4.2)**
```php
static function doHook ($name, $param = null) {
...
if (isset($PLUGIN_HOOKS[$name]) && is_array($PLUGIN_HOOKS[$name])) {
foreach ($PLUGIN_HOOKS[$name] as $plug => $tab) {
$plug = strtolower($plug); //-> Add this line
...
} else { // Standard hook call
if (isset($PLUGIN_HOOKS[$name]) && is_array($PLUGIN_HOOKS[$name])) {
foreach ($PLUGIN_HOOKS[$name] as $plug => $function) {
$plug = strtolower($plug); //-> Add this line
...
}
```

**Plugin::doHookFunction() - line 1158 (GLPI 9.4.2)**
```php
static function doHookFunction($name, $parm = null) {
global $PLUGIN_HOOKS;

$ret = $parm;
if (isset($PLUGIN_HOOKS[$name]) && is_array($PLUGIN_HOOKS[$name])) {
foreach ($PLUGIN_HOOKS[$name] as $plug => $function) {
$plug = strtolower($plug); //-> Add this line
...
}
```

- Setup the Notifications:
- On your GLPI application open the menu: Setup -> Notifications.
- A 'Notifications configuration' table will be displayed.
- You will see a 'Enable followup' option, change to Yes.
- You will see a 'Enable followups via Telegram' option, change to Yes.
- Click on Save button.
- A new table with the title 'Notifications' will appear.
- Click on 'Telegram followups configuration'.
- On 'Bot token' field PASTE the token to access the HTTP API given by BotFather. Ex.: 872970295:AAFsALgD0WH9BOp-ZU282JVN_lW3l56GZEA
- On 'Bot username' field PASTE the username of your bot on Telegram. Ex.: glpi_telegrambot_demo_bot.
- Click on 'Save' button.

- Setup the Automatic actions:
- Open the menu: Setup -> Automatic actions.
- A list with the 'Automatic actions' will be displayed.
- Search for 'messagelistener' and click on it.
- A log page will be displayed. Click the menu button 'Automatic actions' on the left.

- Configure the GLPI user:
- On your GLPI application open the menu: Administration -> Users.
- Select the user. Ex.: glpi.
- On the bottom of the form displayed, you will see a 'Telegram username' field.
- On this field put the Telegram username and save.

- Setup the notification:
- On your GLPI application open the menu: Setup -> Notifications.
- On the Notification table, click on 'Notification templates'.
- Click on 'Add' icon and the 'New item - Notification template' form will be displayed.
- Choose a name for your template and the 'Type' choose 'ticket'.
- Click on 'Add' button.
- A 'New item - Template translation' form will be displayed.
- On 'Subject' field put the message that will be send to your Bot.
- On 'Email text body' field put the text:
```
New Ticket
ID: ##ticket.id##
Title: ##ticket.title##
```
- Click on 'Add' button.
- Go back to Setup -> Notifications -> Notifications.
- Click on 'Add' button.
- A 'New item - Notification' form will be displayed.
- Choose a name to your item notification.
- Change 'Active' field to 'Yes'.
- Change 'Type' field to 'Ticket'.
- Change 'Event' field to 'New ticket'.
- Click on 'Add' button.
- The notification page will be displayed. Click the menu button 'Templates' on the left.
- Click on 'Add a template' button.
- Change the 'Mode' field to 'Telegram'.
- Change the 'Notification template' to the name you choose before to your template.
- Click on 'Add' button.
- Go back to Setup -> Notifications -> Notifications.
- Search for the Notification you just added and click on it.
- The notification page will be displayed. Click the menu button 'Recipients' on the left.
- On the blank field, choose the options 'Administrator' and 'Requester'
- Click on 'Update' button.

- Test your Bot:
- Go to your Telegram App and start a chat with your Bot. Ex.: glpi_telegrambot_demo_bot.
- Send a message: Ex.: Hello
- Go back to 'Automatic actions' page on GLPI and click on the button 'Execute'
- Click the menu button 'Logs' on the left.
- You will see a new entry. Thats our 'listener'.

- Setup the Ticket:
- On your GLPI application open the menu: Assistance -> Create Ticket.
- Choose a 'Title' and a 'Description' to your Ticket.
- Click on 'Add' button.

- Test your Bot result:
- After you Setup the Ticket, the user will receive a Notification Ticket on Telegram.

## Documentation

We maintain a detailed documentation of the project on the website, see our [How-tos](https://pluginsGLPI.github.io/telegrambot/howtos) and [Development](https://pluginsGLPI.github.io/telegrambot/) sections.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require-dev": {
"glpi-project/tools": "^0.1.2"
"glpi-project/tools": "^0.1.7"
},
"require": {
"longman/telegram-bot": "*"
Expand Down
Loading