Documentation

Learn how the Senpilot CX Tool Manager works and how to integrate it with your AI agents.

Overview

The Senpilot CX Tool Manager is a multi-tenant middleware service that enables AI agents to access utility customer data through standardized tool interfaces. It routes tool calls to either internal databases or external APIs based on tenant-specific configurations.

Multi-tenant

Each tenant has isolated configurations

Flexible Routing

Internal DB or external APIs per tool

Secure

Auth tokens stored in secrets manager

How Tool Execution Works
AI AgentTool Manager APIConnector FactoryData Source
  1. 1

    Request Received

    Agent calls POST /api/tools/execute with tenantId, toolName, and input parameters

  2. 2

    Validation

    Tenant status checked (must be active), input validated against tool schema

  3. 3

    Connector Selection

    Based on tenant's tool config, routes to Internal DB connector or External REST connector

  4. 4

    Execution & Response

    Tool executed, result logged, and canonical response returned with metadata

Data Source Types
INTERNAL_DB

Routes tool calls to the internal Senpilot database. Ideal for tenants who store their customer data directly in the platform.

  • No external dependencies
  • Fast response times
  • Default when no config exists
EXTERNAL_REST

Routes tool calls to an external REST API. Perfect for integrating with existing utility systems or third-party services.

  • Multiple auth types (API Key, Bearer, OAuth2)
  • Field mapping support
  • Configurable HTTP methods
Available Tools
check_account_balance

Retrieve current account balance, due date, and payment history

Inputs:

  • accountNumber (required)
  • customerId (optional)

Outputs:

  • currentBalance
  • dueDate
  • pastDueAmount
  • paymentHistory
check_outage_map

Check active outages and estimated restoration times by location

Inputs:

  • zipCode (required)
  • utilityType (optional: electric/water/gas)

Outputs:

  • activeOutages
  • estimatedRestoration
  • affectedCustomers
check_current_meter

Get the current meter reading and usage information

Inputs:

  • accountNumber (required)
  • meterId (optional)

Outputs:

  • currentReading
  • usageSinceLastRead
  • meterType
  • timestamp
analyze_meter

Analyze meter usage patterns, trends, and anomalies over time

Inputs:

  • accountNumber (required)
  • startDate
  • endDate
  • granularity

Outputs:

  • usagePatterns
  • trends
  • anomalies
  • recommendations
analyze_bills

Analyze billing history and payment patterns

Inputs:

  • accountNumber (required)
  • months (default: 12)

Outputs:

  • paymentPatterns
  • billingHistory
  • paymentPlanEligibility
create_ticket

Create a support ticket for customer issues

Inputs:

  • accountNumber
  • category
  • subject
  • description
  • priority

Outputs:

  • ticketId
  • status
  • assignedTeam
  • estimatedResponseTime
API Examples

Execute a Tool

POST /api/tools/execute
Content-Type: application/json

{
  "tenantId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
  "toolName": "check_account_balance",
  "input": {
    "accountNumber": "ACC-12345"
  }
}

Response

{
  "success": true,
  "data": {
    "utilityCompany": "ZapCo Electric",
    "accountNumber": "ACC-12345",
    "currentBalance": 142.50,
    "dueDate": "2025-01-15",
    "pastDueAmount": 0,
    "accountStatus": "current"
  },
  "metadata": {
    "executionTimeMs": 45,
    "source": "internal_db",
    "tenantId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
    "toolName": "check_account_balance"
  }
}

Get Tool Definitions (for LLM)

GET /api/tools/definitions?tenantId=a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d

# Returns tool schemas in a format suitable for LLM function calling

Configure External API Tool

POST /api/tenants/{tenantId}/tools
Content-Type: application/json

{
  "toolName": "check_account_balance",
  "sourceType": "EXTERNAL_REST",
  "enabled": true,
  "endpointUrl": "https://api.myutility.com/v1/billing",
  "authType": "API_KEY",
  "authSecretRef": "my-utility-api-key",
  "configJson": {
    "method": "GET",
    "pathSuffix": "/balance"
  },
  "fieldMappings": {
    "accountNumber": "account_id",
    "currentBalance": "balance_due"
  }
}
Field Mapping

When integrating with external APIs that use different field names, configure field mappings to translate between canonical names and the external API's schema.

Canonical FieldExternal API FieldDirection
accountNumberaccount_idInput
currentBalancebalance_amountOutput
dueDatepayment_dueOutput
Authentication Types
API_KEY

Sends API key in a custom header (default: X-API-Key)

BEARER

Sends token in Authorization: Bearer <token> header

OAUTH2

OAuth 2.0 flow with automatic token refresh (coming soon)

NONE

No authentication required (for public APIs)

Secrets are stored securely and referenced by name via authSecretRef. In production, secrets are resolved from AWS Secrets Manager, HashiCorp Vault, or environment variables.