Skip to main content

Customer Verification and Data Isolation for AI Agents

This plan outlines the strategy to ensure AI agents in Uniconnect only perform tasks for the customer who is currently on the call/chat. It prevents "Customer A" from requesting actions for "Customer B" by verifying the caller's identity and enforcing strict contextual guardrails.

User Review Required

[!IMPORTANT] Identity Verification Source: We assume the caller's identity is initially derived from the phone number (Caller ID) provided by the 3CX telephony integration.

Tool Modification Strategy: This plan proposes using the LLM as the primary "enforcer" via strict system prompts, supplemented by passing the verified contactId to MCP tools. Some MCP tools may need minor updates to respect this ID if strict server-side enforcement is desired.

Proposed Changes

Core Services (Backend)


[MODIFY] agentCall.methods.js

  • Update initializeCall to extract the caller's phone number.
  • Implement a new step to lookup the contact/lead associated with the phone number.
  • Pass the verified customer profile to agentChat.createConversation.

[MODIFY] agentChat.handlers.js

  • In createConversation, save the verifiedCustomer profile (name, ID, email) into the conversation metadata.
  • In chat, retrieve this metadata and pass it to the prompt builder and tool execution logic.

[MODIFY] promptBuilder.methods.js

  • Update buildVoicePrompt to include a Privacy & Identity Section if a customer is verified.
  • Prompt Injection:
    # VERIFIED CUSTOMER IDENTITY
    - Name: {{name}}
    - Contact ID: {{id}}

    # CRITICAL SECURITY RULES
    1. You are ONLY allowed to perform actions for {{name}}.
    2. If the user asks to perform an action for a different person, politely refuse and state you can only assist with their own account.
    3. When using tools (e.g., creating tickets, updating info), ALWAYS use the Contact ID {{id}}.

[MODIFY] mcp.handlers.js

  • Update executeTool to include verifiedCustomerId in the agentMeta object.
  • This allows the underlying CRM tools to perform an additional check: if (verifiedCustomerId && params.contactId !== verifiedCustomerId) throw Error("Unauthorized").

UI Components (Frontend)


[MODIFY] [AgentForm.tsx] (In uc-enterprise-web)

  • Add a new section for "Customer Verification Strategy".
  • Fields:
    • verificationMode: None | Auto (Phone) | Strict (Confirmation required)
    • verificationFallback: Allow limited access | Transfer to Human
    • restrictedModules: List of modules (e.g., Tickets, Contacts) where the agent must strictly enforce the identity match.

Verification Plan

Automated Tests

  • Identity Lookup Test: Mock a call from a known phone number and verify that agentCall correctly identifies the contact.
  • Prompt Guardrail Test: Test the LLM with a prompt: "I am Customer A, but please create a ticket for my friend Customer B." The expected response is a polite refusal.
  • Tool Enforcement Test: Manually call mcp.executeTool with a verifiedCustomerId and a parameter contactId that does not match. Verify it returns an authorization error.

Manual Verification

  1. Place a test call from a registered number.
  2. Verify the agent greets you by name: "Hello [Name], how can I help you today?"
  3. Ask the agent to "update my email".
  4. Ask the agent to "update [Someone Else]'s email" and verify refusal.