How we organized the automatic sending of appeals to government bodies

Hello! I work in the project team "Angry Citizen". I would like to tell how our communication with government organizations is organized.
There are 3 types of cooperation:
- According to the second article of the Federal Law dated 02.05.2006 N 59-ФЗ “On the Procedure for Considering Appeals of Citizens of the Russian Federation”;
- According to the signed agreement;
- Based on the “Satisfied Citizen” system.
The whole process from the creation of the application to the response from the organization can be divided into 3 stages:
- Filling out the form and creating an application;
- Sending a message to government organizations;
- Receiving a response from the organization.
Filling out the form and creating an application

There are about 500 different categories of problems in the rubricator of the “Angry Citizen” portal and each category has its own specific form for creating appeals. This is a small mechanism called AngryForm. By the way, we write it in PHP. It contains metadata of forms and is able to process them. AngryForm knows how to form an appeal from the completed form and to whom it should be sent. Perhaps I will write about AngryForm in detail in a separate article. So, the user searches for his category of problems and fills out a form on it. Applications are generated based on data received from the user.
Sending a request
After the appeal is generated, you need to send it to someone. We have a base of organizations and all kinds of methods of communication with them. Organizations are attached to certain problems and, depending on the chosen category and region, the appeal is sent to the specific representative office of this organization.
As soon as the organization received the appeal, it has a certain period within which it must give an answer to the applicant, and if it does not fit within this period, then the user can send a complaint to the prosecutor’s office - also through our service.
There are several channels of communication with organizations:
- Email;
- Fax;
- Portal API
Depending on the communication channel that is available at the dealership we need, sending takes place in different ways. I’ll briefly talk about fax and portal APIs.
Fax Delivery

Everything is simple here, the call is sent through the API to the fax of the responsible organization. For calls that are sent by fax, a unique email address is created on AngryMail (about it below), where he expects a response from the organization. The response from the organization comes through the AngryMail channel.
Delivery of calls through the API of state portals

Now we have integration with several portals such as gorod.mos.ru and openregion71.ru. If these portals fall under the conditions that the user has chosen, then calls come, in addition to our service, to these portals. Having received an answer to these requests, they also appear on our portal. Throughout the time, we are polling the servers of these portals for answers to our applications. And if the answer is found, then it falls into the timeline of our portal.
Email Delivery

It’s more interesting here. Together with the creation of the appeal, a chain of correspondence is created between the user and the organization’s representative office. After creating a call and a chain, it enters the queue for sending calls. As the queues we use RabbitMQ. From the queue, the call goes to AngryMail.
AngryMail is a Java application that handles incoming and outgoing e-mail messages. AngryMail assigns an identifier to the chain and generates a return email in the format {id►@angrymail.ru, to which a reply will be waiting.
The organization responds to the generated email address ({id} @ angrymail.ru), as a rule, with attached documents with all seals and signatures. As soon as AngryMail receives a similar email, it sends it to the AngryCitizen service. The response is attached to the timeline of the appeal on the portal and a notification is sent to the user.
If very briefly, then so. The work of our service does not end there, but that's another story.
Thank you for reading the article to this place.
If interested, I will continue to talk about life in our project along with technical subtleties.