Letterbook Docs
Connect PostgreSQL
Use PostgreSQL data to answer account, subscription, and usage questions.
Last updated June 25, 2026
What this guide covers#
Connect PostgreSQL with least-privilege access so Letterbook can look up support-safe customer data.
PostgreSQL context helps the AI answer tickets that depend on live account state, subscriptions, entitlements, usage, workspace membership, or product events.
Setup steps#
- Create a read-only role for Letterbook.
- Restrict access to support-safe tables or views.
- Add network access if your database uses an allowlist.
- Configure SSL according to your database requirements.
- Map customer identifiers such as email, user ID, account ID, or workspace ID.
- Test lookups with representative customers.
- Document field meanings and support policies in the knowledge base.
Configuration details#
- Connection string format
- SSL requirements
- IP allowlist requirements
- Recommended views for sensitive schemas
- How to rotate credentials
Use views for support-safe access#
For production databases, prefer views that expose only the fields support needs. This keeps the integration stable even if internal schema changes and reduces the risk of exposing sensitive data.
Good support views often include:
- Customer ID, email, and name
- Account or workspace ID
- Current plan and entitlement limits
- Subscription state from your application
- Recent usage or sync status
- Feature flags relevant to support
Avoid exposing password hashes, sessions, raw tokens, private keys, sensitive audit records, or unrelated personal data.
Identifier mapping#
Map identifiers based on how tickets enter Letterbook. Email-created tickets often match by email. API-created tickets can send a user ID, account ID, or workspace ID directly. Document fallback behavior for customers who use a different billing email or team email.
Testing checklist#
Test:
- Active customer
- Canceled or disabled customer
- Customer with multiple accounts
- Customer whose email changed
- Customer with missing database record
- Query timeout or connection failure behavior