Bots for Finance: How to Increase Back-office Efficiency Through Automation
Automating basic financial functions can save your company time and money and free your employees from tedious rote tasks. Toptal finance expert Miklos Lukacs explains how building a simple Python bot can streamline your business.
Automating basic financial functions can save your company time and money and free your employees from tedious rote tasks. Toptal finance expert Miklos Lukacs explains how building a simple Python bot can streamline your business.
Miklos is highly experienced in finance processes, fintech, and Python programming. In addition to being a Toptal finance expert and software developer, he is the director of the structured finance consulting company Pylink Ltd.
Previous Role
CEOPREVIOUSLY AT
Mention of the office of the future might conjure up images of machines taking over repetitive and labor-intensive tasks. But that future is now. The development of technologies such as cloud-based applications, as well as software platforms and enterprise resource planning systems that help companies achieve peak operating efficiency, have made automated offices a reality.
According to the consulting firm McKinsey, corporate finance departments have reduced costs by almost 30% over the last decade by implementing automation solutions in areas like procurement, accounting, and payroll. These innovations have transformed finance functions and eliminated many inefficiencies.
As a financial analyst and software developer, I took full advantage of automation by setting up bots for finance tasks when I created and built my own consulting firm, Pylink. But many finance offices still haven’t, so they continue to spend an inordinate amount of time and resources performing basic tasks.
I’m not the only one to have noted the problem. The consulting firm PwC found that finance offices need to up their productivity and insight through automation and process improvement, which can reduce costs by double-digit percentages for many key functions. PwC’s research indicates that automation could cut 40% of time spent by people on management reporting, 27% of time spent on tax accounting, and 23% of hours devoted to credit management, general accounting, and billing.
Deloitte has reached comparable conclusions: Citing research published by Ayehu, it reports that intelligent automation decreases business process costs by 25 to 40%. And Gartner’s research reveals that a company with 40 full-time accounting staff members could eliminate over $870,000 in spending each year by automating tasks and eliminating extra work to fix human error.
In this article, I’d like to share some simple automation strategies that I’ve used for my company and my clients—easy fixes that can be useful for organizations of any size.
Off-the-shelf solutions like QuickBooks can be helpful for smaller organizations. However, to maximize efficiency, I advise using programming languages like Python to custom build your solutions, including bots for business. Python is very intuitive and provides a large standard library of tools, plus access to finance-specific libraries, making it more versatile than Excel.
In my previous article for Toptal, I showed how easy it is to use Python to develop bespoke cash flow models for corporations. I encourage you to read that if you’re interested in learning the language. In this article, however, I’ll give you an overview of practical applications—ranging from time tracking to payroll to email—that a developer can quickly and easily implement for you if you’re not interested in delving into the code yourself.
How My Firm Leverages Bots for Finance: Easy, Efficient Payments
Let me demonstrate how useful custom automation can be by showing you an example from my company, which can serve as a case study. Despite being a small business, my team at Pylink and I face considerable complexity that presents challenges when it comes to payments, including the following:
- We work on several projects based on hourly contracts and have to track the time of each of our tasks.
- Our clients are from different countries and thus pay us in multiple currencies.
- While we use an in-house software engineering team on some projects, we subcontract others to developers from different countries.
- From a tax optimization perspective, we have three companies: one UK-based, one EU-based, and one an EU-based individual freelancer.
- Each of our companies has separate bank accounts in multiple currencies, including USD, EUR, GBP, and HUF.
- We have regular costs—such as taxes, salaries and benefits for full-time employees, office space and supplies, and software—in different currencies.
To develop a payment system that would meet these challenges, I use (and recommend) the following technologies to create a Python bot running in the cloud infrastructure of Amazon Web Services (AWS).
- Codebase: Python (downloadable for free)
- Service on which the code is running: AWS Lambda
- Lambda makes it convenient to scale our code execution as needed.
- This service goes into effect only when it’s triggered. You put your Python code into a Lambda function and set up a trigger event—anything from an Alexa voice command to a scheduled calendar time.
- Since Lambda is serverless, it’s a cost-effective solution that requires us to pay only for the computing time we actually use.
- Bank operations tool: Wise API
- An API (application programming interface) is a software intermediary that allows two applications to communicate with each other. Wise API enables me and my team to get statement information and historical transaction data easily, as well as make payments automatically. It also lets us track currency exchange rates and make automated conversions.
- Time tracker: Everhour + Everhour API
- This software affords accurate time tracking and flexible billing and budgeting capabilities. Additionally, it integrates seamlessly with project management tools such as Asana, Trello, Jira, and GitHub.
- Email sender: Amazon Simple Email Service
- With Amazon SES, we have an adaptable and secure way of sending HTML emails from within any application, along with data analytics to monitor deliveries and bounces.
- SES’s Free Usage Tier allows you to send up to 62,000 messages per month at no charge if you activate the service from an application hosted in Amazon EC2 or through AWS Lambda.
- Scheduler: AWS EventBridge
- Using this tool, we can easily trigger our Python bot to perform scheduled finance functions monthly or semimonthly.
- Because EventBridge, like Lambda, doesn’t require a server for operation, it significantly reduces our overhead.
- Slack notification: Slack API
- This API sends real-time alerts to inform us of our contractors’ hours and tell us whether clients have paid us.
- Slack communication with the bot: Slack API + Amazon API Gateway
- The Slack API allows the Python bot to send us payment requests for approval.
- With a single click on our end, our bot is able to use API Gateway to complete each payment automatically.
- API Gateway offers a free tier that gives you access to over a million API calls and a million messages per month for a year.
Here’s how I used these tools to automate one multitask use case: paying staff, contractors, and myself. I’ll show you the whole process on a high level before diving into the most common automation practices.
Now let’s go through the steps:
- On the first day of every month, we use AWS EventBridge to trigger the Python bot that is stored in AWS Lambda.
- Using the Everhour API, the bot pulls timesheets for all employees, contractors (developers, in Pylink’s case), and me.
- Next, the bot aggregates the hours worked for each project and creates a timesheet and an invoice (both PDFs). Then it sends these documents to the clients via email.
- Additionally, the bot notifies Pylink’s team via Slack about the contractors’ hours. It also asks for permission to pay them by presenting “approve” and “deny” buttons.
- If someone from Pylink’s management team approves the request, the bot sends a message to our own API (an always available public URL) through AWS API Gateway, which executes another code in a Lambda function to make the transfer.
- The second Lambda function uses the Wise API to make the payment.
- On the 14th of every month, we again use EventBridge to schedule another run of follow-up functions. But this time, EventBridge triggers a different code saved in another Lambda function.
- This code uses the Wise API to track the transactions from the last two weeks and check whether the client has paid.
- If there has been a payment from the client, the bot sends a Slack confirmation to the Pylink team via the Slack API. If there has not been a payment, the bot sends an email to the client using Amazon SES service.
Previously, all of these tasks were done manually, consuming valuable time and energy that can now be spent elsewhere. Best of all, we were able to set up this process without a large investment of time or money.
What You Can Do With Automation
Now let’s look at some of the most practical applications for automation, using the tools I’ve already discussed. For your reference, I’ll include some coding examples as a resource for your in-house, contract, or freelance developers—or for yourself, should you choose to learn Python to assist with your company or client work.
Tracking Work Hours and Projects
At the end of every month, the bot (using Everhour) runs the “close_the_month” function that collects all of the hours that were spent on different assignments:
- My hours on my consulting projects (revenue)
- The developers’ hours on the client’s projects (both revenue and cost)
- The developers’ hours on our own software development (cost)
What follows is a simple function that returns a Pandas DataFrame, i.e., a table with rows and columns, including all of the hours and projects for a time period for a given user. Please note that, as mentioned earlier, this and all subsequent coding excerpts are just highlights of the entire codebase, not a step-by-step tutorial to build our bot.
Creating a PDF Timesheet and Invoice
With each worker’s project hours automatically tracked, the next task is to create timesheets and invoices. There are many Python packages that enable you to create PDF files. We use PyFPDF, a compact document generation library that offers simplicity as well as the flexibility to draw shapes and add images and text. As you can see from the following example, it yields a clean and professional invoice:
While there are more advanced methods for creating reports, PDF is a good choice because it’s a universal format used across all industries and it’s easy to generate. It also allows for sending files to anyone while ensuring that all fonts, images, tables, and formatting will transfer. Additionally, it works independently of your computer hardware and operating system, and can be used offline.
Sending Emails
Amazon Simple Email Service is a cost-effective and scalable tool for creating and deploying nicely formatted HTML emails. Furthermore, SES’s data analytics track and share information about feedback loop results to notify you if any recipients report your message as spam, either by mistake or because the email was sent to the wrong address. The analytics also measure the effectiveness of each communication in terms of engagement, including open and click-through rates. This feature is particularly useful for marketing emails.
Here’s an example of the Python code used to generate an email with an attached invoice and send it to a client:
And here is the email that it produces:
Automating Banking Activities
We chose Wise for private and business bank accounts since we have income and costs in several currencies, and this financial technology company has favorable exchange fees, an intuitive user interface, and a flexible API with detailed documentation.
We use this API to accomplish the following tasks:
- Collect statement information for each company and currency, so I can quickly see the aggregate and actual liquidity.
- Extract historical transaction information, so I can identify trends in different cost items as well as check whether the client has paid the previous month’s invoice. If they have not, the API sends a reminder email.
- Make money transfers automatically.
Below is the code we programmed to complete the first of these tasks (collecting statement information):
For regular fixed costs (salary, taxes, office costs, etc.), you don’t need to write code to make automatic transfers; Wise has a scheduled payment feature. However, if the amount is not fixed but based on a formula that an algorithm can calculate, the Wise API is useful. In my case, the business advisor’s salary is a notable example since it’s a function of the monthly revenue. By checking the tracked hours, the bot knows exactly how much revenue we have and therefore how much to pay the advisor.
Mitigating Risks Through a Two-sided Conversation With the Bot
It’s crucial to be aware of the bot’s activity, as there can be coding bugs that aren’t revealed during testing. We get real-time notifications on Slack, so we can fix any broken code promptly. Here are a couple of notification examples that let us know the bot is operating properly:
We also enabled the bot to send confirmation questions for the Pylink team before each bank transfer. This helps us avoid mistakes due to human error. Imagine a developer makes a typo and enters 825 hours instead of 8.25 hours for one ticket. An approval step in Slack ensures that we don’t transfer a hundred times more money than we owe. The process retains the element of human verification but delivers a seamless experience.
There’s a lot of other functionality that you can achieve with the Slack API, too.
The Office of Tomorrow
Business automation can help organizations thrive. The tools I discussed can transform companies in need of greater efficiency and control, especially when it comes to transactional functions like accounts payable, accounts receivable, and other core accounting areas.
But this isn’t the end of the story. According to McKinsey, the challenge for corporate leaders is to cast an even wider net for new efficiencies. The firm supports reimagining the entire finance operation, going beyond just transactional tasks by leading in areas like data analytics—consolidating, simplifying, and controlling information across the corporation. I couldn’t agree more. I recommend that you explore coding solutions that help your organization own its answers and advance its results-oriented culture. In the meantime, adopting the tactics I’ve described here can help your company become more efficient today—while giving you a taste of tomorrow’s possibilities.
Further Reading on the Toptal Blog:
- How Artificial Intelligence Is Disrupting Finance
- Advanced Financial Modeling Best Practices: Hacks for Intelligent, Error-free Modeling
- Building Your First Telegram Bot: A Step by Step Guide
- Exploring the Post-crash Cryptocurrency Market: Blockchain, Regulations, and Beyond
- How to Recreate the Resources of a Bloomberg Terminal for Free
Understanding the basics
What are bots in finance?
Bots are computer software programs set up to automate certain finance functions that don’t require manual human operation. They are created via code that’s developed with tools such as Python, and they perform tasks in response to coded commands.
What kinds of tasks can be automated with a bot?
Automation can be used in finance areas such as procurement, accounting, payroll, and other transactional business services. Bank operations, time tracking, invoice generation, email sending, and scheduling can all be accomplished seamlessly by creating and running a Python bot.
Are bots good for business?
Bots help staff members accomplish routine work more efficiently and free them up for more complex tasks that add value to the business. Bots can reduce the time required to complete functions by 23 – 40%, and considerably more in some cases, potentially saving organizations hundreds of thousands of dollars annually.
London, United Kingdom
Member since October 6, 2020
About the author
Miklos is highly experienced in finance processes, fintech, and Python programming. In addition to being a Toptal finance expert and software developer, he is the director of the structured finance consulting company Pylink Ltd.
Previous Role
CEOPREVIOUSLY AT