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.
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.
{
"order_id": "ord_8812",
"customer_id": "cus_4102",
"total_cents": 489000,
"_postgres": {
"channel": "orders_created",
"pid": 48213,
"timestamp": "2026-10-13T09:00:00.123456"
}
}{
"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.
type: postgres
name: New orders
connection: shop-postgres
bridge: office-network
config:
channel: orders_created
agents:
- order-reviewerOne 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.
Connect
connic logs in with your credentials, applies the SSL mode you chose and runs LISTEN on the channel.
Listen
Each NOTIFY on the channel starts a run for every linked agent.
Check
Every 30 seconds, connic confirms that the connection is still alive.
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.
{
"customer_id": "cus_4102",
"email": "jana@example.com",
"company": "Example GmbH",
"_postgres": {
"channel": "new_customers",
"pid": 48213,
"timestamp": "2026-10-13T09:00:00.123456"
}
}{
"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.
{
"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"
}
}{
"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.
{
"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"
}
}{
"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.
{
"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"
}
}{
"to": "owner@example.com",
"subject": "Your payment is past due",
"body": "The last payment for acc_2207 failed. Please update your card."
}PostgreSQL FAQ
More connectors
AWS SQS
Drain SQS queues with an agent. Each message is deleted once its runs complete, and failed ones return after the visibility timeout.
Inbound · Outbound
Gmail
Run an agent on new email in a Google Workspace mailbox and reply in the same thread. connic signs in with your own service account. Attachments included.
Inbound · Outbound
Jira
Run an agent on new issues, issue updates and comments in Jira Cloud. It comments back or creates a new issue.
Inbound · Outbound
Notion
Run an agent when pages are created or changed or comments are added in Notion. It replies in the comment's discussion or creates a new page.
Inbound · Outbound
Telnyx Messaging
Receive and send SMS/MMS, WhatsApp, and RCS messages through your Telnyx account. Connect agents to customer conversations and notifications.
Inbound · Outbound
Twilio Messaging
Receive SMS, MMS, WhatsApp, and RCS messages with an agent. Send replies, media, and WhatsApp templates through your Twilio account.
Inbound · Outbound