AI Workflows

Part 1 — Build a Support Workflow in Python Before Adding LangGraph

CodeTips Academy
October 24, 2026
6 min read
58 views
Build a Support Workflow in Python Before Adding LangGraph

Start with a small working program, learn what a workflow means, and identify the problems a graph will help us organize.

Complete code for Part 1: Download this standalone lesson · Download the full series project. This article shows every required code file and import. Extract the lesson folder and follow its requirements.txt and README.

What you will build

A learner writes “ My Python module is missing. ” to a workshop help desk. Before we choose an AI framework, we need a small program that accepts that text and returns something useful. This lesson deliberately has no language model: it separates ordinary data processing from the tools we will introduce later.

We will write two functions, run them on one example, and inspect the returned dictionary. In Part 2, we will keep this small task and change how its steps are connected. You should be able to explain this version before making that change.

By the end: Turn one messy workshop question into a predictable, printed reply using only Python.

What you need before starting

You need basic Python: variables, functions, dictionaries, loops, and imports. When this lesson introduces a class or a library-specific term, its role is explained below.

Use Python 3.12. These examples were executed on Windows with Python 3.12.4. Use the shown interpreter consistently when installing packages and running code. This part uses the Python standard library only.

You do not need to run an earlier article to make this part execute. The complete files and data used here are supplied below. The series order is for learning the ideas progressively.

Understand the idea before the code

We are building a small support workflow: a sequence of Python operations that takes a question and prepares a reply. “Workflow” means the steps and their order. It does not imply artificial intelligence. In this first part, ordinary Python performs every step; LangGraph is not needed yet.

A request is one incoming question. A function is a named piece of Python code that accepts input and returns a result. A return value is the result handed back to the caller. If clean(text) returns a shorter string, the caller must use that returned string; returning a value does not automatically change the original variable.

Think of one question on a workshop help desk: receive it, remove extra spaces, prepare a reply, print the result. Printing is a visible output for this exercise; it is not delivery to the customer.

Word Plain meaning in this project
Input The value supplied to a step, such as a question string.
Output The value a step returns, such as a cleaned question.
State The current named data for one workflow run, usually kept in a dictionary. We introduce that dictionary in Part 2.
Graph A map of steps and allowed next steps. It is a workflow map, not a line chart and not a neural network.

Create the lesson folder

Create this folder and keep the filenames exactly as shown. In particular, a local module is an ordinary file beside the program, not an extra package you must guess how to install.

lesson-folder/
  lesson.py
  requirements.txt

Save requirements.txt

Leave this file empty; the standard library supplies everything used in Part 1.


No dependency installation is needed for this part. Save the file and use your Python 3.12 interpreter.

Complete code for this article

Save this complete file as lesson.py

This is the complete program, including imports, data, function definitions, and the entry point.

"""Article 1: the smallest working support reply, using Python only."""

import json


def clean(text):
    return " ".join(text.split())


def prepare_reply(text):
    cleaned = clean(text)
    return {
        "text": cleaned,
        "reply": "Check that you installed the package into the Python environment you are running.",
    }


if __name__ == "__main__":
    print(json.dumps(prepare_reply("  My Python module   is missing.  "), indent=2))

Run it and compare the result

Run commands from the lesson folder. In the commands below, python means the environment you installed into. On Windows, substitute .venv\Scripts\python.exe; on Linux/macOS substitute .venv/bin/python. Do not create the environment with one interpreter and run the lesson with another.

Run 1: python lesson.py

python lesson.py

Captured standard output:

{
  "text": "My Python module is missing.",
  "reply": "Check that you installed the package into the Python environment you are running."
}

The displayed output was captured from the supplied default program in a separate folder, with no project-level module on its import path. It is a reproducible demonstration on these examples, not a claim about arbitrary inputs.

Walk through what just happened

1. Import the standard library

import json supplies the printing function used at the bottom. JSON is only the display format; the program works with Python strings and dictionaries internally.

2. Normalize the input in clean

text.split() separates words while ignoring extra whitespace. Joining those words with one space creates a new string. The original input string is not modified in place.

3. Assemble a result in prepare_reply

The dictionary has two named fields: the cleaned text and a fixed reply. The reply is a programmed sentence, so do not interpret it as the answer of a trained model.

4. Run the program deliberately

The if __name__ == "__main__" block runs when Python executes this file directly. Importing this file elsewhere would define its functions without running that block.

Change one thing yourself

Change the input to a question about an ESP32 camera. Predict the reply before running it. It stays the same because no part of this program understands the question’s category.

If your result is different

If Python cannot find lesson.py, check the folder you are running from. This part requires no pip package, API key, or website account.

Check the complete imports and filenames first. Then compare your input and command with the shown run. Numeric results may differ slightly between platforms; the program's assertions check the intended relationships rather than relying on a decorative screenshot.

What you can now explain

Turn one messy workshop question into a predictable, printed reply using only Python. Next we will express the same two-step job as a LangGraph workflow and follow a dictionary through its steps.

Technical reference: LangGraph Graph API. This project and its wording are original CodeTips Academy material.


Related Articles

Back to Articles