- Celonis Product Documentation
- Automation
- Action Flows in Celonis Platform
- Action Flow blueprints
- Use case templates for Action Flows
- Archive invoice attachments in emails to Sharepoint
Archive invoice attachments in emails to Sharepoint
Saving invoices by hand can be annoying. That's the reason we provide you with that automation solution which stores invoices that were sent to you via Mail automatically. Imagine you always have to search for those invoices in your mails and if you search for invoices you get all invoices of all companies unsorted. After setting up this action flow all those files will be automatically stored at your desired storage place, making sure that invoices sent by the same person are stored within the same folder. You could also rename them using the naming convention you prefer (e.g. including the receiving date of the invoice).
Follow the step-by-step guide below to implement this solution for your Celonis Action Flows use case.
Sample Action Flow
The image below shows a working Action Flow which:
Parses your emails and select those which include the phrase 'invoice' in the subject or main text.
Filters the attachments of those selected mails for those including 'invoice' in their title.
If not already existing, a folder with the senders name is created and the invoice uploaded inside. If there is already a folder with the senders name the invoices are saved inside.
Configuring Action Flow
Below you will find the step-by-step guide for configuring each module of the above Action Flow.
1. Parse Emails
In the example provided above, mails are gathered from a mail account using the "Email" action. The screenshot on the right shows how this module has been configured.
You additionally have the possibility to filter specific mails.
Folder: You can choose a folder where the mails you want to use are currently saved (we chose the INBOX in the example)
Criteria: You can define more Criteria like only choosing unread/read mails or all
Sender email address: you can define a sender from whom the mails to use will come/came.
Note
We do not use the subject or phrase filter here as both are case sensitive (if you put the word 'invoice' here, mails including the word 'Invoice' in their subject/text will not cause a match as the 'i' is one time upper and one time lower case). Instead we use the Filter which we will set up after adding the next module.
Configuration:
Action Flows Module: Email
Action: Watch Emails
2. Iterate through attachments
To face the possibility of having more than one attachment in a mail we need to set up an iterator to make sure every attachment is checked.The screenshot on the right shows how this module has been configured.
Configuration:
Action Flows Module: Flow Control
Action: Iterator
3. Set up filter for mails
Set up a filter between the mail module and the iterator for with a throughput of mails which contain the word invoice either in their subject or text. The screenshot on the right shows how this filter has been configured.
Note
It is important to take the condition 'contains' which is case insensitive to make sure differences in upper or lower case letters are ignored.
4. Create Folder
To have more specific places to save the invoices in we want to create a Folder for each sender where we collect all the invoices we got from them. To do this we choose the create a Folder module. and
New Folder Name: 'Sender name' item from the Email module
same name handler: 'End with the error'. (This iscrucialfor the AF to work properly.)
Configuration:
Action Flows Module: OneDrive
Action: Create a Folder
5. Set up filter for attachments
Set up a filter between the iterator and the OneDrive module with a throughput of attachments/files which contain the word invoice in their name. The screenshot on the right shows how this filter has been configured.
Note
It is important to take the condition 'contains' which is case insensitive to make sure differences in upper or lower case letters are ignored.
We are now getting to the part where we split our Action Flow without a Router. But How is this possible? One of the two routes is an Error handler and the other one is the normal route which is executed when the module before doesn't fail. If the model before fails this means that we already have a folder with the defined name (we defined that in 4. Create a Folder) and do not want to add the same folder again but upload the invoice in that folder. That's why we use as an error handler the Update a file module.
6. Add error handler (Folder already existing)
Right click on the 'create a folder' module and choose the option 'Add error handler'. Add the 'Upload a file' module and set it up as in the screenshot.
Enter(Folder Location ID & Path): Folder Location Path (this is important to be able to find the right folder by name)
Folder: choose the item 'Sender name' from the mail module (→ we tried to set up a folder with that name which already existed, so we can access it like that)
Source file: Map (this will give us the possibility to change the naming of the file/invoice and make it unique)
File Name: We chose to construct the name out of the mails date and the original file name. Choose a name structure you want but make sure it will be unique!!
{{formatDate(1.date; "YYYY.MM.DD")}}_{{3.fileName}}
Data: data item of the iterator
Same name handler: set it to 'End with the error' as renaming the incoming file will lead to saving it outside the folder. Thus it is crucial to have unique file names.
Configuration:
Action Flows Module: OneDrive
Action: Upload a File
7. Upload invoices (after the folder was created)
To make it as easy as possible just right click on the error handling module created before and clone and connect it to the 'create a folder' module. The only thing you should change is
Folder: Name item of the 'Create a folder' module
Configuration:
Action Flows Module: OneDrive
Action: Upload a File
Potential Alternatives
You could replace the One Drive module with a storage place of your choice e.g. Google Drive
For more complex use cases where filtering the subject or content is not sufficient, you could use the Text Parser module