Skip to main content
You're viewing v3 documentation

This is the v3 HyperIndex documentation. Still on an older version? Open the v2 documentation and consider migrating to v3.

Chat Bots

Chat bots in HyperIndex are just Effects running in orderedAfterCommit mode that call a chat platform's API. There is no separate templating language and no separate config file — you build your message string with template literals and decide when to send it with normal if statements.

Why orderedAfterCommit?

Chat platforms display messages in arrival order to humans, so you almost always want ordered delivery. The runtime preserves the order of context.effect(...) calls across the entire batch, then dispatches them sequentially after the DB commit. The AfterCommit half guarantees you never message users about a state that was rolled back by a reorg or a failed batch.

If you don't care about order across events (e.g. one alert per swap, no relation between alerts), you can use unorderedAfterCommit for higher throughput.

Comparison with rindexer

rindexerHyperIndex
chat: block in YAML, one entry per providerA createEffect({ mode: "orderedAfterCommit" }) per destination
filter_expression: "value >= 10 && from = '0x…'"A regular TypeScript if
template_inline Mustache templateTemplate literal (full TypeScript expressions inside ${...})
10-block max range hard-codedUse the rate-limit option to tune throughput

Supported platforms

Helper: human-readable token amounts

Most examples below use a small formatUnits helper instead of rindexer's {{format_value(value, 18)}}:

src/utils/format.ts
export const formatUnits = (value: bigint, decimals = 18) => {
const base = 10n ** BigInt(decimals);
const whole = value / base;
const frac = value % base;
if (frac === 0n) return whole.toString();
const fracStr = frac.toString().padStart(decimals, "0").replace(/0+$/, "");
return `${whole}.${fracStr}`;
};