Declare pipelines
A pipeline feeds a source’s raw streams. Declare it in TypeScript next to the source, withsource(name, { pipeline }), and list it in ontology({ pipelines }). It compiles into the version, and Tilde runs it in each environment the version deploys to.
ontologies/crm/pipelines.ts
linear.stream("issues"). Stream names are typed by the pipeline, so a misspelt stream does not compile. List the connections, secrets, and pipelines in ontology({ connections, secrets, pipelines: [linear, app, github] }), with github from GitHub below.
Pipeline helpers cover polled APIs (linear, sentry, and cloudwatch, and polled() for Plaid, QuickBooks, Xero, Google mail, calendars, and contacts, and Slack), GitHub (github.sync), provider webhooks (github.webhook, linear.webhook, sentry.webhook), your own webhook(), PostgreSQL row changes (postgres.cdc), Kafka topics (kafka.consume), and Tilde’s own events (tilde.events).
- A pipeline with a
connectiongets the account’s current credentials from Tilde, including refreshed OAuth tokens. A webhook pipeline with a connection receives that provider’s verified webhooks. - Any other credential is a secret from
defineSecrets. Each environment binds it to one of your team’s secrets. See Bind connections and secrets. - Polled pipelines take
backfill: { start: "90d" }: where the first run starts, as a date, an RFC 3339 time, or a duration before now. - Once an ontology has one pipeline, every source it reads needs one, and every pipeline must be read.
GitHub
github.sync keeps one stream per GitHub entity for the repositories you list: pull requests, their reviews, check runs, and releases. On its first run it backfills each repository’s recent history from GitHub’s API (30 days unless backfill.start says otherwise). After that, the connection’s webhooks keep it current. Rows are the webhook bodies, whether backfilled or delivered, and each row’s _key is the entity: {repository, number} for a pull request, {id} otherwise.
ontologies/crm/pipelines.ts
- Only the listed repositories are written. Deliveries from any other repository the GitHub App is installed on are dropped, so list every repository you read.
- Each repository is backfilled once, by its own job: a repository added later gets its backfill on the next run, and the others are not fetched again.
- It never polls again after the backfill: GitHub’s webhooks are complete.
github.webhook(withoutbackfill) still gives the raw deliveries, routed by event type into streams of your choosing.
Connections
An ontology’s connections are the third-party accounts it needs. Declare them as plain data, and bind each to one of your connections in each environment’s entry intilde.config.ts.
ontologies/crm/connections.ts
connections.linear, never as strings, and a pipeline helper takes only a connection of its provider. List them in ontology({ connections }). Handlers use the same connections to call the provider. See Call third parties.
Custom streams
A custom stream takes records from your own code. Each record is validated against a zod schema and keyed, so a newer record with the same key replaces the older one.ontologies/crm/sources.ts
ontology({ streams: [feedback] }). Write records through the management API, with a management API key that has write_streams on the project.
Reference data
A stream can also ship static records with the project, such as lookup tables. Add them asreference: [ ... ] on the stream, as in the project guide. Tilde validates them at build time and loads them on every deploy.
Removing a record from
reference does not delete it. A redeploy only adds and replaces records.Tilde chat events
An ontology can read your organisation’s own Tilde data, such as chat threads, messages, participants, and channel identities. Agents’ conversations then become data you can join with everything else, for example to link a WhatsApp thread to a customer.-
Declare a source named
tildewith the streams you want. Message bodies reach the ontology only if you listpublic_chat_messages.ontologies/crm/pipelines.ts - Turn on Registry events in the environment’s settings. Tilde delivers existing rows first, then every change, for the streams the version declares.
Models
A model is SQL over sources or other models, in dbt’s vocabulary. Read sources withsource(pipeline, stream), or use a custom stream directly.
ontologies/crm/models.ts
materializedisview,table,incremental, orcell. Acellmodel is a table of a transactional view.sqlruns once for the full build and once for incremental runs. Useref()for models and objects,src()for sources, andchanges()for rows that changed since the last run. The build rejects SQL that names a raw table directly.- You can keep SQL in a file with
sql: sqlFile("./customers.sql"). - Models and handler SQL use DuckDB’s SQL dialect. Read JSON with
->>, such aspayload->>'$.address.country'.
When a deploy rebuilds a model
Some changes make a deployed model rebuild from scratch, such as new inputs tochanges(), a new schema, or a new dependency. Tilde refuses a deploy that would rebuild a model, and names each model. Deploy again with tilde deploy --accept-rebuild <model> when the rebuild is what you want. See Deploy.