Skip to main content

Declarative YAML-first chatbot framework with pluggable intent detection

Project description

FlowForge

Object-oriented dialogue framework for Python.

FlowForge lets you build conversational bots using a declarative YAML DSL where each state is a business object — not an abstract node in a state machine, but a real concept from your domain: pricing, support, checkout, booking.

YAML defines the dialogue structure. Python handles the logic. The engine connects them.

Philosophy

Traditional chatbot frameworks think in terms of states and transitions — abstract nodes connected by arrows. FlowForge thinks in terms of objects and signals:

Traditional FlowForge
State node Business object (pricing, support, order)
Responses What the object says about itself
run: actions What the object does when activated
auto_transitions Signals this object listens for
response_transitions Follow-up actions after the object has spoken

This means your bot's structure mirrors your business domain. Adding a new topic = adding a new object. Each object is self-contained: it knows what to say, what to do, and where to go next.

Quick Start

pip install pyflowforge

Create scenario.yaml:

scenario:
  name: shop_bot
  initial_state: greeting
  fallback: llm

intents:
  ask_price:
    - "how much does it cost"
    - "what is the price"
  greeting:
    - "hello"
    - "hi"

states:
  # Object: Greeting — entry point, knows how to welcome
  greeting:
    responses:
      - "Hello! Ask about prices or say help."
    auto_transitions:
      - target: pricing
        when:
          - type: intent
            value: ask_price
      - target: help
        when:
          - type: regex
            value: 'help|support'

  # Object: Pricing — knows everything about prices
  pricing:
    run:
      - action: get_price
    responses:
      - "Price: {price} USD."
    response_transitions:
      - target: checkout
        when:
          - type: regex
            value: 'yes|sure|buy'

  # Object: Help — knows how to assist
  help:
    responses:
      - "I can help with pricing and orders."
    auto_transitions:
      - target: greeting
        when:
          - type: intent
            value: '*'

  # Object: Checkout — handles purchases
  checkout:
    responses:
      - "Order confirmed!"

Run:

from flowforge import Bot

bot = Bot.from_yaml("scenario.yaml")

@bot.action("get_price")
def get_price(ctx):
    return {"price": 100}

bot.run()  # interactive console REPL

Or use programmatically:

response = bot.send("how much does it cost?")
print(response.text)   # "Price: 100 USD."
print(response.state)  # "pricing"

Connect to any channel

FlowForge is the brain. The channel (Telegram, Discord, web) is just ears and mouth:

from telegram.ext import ApplicationBuilder, MessageHandler, filters
from flowforge import Bot

bot = Bot.from_yaml("scenario.yaml")

async def handle_message(update, context):
    user_id = str(update.effective_user.id)
    response = bot.send(update.message.text, session_id=user_id)
    await update.message.reply_text(response.text)

app = ApplicationBuilder().token("TOKEN").build()
app.add_handler(MessageHandler(filters.TEXT, handle_message))
app.run_polling()

Features

  • Object-oriented DSL — states are business objects, not abstract nodes
  • Hybrid API — YAML for dialogue structure, Python for business logic
  • Pluggable intent detection — TF-IDF out of the box, bring your own classifier
  • LLM fallback — rule-based for known paths, LLM for everything else
  • Knowledge base — attach a knowledge.md file for LLM-powered Q&A
  • Persistent sessions — SQLite store included, plug in Redis/Postgres/anything
  • Trigger types — regex, pattern matching, intent classification
  • Session management — multiple independent conversations by session_id
  • Actions — Python functions via @bot.action(), Node.js via subprocess
  • Debuggingverbose=True for step-by-step engine trace
  • Channel-agnosticbot.send(text) -> response, connect to anything
  • Zero heavy dependencies — only pyyaml

Documentation

Full DSL reference, Python API, and examples: docs/dsl.md

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyflowforge-0.1.1.tar.gz (56.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyflowforge-0.1.1-py3-none-any.whl (30.5 kB view details)

Uploaded Python 3

File details

Details for the file pyflowforge-0.1.1.tar.gz.

File metadata

  • Download URL: pyflowforge-0.1.1.tar.gz
  • Upload date:
  • Size: 56.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.1

File hashes

Hashes for pyflowforge-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7b62543efa1217f7c4d8f2cd1bfae159c427d17ccd9a231d698ad2667ca0dd55
MD5 34d907f61f097fab02a193849025658d
BLAKE2b-256 a3d906a2297b13190fc93a08961399ceca5f28cdee568736ccd39a1ea4bd1dbf

See more details on using hashes here.

File details

Details for the file pyflowforge-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyflowforge-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 30.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.1

File hashes

Hashes for pyflowforge-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16c8aa9a08c80fc913f9bf5d02353dd3ec196662dad11a74ad6130619cf3f744
MD5 8b4daa137f7d0dc94088e713e8153ee2
BLAKE2b-256 c0d2f4086e0af57d5ef293a7927fff1f6f7ea55477164a2eef95f026b5c41798

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page