This project automates the processing of emails within the CDESK system. It covers fetching new emails, identifying specific actions based on the email content, and performing operations such as creating discussions or requests according to the information obtained.
The script is built as an Azure Function App, as an alternative to the local Dockerised version. Since it runs in the cloud, the application logs cannot be viewed through the local application; instead, they are available in the Azure service. This manual provides a step-by-step guide to creating a Function App using Visual Studio Code. For other methods, if needed, see Microsoft’s official documentation.
This script serves as a demonstration of data processing in CDESK and the automation of object creation – in this case, processing emails and creating requests with a discussion.
function_app.py
The main entry point of the application. The script runs every 5 minutes, initialises the connection to CDESK, fetches new emails, processes each email according to its action code, and logs out once finished.
ConnectionController.py
Handles the connection to the CDESK API. It manages the login process, maintains the session, and performs GET and POST requests with the required authentication.
ObjectController.py
Contains methods for interacting with CDESK objects, such as emails and requests. It includes functions for fetching emails, processing them, and creating discussions or requests based on the email content.
LoggerController.yml
Used to print log messages to the function app logs.
docker-compose.yml
Defines the Docker environment for running the email processing script. It sets up the required environment variables for connecting to CDESK and specifies the network configurations.
last_email_id.txt
A document containing the ID of the last processed email.
First, you must have at least one email in Message processing -> Message processing with a certain combination of content.
This email should contain a combination of capital letters and numbers, 6 to 8 characters long. This combination can be given either in the subject or the body of the email and will represent the parcel number that the script will process. In addition, the email may contain words about the destination (e.g. Destination: Testovacia 11, Bratislava), which will be added to the newly created request as a custom field.
Example email:
Subject: Dispatch notification NK123455
Body: Dispatch notification NK123455. Destination: Nová 34, Bratislava. Used for testing purposes only.
First, you will need a custom field that the script will use and that will be added to the newly created request when the email is processed. To create a new field, you can follow these steps:


After creating the custom field, you will need to set the following data from CDESK in the script (as environment variables in the docker-compose.yml file):



You can find it in the menu / tiles -> Configuration database (or CMDB) -> User-defined fields -> Custom fields.
Then find the required custom field, open it, and find its ID in the URL address.
Then find the required custom field, open it, and find its ID in the URL address.
You can find it in the menu / tiles -> Configuration database (or CMDB) -> User-defined fields -> Base properties
Also, to visualise the logs generated by this script, you need to set up a volume mapping to a directory on the local PC or server. This directory can be /logs in the application for logs, which is specifically created for this purpose.
Search for and install the following extensions:


Name: any name for the resource, for example my-email-processing-script
Runtime stack: If possible, select a newer version of Python, for example Python 3.11.
Resource location: Select a location that is geographically close to you.





Note: Cron – This entire script, when dockerised, is set up as a cron that runs every 5 minutes.
While running, the script generates logs that can be monitored in docker logs. These logs contain initialisation messages, progress updates, and any errors.