Welcome to ProjeQtOr new Forum. We migrated old forum to the new website.
You will find all your posts here, with your usual account.
Just one point : you’ll have to reinitialize your password. Use “Lost password” feature.
Good morning, or good evening
For the last 3-4 weeks, I've been tinkering a bit with projeqtor for my brother. He wanted some new features so I had a go.One of them was a way to send notifications to users in a better way than mails. Indeed, he didn't really like the idea of receiving several emails for simple notifications such a ticket's state change. So I added a few lines to the "SqlElement.php" file so that, when sending mails, it first checks if the person has a custom field containing their Telegram id, and if so, sends the notification via Telegram.
However, I know that it won't be easy to maitain this feature trhough the future versions since I modified one of the main files, so I was wandering if it was possible to make it as a plugin. I've attached the modified file (for projeqtor v9.0.5). I've also used node-red to manage the bot in order to redirect new messages to a script (also attached as "telegram_bot.php").
Configuration:
- First, add two custom fields to the Resource class: an "idTelegram" field (varchar) to store the telegram id (like "@ARandomId") and a chatIdTelegram field (varchar). Both need to be visible and you can put chatIdTelegram as readonly.
- In SqlElement.php: You just need to replace "YOUR_URL" with the url of your server and "YOUR_BOT_TOKEN" with your Telegram bot token.
- In telegram_bot.php: You need to replace "USER:PWD" with a valid projeqtor user and password, "YOUR_API_KEY" with the corresponding API key, "YOUR_URL" with the url of your server and "YOUR_BOT_TOKEN" with your Telegram bot token.
You can also change the message at the end of "telegram_bot.php" in the $msg variable (I wrote them in french sry).
Does this seem to be a good enough idea to make it a plugin ?
Anyway, I hope this will help others and maybe reach your interest
Hi,
Your idea is interesting, replacing emails with chat interface.
I had a look at your code, and there are few things that will have to be improved :
- parametering of all parameters you defined as Strings.
- translation of messages (we do not accept hard coded messages, with only exception in technical log writing in english)
- why restrict to Telegram ?
Trick : you can add in parameters.php
$myParameter='YOUR_PARAMETER';
then use is projeqtor code
Parameter::getGlobalParameter('myParameter');
We'll then just have to "move" the parameters from file to DB to intergate it, and possibly change it as user parameter...
I understand reasons that let you prefer Telegram to other chats, but I think this could be easily extended to many other chats, such as Whatsapp, Messenger, Discord, ..
Also it is difficult to imagine this as a plugin, but possibly it could be included in community version.
It's too late for V9.1 that is under testing before soon deployment, but we'll have a look at this for V9.2.
I recorded Ticket #5359.
Thank you very much !
Of course parametering would be a necessity if it were to become a full feature. I went for the easy way by hard-coding the messages cause it was only on a very small scale but I admit it's not optimal.
Concerning other chats, Messenger and Discord would be quite easy to implement but Whatsapp would be a bit tricky I believe since you can't easily make a Whatsapp bot.
Thank you very much for your reply and for considering my idea
Small correction, the line (in SqlElement.php)
$res = $resource->getSqlElementsFromCriteria ( array("idTelegram"=>str_replace("@tg@", "", $adr)), false );
should be
$res = $resource->getSqlElementsFromCriteria ( array("idTelegram"=>str_replace("@tg", "", $adr)), false );
(without the second "@")
and the line
array_push($tgUsers, $res[0]->chatIdTelegram);
should be
if (!in_array($res[0]->chatIdTelegram, $tgUsers)) {
array_push($tgUsers, $res[0]->chatIdTelegram);
}
(sry, I've just found out about these problems)
Hello again,
I also added the possibility to create templates for the messages. It works exactly the same as email templates. I added a page and copied the email template class (modified so that it doesn't create html but a more suitable message for telegram). Though it's not perfect, it works pretty well !
Don't know if it would be interesting enough to implement it
Yes, please post your files.
We'll have a look at oppotunity toi integrate it on V9.2
Sure,
Here is the modified SqlElement.php and the new TelegramTemplate.php.
Main modifications of SqlElement (from the last I posted) are on lines 5293, 5600 to 5638 and 5705.
Here are the SQL statements I used to modify the database:
INSERT INTO menu (id, name, idMenu, type, sortOrder, level, idle, menuClass, isAdminMenu, isLeavesSystemMenu) VALUES ( 200000000, 'menuTelegramTemplate', 88, 'object', 686, 'ReadWriteAutomation', 0, 'Automation', 0, 0);
INSERT INTO navigation (name, idParent, idMenu, idReport, sortOrder) VALUES ('menuTelegramTemplate', 129, 200000000, 0, 21);
CREATE TABLE telegramtemplate ( id INT(12) UNSIGNED NOT NULL AUTO_INCREMENT, name VARCHAR(100) NOT NULL, template VARCHAR(500) DEFAULT NULL, idMailable INT(12) DEFAULT NULL COMMENT '12', idType INT(12) UNSIGNED DEFAULT NULL COMMENT '12', idle INT(1) UNSIGNED DEFAULT '0' COMMENT '1', PRIMARY KEY (id), KEY emailtemplateMailable (idMailable) );
ALTER TABLE mailtosend ADD idTelegramTemplate INT(12) UNSIGNED DEFAULT NULL;
And the not really needed icons are also attached.
Thanks.
Added new files in the ticket for integration on V9.2.
Hello again, quick update
I've nearly finished implementing another feature to the bot. You are now able to create tickets via Telegram. You can define some fields and specify a "Ticket Model" in which you can set default values for frequent similar tickets. I'll post the files when it's completly done
Update:
I added the possibility to create tickets directly from Telegram and to view information about tickets and activities (can easily be extended to other classes)
- available commands:
- /ticket (create a ticket)
- /afficher (display element info)
- /stop (stop current command)
- /report (report a bug)
- /about (sends info about the bot)
- /ticket:
- Asks the name of the ticket
- Display fields that can be set
- You can choose a template (more about below) with predefined field values
- When you click on "Créer" (create), it prints a summary of the ticket and let you modify or save it
[list=1]
- New menu in Automation
- You can create ticket templates with predefined field values
- When creating a ticket with the bot, you can choose a template and it will automatically set the values defined in the template
- Currently available fields for ticket templates:
- ticket type, project, activity, responsible, urgency, criticality, context (1 and 3, bc we only needed these two)
[list=1]
[list=1]
- I just added a field to Statuses and Priorities to set an emoji representing the said stat./prio. (not optimal since I can only use UTF-16 emojis due to some limitations of the database encoding I believe)
- These emojis are used for notifications and in the list of displayable elements
- Sends a message to the hardcoded chatId (mine) with details about current status of the bot for the sender user. Not much but it can help debug some problems
That's it ! (I think). I still have some ideas in mind and so does my client (my brother 🙂 ). Though there's still a lot of place for improvement (hardcoded values, repeated blocks, unclear statements, no translations), I'm pretty proud of that bot. I've linked the files for the bot and for the TicketTemplate menu.
To make it work, I also had to insert some lines in the database and create some tables:
-
INSERT INTO menu (id, name, idMenu, type, sortOrder, level, idle, menuClass, isAdminMenu, isLeavesSystemMenu) VALUES ( 200000001, 'menuTicketTemplate', 88, 'object', 694, 'Project', 0, 'Automation', 0, 0);
-
INSERT INTO navigation (name, idParent, idMenu, idReport, sortOrder) VALUES ('menuTicketTemplate', 129, 200000001, 0, 51); -
CREATE TABLE tickettemplate ( id INT(12) UNSIGNED NOT NULL AUTO_INCREMENT, name VARCHAR(100) NOT NULL, idTicketType INT(12) UNSIGNED DEFAULT NULL COMMENT '12', idProject INT(12) UNSIGNED DEFAULT NULL COMMENT '12', idle INT(1) UNSIGNED DEFAULT '0' COMMENT '1', idContext1 INT(12) UNSIGNED DEFAULT NULL, idContext3 INT(12) UNSIGNED DEFAULT NULL, idActivity INT(12) UNSIGNED DEFAULT NULL COMMENT '12', idUrgency INT(12) UNSIGNED DEFAULT NULL COMMENT '12', PRIMARY KEY (id), KEY ticketTicketType (idTicketType), KEY projectProject (idProject), KEY ticketActivity (idActivity), ticketUrgency (idUrgency) );
And here is my nodered flow:
Hi,
Thanks for your contribution.
I added your post as note on ticket to include it on comlmunity version.
Would it be easier if I created a github repo, so you don't have to do this every time I've made modifications ?
Oh and I just found a bug, the line after "//Come back to class selection" should be
$state = 0;
instead of
$state = 100;
(Hence the usefulness of a repo)
Yes, it can be a good idea.
But please, keep informing use when you publixh changes in the repo ! 😉
Of course no problem, I'll make it and post the link when it's done (probably next week)
Big News
First, I have made some progress on the bot:
- You can now create questions and reply to them
- A new command "/reference" let you display an element from their reference
- Thanks to inline bots, you can also @ the bot and start typing a reference for a list of matching elements. You can choose one and it will display its details
Now for the second thing:
I finished creating a Github repository. I uploaded all the files and spent some time (maybe a lot of time
) to write a readme, changelog and installation instructions. In the future, I will post all the files on it but I will still make a post on the forum to keep you updated.
Although I've made a lot of progress this last two weeks, this project is still in development, with (several) other planned features. The code is also not optimal at all and very messy. I am going to refactor the entire bot in the near future, as stated in the todo list. So if you want a stable, clear and understanble script, you'll have to wait. I know you (babynus) have included this as a possible evolution for V9.2 (many thanks) but I don't know if I will be in time with the complete rewriting of the script. Maybe this wibbly wobbly piece of PHP is sufficient for your needs but don't hesitate to contact me to ask for explanations. I believe the refactored script will be more suitable for your reading though
That's it !
I hope this will help and please people, and that you will check out the repo
Have a nice day !
Baryhobal
PS: I did my best to respect the copyright law but it may be too much or not enough. Let me know if I did anything wrong, thx
Hi,
Thanks for your contribution.
I posted a reference to your work (to the github repository) in the Download page, in section Contributions.
I also added you in the contributors list.
Possibly we'll wait for a stable version from you to integrate into ProjeQtOr parts that may be required in core of software.
We're not in a hurry and may wait to integrate in in V9.3...
Users who want to try it can follow your instructions that seam quite clear...
You did a great job.![]()
Only remark I can tell a this poitn of analysis : I did not find how to use the bot (some user manual)
Regards.
Hello everyone,
Here is a little update about the project. V5.0 is available on the github. It doesn't add much but you can now edit and add notes to elements.
I have now started the process of refactoring the whole bot script, rewriting it from scratch in a, hopefully, more structured and clearer way.
This will probably take me some time to finish (even if it's the summer holidays) but I will let you know when it's done.
That's it !
I hope you're having a nice day and see you soon for V6.0 !
PS: I know, the version numbering is not structured at all and pretty random. From V6.0 and after, I'll try to keep a consistent naming
Big News: V6.0.0 is out !!!
I have finally finished the refactorization of the bot. Everything is now available in the Github repo.
What is new, you may ask. Well, here's a list of some of the changes:
- Most importantly, clearer and more structured code (at least I hope)
- Display templates: write your own custom messages to use when displaying elements
- Summary templates: organize the summary messages displayed after creating an element and choose which fields to show
- Translations: the bot now uses the personalized translations system, allowing internationalization of messages and buttons (french and english are already available)
- Settings for the bot are no longer written in the script but can now be modified in the global parameters menu. You can also modify the command names
- /reference and /afficher (display) have been combined into one command -> /chercher (search)
This version has not been tested extensively yet, but it should still work well (I would say ~98% reliability). If you find any bug, please let me know by creating an issue on Github.
Also, if you want to participate and translate the messages and button texts, please share it either here or on Github.
V6.0.0 can be considered as a beta version and should be relatively stable with no major changes planned for the moment. I hope this project will be helpful to the development of ProjeQtOr and to its community.
Finally, if you have any questions, suggestions or encounter any problem, don't hesitate to contact me either on Github or on this forum.
That's it ! Have a nice day !
EDIT: I forgot to precise, this has been developped for ProjeQtOr V9.2.1
Hello !
V6.0.1 is out
This versions fixes the issues that we have found in V6.0.0. There may still be some. If you find any, please report them on the github repo.
List of fixes:
- "Leave empty" button when selecting a template (ticket creation) now works
- "Leave empty" button when choosing a project (ticket creation) now works
- Added translations for "telegramBotMsgFieldProj" and "telegramBotMsgInvalidFieldEstimatedWork"
- When using the search command, if no display template is defined, a message is now displayed (instead of crashing)
- When selecting a template/urgency/priority/criticality/..., only non-idle items are displayed
Next version should be V6.1.0 and should implement the following key features:
- Possibility to add sub-tasks (point à traiter)
- Correct use of projeqtor's habilitation system (for displaying and creating elements)
For the devs:
I realise now that I haven't really documented the "notification" part of the bot. Let me know if you would like me to highlight the changes I did to SqlElement.php and more generaly give you information about how it works
If feel like the current state of the bot would be a great addition to ProjeQtOr, but the changes planned for V6.1.0 also seem interesting.
I saw you put Ticket # 5359 in ProjeQtOr V9.4.0. I don't know when you will start developping (maybe/probably already started ?) but I should have finished the planned features for the end of November.
Here is the github repo again
I hope you all have a wonderful day
See you soon
Baryhobal
EDIT:
As it turns out, I needed to rethink a significant part of the creating process. This means that modularity will be further improved compared to V6.0.1.
Consequently, some minor changes will also be made, for example, questions will now use the same system of field choice as other elements (like tickets). The "name" field will now also be modifyable through the button menu.
Hello everyone
V6.1.0 is done
Main changes:
- You can now create sub-tasks ("points à traiter") with the create command
- You can configure which profile can use the create and search commands through habilitations
- A major security breach has been fixed. Credentials are now required to access the script (basic http authentification)
- Fixed issues when dislaying some elements' description (html tags were left rendering the text quite unreadable)
- ProjeQtOr's access rights are now respected regarding creation and display of elements
Everything is in the github repository
If you find any errors, please let me know.
Due to other projects, the development will probably slow down quite a bit. I don't have any scheduled date for the next version. There will probably be a patch sooner or later if we find some bugs though.
Future possible features include:
- displaying equipments
- changing location of equipment
- creating change requests
- displaying reports
- creating and displaying leaves
- adding the option to create a telegram group when creating a new project and allowing the bot to be used inside of groups
Of course these will be split into multiple versions.
For the devs:
As I said in my last post, this is probably the most stable version as of now (until we find bugs at least).
I don't know how much of this you plan on implementing, if anything, but I hope that you will find this interesting and maybe take a look at it
I wish you all a pleasant day/night
Baryhobal


