In this article, you will see how MindsDB fully automates AI workflows, connecting any source of data with any AI/ML model, and enabling the flow of real-time data and predictions between them.
One of the core components of MindsDB is a Job, a command that allows anything in MindsDB to be run either on a timer (e.g. every day) or based on an event (e.g. when a new row is added to my DB).
Read along to explore how using Jobs radically simplifies building Applied AI use cases:
MindsDB can connect to any source of data - a database, warehouse, stream or app. Here, we’ll connect to Binance (a crypto exchange) to get a feed of real-time price information:.
That’s it, you now have access to the Binance API! Now you can take a look at the data for the crypto pair that will be ultimately used::
But what if you wanted to automate pulling the data every day? You guessed it, this is where a JOB can come in handy to run this over and over. You just wrap the query with the previous CREATE JOB syntax:
There you have it - you’ve learned what a JOB is and how they can work by automating getting the data from Binance every minute. This is just a super-simple toy example; in practice you might want to save SELECT output into a VIEW for this functionality as you move to building a fully automated end-to-end Crypto forecasting solution.
MindsDB enables users to automate every element of a production AI workflow by scheduling Jobs. A Job can be run on either a time-based or data-based trigger, depending on what your workflow calls for.
In this tutorial, you will walk through automating real-time forecasts like a Cryptocurrency trader for BTC/USDT trading pair. You can then automate the sending of these forecasts to Slack.
Every time the job runs, it will retrain a time-series model using the latest trade data from Binance. Then, it will insert real-time predictions into your Slack every 5 minutes to get you up to date with the latest developments of the BTC/USDT trading pair.
That is how you can automate the entire AI workflow - use the CREATE JOB statement to start a job that executes queries defined within it.
Here is the Slack output of one job run:
Follow along to find out more about Binance and Slack connectors and the time-series model used to forecast the open price values.
Alternatively, you can watch the video tutorials ( and ) that walk you through the process of setting up data and a model, connecting Slack, and automating real-time forecasts as Slack notifications.
Read along to learn more about all the components used in the job, including the connector to Binance data, the time-series model, and the connector to Slack.
The training data is required to train a time-series model. This tutorial uses data from Binance, a company that operates a cryptocurrency exchange.
MindsDB integrates with Binance and enables users to fetch real-time data. Here is how to connect Binance to your MindsDB account.
It doesn’t require any additional parameters, so now you can query for Binance data.
This tutorial focuses on the BTC/USDT trading pair.
The Binance trade data is updated every minute. Therefore, the time-series model is going to predict the open prices of the BTC/USDT trading pair for the next 10 minutes.
Use the CREATE MODEL statement to create, train, and deploy a model. The FROM clause defines the training data used to train the model - here, the latest Binance data is used. The PREDICT clause specifies the column to be predicted - here, the open price of the BTC/USDT trading pair is to be forecasted. As it is a time-series model, you should order the data by a date column - here, it is the open time when the open price takes effect. Finally, the WINDOW clause defines the window the model looks back at while making forecasts - here, the model looks back at sets of 100 rows (intervals of 100 minutes). The HORIZON clause defines how many rows into the future the model will forecast - here, it forecasts the next 10 rows (the next 10 minutes).
After executing the CREATE MODEL statement as above, you can check the progress status using this query:
Once the status reads complete, you can proceed to make forecasts.
First, save the Binance data into a view, which will be joined with the model to provide the latest Binance trade data.
Next, query for forecasts by joining the model with the Binance input data table.
Here is a sample output:
Please note that the Binance data is updated every minute, so every time you query the model, you will get forecasts for the following 10 minutes.
This tutorial automates not only getting real-time forecasts but also notifying you about it on Slack. So, let’s connect your Slack workspace to MindsDB.
Follow this instruction to set up your Slack app and generate the Slack bot token. Once you get the Slack bot token and integrate your Slack app into one of the Slack channels, you can connect it to MindsDB.
Here is how to send messages to a Slack channel:
Let’s put it all together again.
Now that you connected Binance to MindsDB and used its trade data to train the time-series model, you can set up a job that will be retraining this time-series model periodically using the latest Binance data. It is to keep improving the model’s accuracy and performance.
In the second step, the job will insert real-time forecasts of the BTC/USDT trading pair for the next 10 minutes and notify you on Slack.
The job will be scheduled to execute every 5 minutes. Thus, the forecasts for the last 5 rows of the current job execution will overlap with the forecasts for the first 5 rows of the next job execution.
Let’s look at the Slack output after a couple of job executions.
The job sends messages to the Slack channel where the Slack app was integrated. There you have it - a fully automated end-to-end alert system!
MindsDB enables users to develop and automate AI workflows easily. You can integrate data from over 100 data sources, including popular databases, like PostgreSQL, MySQL, MS SQL Server, and MongoDB, and applications, such as Slack, Twitter, Shopify, YouTube, and more. Moreover, you can choose from over 15 ML frameworks, including OpenAI, Nixtla, LangChain, LlamaIndex, and more, to create and deploy AI models with a single command.
Take a hands-on approach to exploring MindsDB by creating a demo account on MindsDB Cloud or installing MindsDB locally (via pip or Docker). And if you plan to use MindsDB for production systems, we recommend considering MindsDB Starter which provides managed instances, ensuring greater security and scalability for your projects.
Whichever option you choose, MindsDB provides flexibility and ensures a smooth experience for all your AI projects.