Skip to content

SQL and BFF — Executing Predefined Platform Logic

This page is mainly for Skill authors, delivery teams, and Agent maintainers. Business users don't need to know sqlcode or functionName, let alone enumerate the SQL or BFF entries in the system themselves.


The short version

When the standard data commands aren't enough, the Lovrabet CLI can reuse SQL and BFF entries that already exist on the platform:

  • sql exec: for complex queries, standardized metrics, and multi-table joins
  • bff exec: for already-encapsulated business logic, aggregation endpoints, and transactional flows

It also provides:

  • sql detail
  • bff detail

so maintainers can confirm parameters and definitions.


Why there is no sql list or bff list

That's intentional, not an omission.

The reasoning is simple:

  • SQL and BFF entries often carry sensitive business logic
  • Business users and general-purpose Agents shouldn't be free to scan and invoke them at will
  • The right pattern is for Skill maintainers to write the allowed SQL / BFF entries into the skill, and let the Agent follow the business flow

In other words:

  • Business users state "what business result I want"
  • Skills decide "which SQL / which BFF to call"
  • The Agent performs the actual call

sql detail / sql exec

When SQL is the right fit

  • Complex multi-table queries
  • Consistent statistical definitions across reports
  • Daily or weekly reports, reconciliation results
  • Anything data aggregate alone can't express

View a SQL definition

Bash
lovrabet sql detail --sqlcode 2305f915-dd48cd4c

Execute SQL

Bash
lovrabet sql exec --sqlcode 2305f915-dd48cd4c --params '{"date":"2026-04-20"}'

The sqlcode format is:

Plain
xxxxxxxx-xxxxxxxx

bff detail / bff exec

When BFF is the right fit

  • You need the result of an already-encapsulated business endpoint
  • The logic spans multiple data sources or multiple steps
  • You need a consistent snapshot, view, or processing result

View a BFF definition

Bash
lovrabet bff detail --id 42

Here --id is the script ID, not the function name.

Execute a BFF

Bash
lovrabet bff exec --name processOrder --params '{"orderId":1,"action":"ship"}'

Here --name is the function name.


Choosing between SQL and BFF

The result you needBetter entry point
Single-table query or summarydata filter / data aggregate
Complex statistics or joinssql exec
An already-encapsulated business flow resultbff exec

A simple heuristic:

  • Feels like "querying the database for a figure" → lean toward SQL
  • Feels like "calling a ready-made business endpoint" → lean toward BFF

How business users should phrase requests

Business users usually shouldn't say things like:

  • Run sqlcode=2305... for me
  • Execute functionName=processOrder

More natural phrasing:

  • Generate yesterday's operations report for me
  • Pull a unified after-sales snapshot for this customer
  • Find out why this order stopped moving forward

The Agent and the skill then decide whether to call SQL or BFF behind the scenes.


One tip for Skill maintainers

If a business action is frequent, stable, and reusable, don't make the Agent improvise every time. A better approach:

  1. State explicitly in the skill which SQL / BFF this scenario should use
  2. Document what parameters the input requires
  3. Document how to interpret the output

That way business users get "a stable result" — not "a lucky guess at which command to run".

基于飞书知识库同步生成,内容以飞书源文档为准