N2CS Query Basics

January 10, 20268 min read

Understanding how to structure queries in N2CS to access customer data safely and efficiently. Learn about read-only access patterns and query optimization.

Understanding how to structure queries in N2CS to access customer data safely and efficiently. Learn about read-only access patterns and query optimization.

Query Architecture in N2CS

N2CS uses approved searches that are defined by admins in advance. CS agents can only select from admin-approved searches, ensuring all data access is intentional, controlled, and auditable.

Unlike free-form database queries, N2CS searches follow predefined patterns that optimize for both safety and performance. Every search in N2CS is read-only by design, meaning you can retrieve information without any risk of modifying customer data.

CS teams don't see database schemas or have write access. They only see the approved search interfaces, ensuring no schema exposure and no risk of accidental modifications.

Approved Search Types

Admins define and approve search types that CS teams can use. These searches are optimized for specific operational needs. Examples include:

Customer Information Queries

These queries retrieve basic customer account information:

Query Type: Customer Info
Input: customer_id OR email OR phone
Returns: Account details, status, registration date

Customer information queries are optimized for fast lookups using indexed fields. They return essential account data needed for support interactions.

Order History Queries

Retrieve customer order and transaction history:

Query Type: Order History
Input: customer_id, date_range (optional)
Returns: Orders, transactions, payment status

Order history queries support optional date filtering to limit results and improve performance. Results are paginated automatically to handle large datasets efficiently.

Support Ticket Queries

Access customer support interaction history:

Query Type: Support Tickets
Input: customer_id, status (optional), date_range (optional)
Returns: Support tickets, interactions, resolution status

Support ticket queries help you understand a customer's interaction history and identify patterns or recurring issues.

Read-Only Access Patterns

All N2CS queries follow strict read-only patterns. Understanding these patterns helps you work effectively within the system's constraints:

No Write Operations

N2CS queries can only retrieve data. You cannot insert, update, or delete records through N2CS, ensuring system stability.

Structured Inputs

All queries require structured inputs (customer IDs, dates, status codes). This prevents SQL injection and ensures query safety.

Admin-Approved Searches Only

You can only use searches that have been defined and approved by your administrator. CS can only select from admin-approved searches, ensuring controlled access to data.

Automatic Pagination

Large result sets are automatically paginated to prevent performance issues and ensure responsive queries.

Query Optimization

N2CS automatically optimizes queries for performance, but understanding how queries work helps you use them more effectively:

Use Specific Identifiers

When possible, use the most specific identifier available. For example:

  • Customer ID is faster than email lookup
  • Email is faster than phone number lookup
  • Exact matches are faster than partial matches

Limit Date Ranges

When querying historical data, always specify date ranges when available:

Good: Order History (last 30 days)
Avoid: Order History (all time)

Limiting date ranges reduces the amount of data processed and improves query response times.

Combine Queries Efficiently

N2CS allows you to combine multiple query types in a single request. This is more efficient than making separate queries:

Efficient Approach:
Single query: Customer Info + Recent Orders

Less Efficient:
Query 1: Customer Info
Query 2: Recent Orders

Query Results and Formatting

N2CS formats query results in a consistent, operational-friendly format:

  • Structured data: Results are returned in a consistent structure, making them easy to read and understand
  • Context included: Each result includes relevant context (timestamps, status codes, related records)
  • Operational focus: Data is presented in a format optimized for support operations, not raw database format

Error Handling

When queries fail or return no results, N2CS provides clear error messages:

  • No results found: The query executed successfully but found no matching records
  • Invalid identifier: The provided identifier doesn't match any records in the system
  • Permission denied: Your user account doesn't have permission to access this data
  • System unavailable: The data source is temporarily unavailable (rare, but possible during maintenance)

All errors are logged in the audit trail, helping administrators identify and resolve issues quickly.

Best Practices Summary

Use Appropriate Query Types

Choose the query type that matches your information need. Don't use a broad query when a specific one will do.

Specify Date Ranges

Always include date ranges for historical queries to improve performance and relevance.

Combine Related Queries

Use combined queries when you need multiple pieces of information about the same customer.

Review Query Results

Take time to understand the structure of query results. This helps you find information faster in future queries.

Results Delivery

When searches are executed, results are delivered to Slack (if configured). Every action is recorded in the audit log, providing full traceability. This ensures that CS teams can access customer data directly from their workflow tools.

Next Steps

Now that you understand query basics, you can:

  • Practice with different approved searches in your N2CS environment
  • Review the Getting Started guide if you need to review setup basics
  • Use N2CS searches from Slack to get results delivered directly to your team
  • Contact your administrator to request additional approved searches if needed
  • Visit the N2CS homepage to see how CS teams use approved searches
← Back to DocumentationReturn to Home