Connect Directus

Point a bot at the collections you keep in Directus — help articles, a FAQ, plans, a product catalogue — and it answers from what the records say now, with a citation to the record. It reads on a schedule — daily on Pro, hourly on Business — Sync now reads straight away, and a Directus Flow can tell it the moment a record changes. A record you edit is read again; one you delete, archive or move back to draft is removed from the bot. It is part of Pro and Business, like every source that keeps itself in sync.

Read this first. Everything you switch on can be quoted to anyone who talks to the bot. Switch on only what the bot may answer from, and for internal material use a bot that is not installed on a public site: the bot's Allowed domains decide where it answers.

What you need

  • Directus 11 or 12, reachable from the internet on a standard web port (443 or 80). An instance on a private network, or on a port like 8055, cannot be connected: Grounded refuses to send a request anywhere but a public web address.
  • A user in a read-only role, and its static token. Grounded refuses a token that could change anything — an administrator's, or one whose role may create, update, delete or share in any collection — and says which permission it found.

Make the read-only user

In the Directus app, as an administrator:

  1. Settings → Access Policies → Create policy. Name it Grounded (read-only). Leave Admin Access off and switch App Access on: without it the role cannot read the data model — which collections and fields exist — and Grounded cannot show it. App Access grants no right to change anything; what the role may change is still only what its permissions below allow, which is nothing.
  2. In the policy, add a permission for each collection the bot should read, and allow Read only. For a collection with translations, allow Read on its …_translations collection and on languages as well. Where a collection has a status, set the Read permission's item permissions to status equals published: drafts then never reach Grounded at all, whatever is chosen on our side.
  3. Settings → User Roles → Create role. Name it Grounded (read-only) and attach the policy.
  4. User Directory → Create user in that role. Open the user, generate a Token under its settings, copy it, and save the user. The token is what you paste into Grounded.

Add it

On the bot's Documents page choose Add documents → Directus. Paste the address of the backend — the one the API answers on, not its /admin page — and the token. The token is checked before anything is kept: if it can change anything, or read nothing, the form says so. It is then stored encrypted and never shown again.

The next screen shows the data model the token can read: every collection, its fields and its relations. Nothing is read until you switch a collection on.

To change the token, connect the same address again with the new one. What you chose is kept.

Choose what the bot reads

For each collection you switch on:

  • Records. Which records are read. Filled in from Directus itself: a collection with a status that has a published value reads only published records; one with an archive field leaves out what it archives. You can change the field, the condition (is, is not) and the value, or read every record. The screen counts the records that match.
  • Fields. Every field a reader could ask about, in the order the Directus form shows them, with a switch each. Fields hidden in Directus are off at first. JSON, files, images and map fields are not read: the bot answers from words. Short fields become lines like Price: 49.00, with the label in the document's language when the field has a translation in Directus; long text, Markdown and WYSIWYG fields become sections of their own.
  • Related items. A many-to-one, one-to-many or many-to-many relation is one line, written the way the related collection's display template shows it in Directus — "Category: Business plans". Twenty related items at most, with the rest counted. One level deep; files and system collections are not followed.
  • Address for citations. Optional: https://yoursite.com/{lang}/plans/{slug} sends a reader to the record's page. {field} is filled in from the record, {lang} with the document's language. A placeholder the collection cannot fill is refused when you save, and the screen shows one address built from a real record. Without an address, a citation shows the record's title.
  • Comparison table. Up to four fields to compare records by — prices, choices, yes/no, dates. The bot gets one table per language listing every matching record, so "which plan is cheaper" finds them all at once. The table is built for up to 200 records; past that it is not built, because the bot reads a few passages per answer and a comparison across a longer list would be unreliable. Answers about single records work as usual.

The screen renders one real record exactly as the bot will read it.

Languages

A collection with a translations field becomes one document per record and language: the bot's languages among those Directus has, or all of them when the bot is on Automatic. A record with no translation in a language makes no document in it. A collection without translations is read once.

How many documents

Every record in every language is a document, and each table is one more. The screen adds them up as you choose — "This selection makes 912 documents" — next to what your plan allows and what is already in use, and Save is not pressed until it fits. If a catalogue grows past the limit later, the next run reads what fits and the card says how many records were left out.

Read changes at once: a Directus Flow

Every run re-reads the chosen collections and re-embeds only the records whose document changed, so a schedule alone keeps the bot right. For prices and availability that should be current within a minute, add a Flow:

Let Grounded make it. On the source's card, open Webhook and press Create the Flow in Directus. Paste a token that may make flows — an administrator's, or one whose role may create, read and update flows and operations. It is used for that one request and not stored; the source keeps its read-only token. Grounded makes the Flow with a new webhook secret, and pressing the button again updates the same Flow instead of adding a second one.

Or build it by hand — Set it up by hand on the card shows these steps with this source's values filled in:

  1. On the source's card in Grounded, open Webhook, copy the endpoint and press Create secret. The secret starts with whsec_ and is shown once.
  2. In Directus, Settings → Flows → Create flow. Trigger: Event Hook, type Action (non-blocking), scope items.create, items.update and items.delete, and the collections the bot reads.
  3. Add an operation Webhook / Request URL: method POST, the endpoint as URL, a header Authorization with the value Bearer whsec_…, and this body — exactly this, nothing around it:
{{$trigger}}

Directus then sends the trigger itself: the collection, and the records an update or a delete names in keys, a create in key. Do not write your own JSON around {{$trigger.keys}}: with text keys such as UUIDs the result is no longer valid JSON, and Grounded refuses it. The named records are read straight away in every language, with their collection's table; a new record is picked up by a run that starts within five minutes. A collection the source does not read is ignored. The endpoint takes 30 calls a minute: an import of hundreds of records is told to slow down, and the next scheduled run reads the rest.

When something is wrong

The card shows the reason in words. The common ones: the token was refused (it was revoked, or its role lost Read on a collection — connect again with a new one, or switch the collection off); the address answered, but not like Directus (it is the /admin page, or a different service); Directus is limiting requests (the next run tries again). If a run lists under half of what it listed last time, deletions are paused and you are emailed, because that is more often a permission that went missing than a catalogue that halved. See Keep it in sync.

Who is a sub-processor

Directus is yours: Grounded reads from it with your token, and your instance receives nothing but the read requests.