Buff Development
Buff CodeWorking in Buff Code

Charts and visuals in a chat

The agent shows numbers as a chart and a plan as a Gantt chart. Visuals of your own kind it makes when you ask.

When an answer holds three numbers or more, a picture reads better than a paragraph. Buff Code draws such answers right in the chat: the chart appears in place while the agent is still writing, responds to clicks and looks like the rest of the app — in every theme.

This works through chat plugins. A plugin teaches the agent one kind of visual: how to write the data and how to draw it. The "Charts" plugin is built in and on for everyone; plugins of your own the agent makes when you ask, in Self-setup mode.

What the built-in charts do

Ask in plain words: "show revenue by month as a chart", "compare the channels", "draw the funnel", "build the launch plan". The agent picks the form.

What you need to seeShown as
Change over timeline, area
Comparison and rankingbars, horizontal bars
Shares of a wholepie and donut charts, stacked bars
Structure with levelstreemap, sunburst, tree
Relation of two or three measuresscatter and bubble charts, heatmap
Distributionbox plot, histogram
A measure against a goalgauge, progress ring
Stages and conversionfunnel
Flows and linksSankey diagram, graph
A profile across several axesradar chart, parallel axes
Prices: open, high, low, closecandlesticks
Activity by daycalendar
A plan in timeGantt chart
What two or three sets shareVenn diagram
What a text is aboutword cloud

Working with a chart

  • Hover or tap — a tooltip with the exact value.
  • Click a bar, a point or a slice — a "More: …" button appears under the chart. It sends a question about that item into the chat as you. A click with Shift sends the question at once. Even without a question the agent learns what you picked, with your next message.
  • "Data" — the same numbers as a table.
  • Legend — a click on a series hides it and brings it back.
  • Keyboard: Tab to the chart, arrow keys through the points (the value is spoken for a screen reader), Enter to pick.

A chart fits the width it has: in the window, in the web client and on the phone it is the same visual. In the console a table with the same numbers stands in its place.

Where to turn it on and off

  • Window: Settings → Extensions → Chat plugins.
  • Web client: Settings → Chat plugins.
  • Phone: the machine's side menu → Chat plugins.

Each plugin shows what it draws, an example and a switch. A plugin that is off stays where it is: its blocks are shown as code, and the agent does not know of it and writes no such blocks.

A plugin of your own

Open Self-setup and say what you want to see: "learn to show the sales funnel by stage", "draw the shift schedule as a board", "show stock levels as tiles". Then the agent:

  1. Asks what data there is and what should read at a glance; an example of your real data is worth three questions.
  2. Writes the plugin and asks your permission to save it.
  3. Tests it in your app: the app draws every example and tells the agent what happened. The agent fixes an error and tests again.
  4. Shows an example in its reply — the visual itself — and changes it until you like it.

After that, in a usual chat it is enough to ask: "show the funnel for March". The plugin is available in all projects or in the current one only — like connections, this follows from where the Self-setup chat was opened. A plugin is removed in the settings or in words: "remove the funnel plugin".

⚠️ Important notes:

  • A plugin works with no network: it draws only the data of the answer and what is inside the plugin itself. It sends nothing out and loads nothing.
  • A plugin runs in an isolated frame: it has no access to the chat, your files or your data in the app. It sends a message into the chat only on your click, and opens a link only after you confirm.
  • The agent knows the main thing about a plugin — what it draws and when it is needed — and reads the full guide at the moment it is about to draw. So there may be many plugins.

How a plugin is built

It is a folder in your Buff Code configuration, chat-plugins/<name>/. You do not need to write it by hand — the agent keeps it — but you can look inside:

FileWhat it holds
plugin.jsonthe name, a description for the agent (when the plugin is needed), block names, the usual height, labels by language
view.htmlthe page that draws a block: markup, styles and script in one file
GUIDE.mdthe guide for the agent: how to write a block's data
guide/*.mdreferences of a large plugin — the agent reads the one it needs
examples/*.mdexample blocks; the plugin is tested on them
text.jsoptional: the text form for the console

A block in an answer is a usual code block named after the plugin's block:

```chart
{ "title": { "text": "Requests by channel" },
  "xAxis": { "type": "category", "data": ["Site", "Mail", "Phone"] },
  "yAxis": { "type": "value" },
  "series": [{ "name": "Requests", "type": "bar", "data": [420, 180, 95] }] }
```

The page has a window.buff object:

CallWhat it does
buff.onBlock(fn)gives the block's text — many times while the answer is written, and once whole
buff.host, buff.onHost(fn)the app's theme and language, and their changes
buff.sendMessage(text)a message into the chat as the person — only right after their click
buff.updateContext(text)quietly tells the agent what is picked in the visual
buff.setState(value), buff.statethe visual's state while the chat is open
buff.openLink(url)opens a link after the person confirms

The page takes colours and fonts from the app's variables (--color-text-primary, --chart-1 … --chart-8 and others) and from its ready styles for buttons, tables and labels, so a plugin looks native in every theme.

On this page