Skip to main content
connic

PostgreSQL

Start an agent from a NOTIFY in your database. A trigger or your application sends the row, and connic keeps the listening connection open.

Modes
Inbound
Set up in
Dashboard or connectors/*.yaml
Documentation
PostgreSQL docs
Publisher
By connic

Send the row from a trigger

Call pg_notify() from a trigger function or from your application. Each notification on the channel starts every linked agent.

Triggers or application code
A trigger catches every insert or update on a table, whichever service wrote it. NOTIFY from your application works the same way.
Small payloads
PostgreSQL caps a notification at 8000 bytes. Send IDs and key fields, and let the agent load the full record.
A channel per event type
Separate channels such as orders_created and users_updated keep each agent on the events it handles. Names use letters, digits and underscores.
notify_new_order.sql
CREATE OR REPLACE FUNCTION notify_new_order()
RETURNS trigger AS $$
BEGIN
  PERFORM pg_notify(
    'orders_created',
    json_build_object(
      'order_id', NEW.id,
      'customer_id', NEW.customer_id,
      'total_cents', NEW.total_cents
    )::text
  );
  RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER order_created
  AFTER INSERT ON orders
  FOR EACH ROW
  EXECUTE FUNCTION notify_new_order();

Get the payload as an object

With Parse JSON Payload on, which is the default, a JSON notification reaches the agent as an object with a _postgres block added.

JSON objects
The notification's keys become top-level fields, and _postgres adds the channel, backend process ID and time.
Everything else
Plain text arrives under message, and other JSON values such as arrays under data.
Parse JSON Payload off
Every notification arrives as the raw string under message.
payload.json
{
  "order_id": "ord_8812",
  "customer_id": "cus_4102",
  "total_cents": 489000,
  "_postgres": {
    "channel": "orders_created",
    "pid": 48213,
    "timestamp": "2026-10-13T09:00:00.123456"
  }
}
plain-text-payload.json
{
  "message": "nightly import finished",
  "_postgres": {
    "channel": "imports",
    "pid": 48213,
    "timestamp": "2026-10-13T02:00:00.481022"
  }
}

Keep the listener in your codebase

Declare it in connectors/. Host, database and login stay in a Connection, and a connector declared in code starts listening as soon as the deploy goes live.

connectors/new-orders.yaml
type: postgres
name: New orders
connection: shop-postgres
bridge: office-network
config:
  channel: orders_created
agents:
  - order-reviewer
create: connectors/new-orders.yaml (postgres)

One connection, no polling

Each connector keeps one connection open and waits for PostgreSQL to push notifications. It never queries your tables.

A low-privilege user
The database user needs CONNECT on the database. Receiving notifications needs no table grants.
Gaps aren't replayed
PostgreSQL doesn't keep notifications for a listener that isn't connected, so anything sent while the connector is paused or reconnecting is lost.
Private databases
Route the connection through a connic bridge in your network. The bridge only connects outbound, so you open no inbound firewall rule.
  1. Connect

    connic logs in with your credentials, applies the SSL mode you chose and runs LISTEN on the channel.

  2. Listen

    Each NOTIFY on the channel starts a run for every linked agent.

  3. Check

    Every 30 seconds, connic confirms that the connection is still alive.

  4. Reconnect

    A dropped connection is retried with a growing delay of up to two minutes. A wrong password or a missing database stops the listener with an error in the connector logs.

Where a Postgres trigger fits

Pick a setup to see which change sends the notification, what the agent receives and where the result goes.

A trigger on customers sends each signup, and an outbound webhook posts the company profile to your CRM.

New signup
Postgres inbound
customer-enricher
Profile in your CRM
payload.json
{
  "customer_id": "cus_4102",
  "email": "jana@example.com",
  "company": "Example GmbH",
  "_postgres": {
    "channel": "new_customers",
    "pid": 48213,
    "timestamp": "2026-10-13T09:00:00.123456"
  }
}
outbound-payload.json
{
  "run_id": "550e8400-e29b-41d4-a716-446655440000",
  "agent_name": "customer-enricher",
  "status": "completed",
  "output": "Example GmbH: logistics software, 40 people, Berlin.",
  "error": null,
  "started_at": "2026-10-13T09:00:00Z",
  "ended_at": "2026-10-13T09:00:05Z",
  "token_usage": {
    "input_tokens": 640,
    "output_tokens": 48,
    "thinking_tokens": 0,
    "cached_input_tokens": 0,
    "total_tokens": 688
  }
}

A trigger fires for large orders, and the agent posts a risk note to your ops channel in Slack.

Large order
Postgres inbound
order-reviewer
Note in Slack
payload.json
{
  "order_id": "ord_8812",
  "customer_id": "cus_4102",
  "total_cents": 489000,
  "first_order": true,
  "_postgres": {
    "channel": "large_orders",
    "pid": 48213,
    "timestamp": "2026-10-13T09:00:00.123456"
  }
}
connector-payload.json
{
  "text": "ord_8812: 4,890 EUR, first order, new address. Check first.",
  "channel_id": "C01234567"
}

Every new comment is checked, and an outbound webhook sends the verdict to your moderation API.

New comment
Postgres inbound
comment-moderator
Verdict to your API
payload.json
{
  "comment_id": "cm_5530",
  "post_id": "post_771",
  "body": "Great guide, but step 3 links to a dead page.",
  "_postgres": {
    "channel": "new_comments",
    "pid": 48213,
    "timestamp": "2026-10-13T09:00:00.123456"
  }
}
outbound-payload.json
{
  "run_id": "550e8400-e29b-41d4-a716-446655440000",
  "agent_name": "comment-moderator",
  "status": "completed",
  "output": "Approved. No policy issues, reports a broken link in step 3.",
  "error": null,
  "started_at": "2026-10-13T09:00:00Z",
  "ended_at": "2026-10-13T09:00:05Z",
  "token_usage": {
    "input_tokens": 640,
    "output_tokens": 48,
    "thinking_tokens": 0,
    "cached_input_tokens": 0,
    "total_tokens": 688
  }
}

An update trigger sends the old and new status, and the agent emails the account owner when a payment falls past due.

Status change
Postgres inbound
account-notifier
Email to the owner
payload.json
{
  "operation": "UPDATE",
  "account_id": "acc_2207",
  "old_status": "active",
  "new_status": "past_due",
  "_postgres": {
    "channel": "account_status",
    "pid": 48213,
    "timestamp": "2026-10-13T09:00:00.123456"
  }
}
connector-payload.json
{
  "to": "owner@example.com",
  "subject": "Your payment is past due",
  "body": "The last payment for acc_2207 failed. Please update your card."
}

PostgreSQL FAQ

Write a trigger function that calls pg_notify() with a JSON payload, attach it AFTER INSERT on the table and point a PostgreSQL connector at that channel. Each insert then starts a run with the payload. AFTER UPDATE and AFTER DELETE triggers work the same way. The PostgreSQL docs have trigger examples for inserts and updates.

No. It holds one persistent connection, listens on the channel and waits for PostgreSQL to push notifications. Apart from a connection check every 30 seconds, it sends no queries.

Yes. Route the connector through a connic bridge running in your network. The bridge only makes outbound connections, so the database needs no public address and no inbound firewall rule.

They are lost. PostgreSQL doesn't keep notifications for a listener that isn't connected, so nothing is replayed after you resume. Keep the source of truth in your tables.

PostgreSQL limits NOTIFY payloads to 8000 bytes. Send the row ID and the fields the agent needs to decide, and let it load the rest through a tool.