OpenAI Assistant — a tool for data analysis and calculations

Last update: 25.06.2025

Before you start configuring, we recommend checking out our article on the overall logic of automation rules in Deskie or watching the quick video guide on rules.

Task: delegate calculations to the OpenAI Assistant.

Tools on the OpenAI side: the Code Interpreter tool must be enabled for the assistant specified in the rule, which allows automating calculations.

Code Interpreter is a tool that, under normal conditions, can execute code, analyze data, generate charts, and work with files. However, within the scope of our integration, it is recommended to use it only for basic calculations. Do not attempt to run visualizations, complex data processing, or file uploads with it — these are not supported and will result in errors.

How it works: When a customer requires a calculation, the agent applies the label "cost calculation" → a rule for updated cases is triggered, which sends the data needed for the calculation to the assistant. The calculation result is then added as a note.

Example of a rule:

How it works:

Example of a structure for the assistant

The example is provided for illustrative purposes only and should be considered as one possible approach, not as a definitive model.

Code for processing delivery data:

import pandas as pd

def load_data(path):
    try: return pd.read_csv(path)
    except: return f"Error: {path}"

def calculate_delivery(data, origin, destination, grams):
    kg = grams / 1000
    filtered = data.query('Origin == @origin and Destination == @destination')
    if filtered.empty: return "No delivery available between these cities"

    results = []
    for _, row in filtered.iterrows():
        min_kg = max(kg, row['Minimum Weight (g)'] / 1000)
        cost = max(row['Cost (eurocents/kg)'] * min_kg / 100,
                   row['Cost (eurocents/kg)'] * row['Minimum Weight (g)'] / 100000)
        insurance = row['Insurance (cents/kg)'] * kg / 100

        results.append({
            'Type': row['Delivery Type'],
            'Duration': row['Delivery Time (days)'],
            'Total Cost': round(cost + insurance, 2)
        })
    return "\n".join([f"{i}. {r['Type']} - {r['Duration']} days, {r['Total Cost']}€"
                      for i, r in enumerate(results, 1)]) if results else "No delivery options found"
# Usage
files = ['/mnt/data/file-en_international_tariffs.csv','/mnt/data/file-en_local_tariffs.csv']
df = pd.concat([d for f in files if isinstance((d := load_data(f)), pd.DataFrame)], ignore_index=True)
print(calculate_international_delivery(df, 'Berlin', 'Oslo', 550))

Examples of files uploaded for Code Interpreter:

https://gist.github.com/deskie-io/26d810ebaac70deff339cce27632ec36

https://gist.github.com/deskie-io/6b7a72f1f7a9b3d444538c413647682d


Was this article helpful?