Skip to content

Manage Content

Learn how to configure and use the Content Admin feature, allowing designated administrators to view chat sessions and messages for any user in the system.

By the end of this guide, you will:

  • Enable content admin functionality
  • Grant content admin roles to users
  • Access and use the content admin interface
  • View user chat sessions and messages
  • Understand security and audit requirements
  • Debug user issues effectively
  • A running Pika installation
  • Access to pika-config.ts for site configuration
  • Ability to assign user roles (via auth provider or database)
  • Understanding of user privacy and security requirements

The Content Admin feature allows designated super-admin users to view chat sessions and messages for any user in the system.

  • View user sessions: Access any user's chat history for a specific chat app
  • Read messages: See complete conversation history
  • Search users: Find and select users through searchable interface
  • Per-chat app control: Select different users for different chat apps independently
  • Create new sessions: Read-only access for selected user
  • Send messages: Cannot interact as another user
  • Modify content: No ability to edit or delete user data
  • Override user data: Data override features disabled in content admin mode
  • Customer Support: Support agents helping customers debug issues
  • Technical Troubleshooting: Developers investigating reported bugs
  • Quality Assurance: QA teams verifying functionality across user profiles
  • UX Research: Understanding how different users interact
  • Compliance & Auditing: Reviewing interactions for compliance

Configure content admin in your pika-config.ts.

Location: apps/pika-chat/pika-config.ts

export const pikaConfig: PikaConfig = {
siteFeatures: {
contentAdmin: {
enabled: true
}
}
};

Users must have the pika:content-admin role to access the feature.

Option A: Authentication Provider Assignment

Section titled “Option A: Authentication Provider Assignment”

Automatically assign the role during authentication:

Location: apps/pika-chat/src/lib/server/auth-provider/index.ts

export default class YourAuthProvider extends AuthProvider<YourAuthData, YourCustomData> {
private createAuthenticatedUser(
userData: any,
token: string
): AuthenticatedUser<YourAuthData, YourCustomData> {
const roles: string[] = [];
// Add content admin role for authorized users
if (userData.email === 'admin@company.com') {
roles.push('pika:content-admin');
}
// Add for specific departments
if (userData.department === 'support' || userData.department === 'engineering') {
roles.push('pika:content-admin');
}
// Add for specific permissions from your system
if (userData.permissions?.includes('view_all_chats')) {
roles.push('pika:content-admin');
}
return {
userId: userData.id,
firstName: userData.firstName,
lastName: userData.lastName,
email: userData.email,
userType: userData.isEmployee ? 'internal-user' : 'external-user',
roles,
// ... other user data
};
}
}

Manually add the role in DynamoDB:

  1. Open AWS ConsoleDynamoDB
  2. Find table: chat-users-{your-stack-name}
  3. Locate user record by userId
  4. Add pika:content-admin to the roles array (create array if missing)
  5. Save changes

Example DynamoDB Record:

{
"userId": "admin_user_123",
"firstName": "Admin",
"lastName": "User",
"email": "admin@company.com",
"userType": "internal-user",
"roles": ["pika:content-admin", "support-agent"],
"customData": { }
}

Once configured and role assigned:

  1. Log in to Pika Chat with content admin account
  2. Click settings/menu icon (usually top right)
  3. Select "Content Admin" option
  4. Content admin dialog opens

The content admin dialog provides:

  • User Search: Auto-complete search field to find users
  • Current Selection: Shows which user you're viewing (if any)
  • Save Changes: Apply selection to begin viewing
  • Stop Viewing: Clear selection to return to your own content
  • Per-Chat App: Independent selections for each chat app
1. Open content admin dialog
2. Type user ID in search field (minimum 3 characters)
3. Select user from autocomplete results
4. Click "Save Changes"
5. Refresh the page
6. You now see the selected user's content

When viewing content for another user:

What You See:

  • All of the selected user's chat sessions for that chat app
  • Complete message history
  • User's custom data and preferences
  • Timestamps and session metadata

Visual Indicators:

  • Interface shows you're viewing content for another user
  • Banner or indicator displays target user ID
  • Read-only mode clearly indicated

Limitations:

  • Cannot create new sessions
  • Cannot send messages
  • Cannot modify user data
  • User data override features disabled
  • Full refresh required for changes to take effect

To return to your own content:

  1. Open content admin dialog
  2. Click "Stop Viewing" or clear user selection
  3. Save changes
  4. Refresh the page

Verify content admin works correctly:

  • Role Verification: Only users with pika:content-admin role can access
  • Per-Request Validation: Each API call verifies admin permissions
  • Feature Toggle: Can be completely disabled in configuration
  • Session Isolation: Viewing doesn't affect target user's experience

Implement audit logging for content admin actions:

// In your handler or middleware
console.log(`[AUDIT] Content admin ${adminUserId} began viewing content for user ${targetUserId} in chat app ${chatAppId}`);
// Consider logging to dedicated audit table
await auditLog.create({
action: 'content_admin_view',
adminUserId,
targetUserId,
chatAppId,
timestamp: new Date().toISOString(),
ipAddress: request.ip
});
  • Read-Only Access: Cannot modify or create content as another user
  • Controlled Scope: Access limited to chat data within the system
  • No persistent changes: Viewing state stored in session only
  • Privacy compliance: Ensure compliance with data protection regulations

When viewing content for another user:

  • No message creation: Send message button disabled
  • No data overrides: User data override UI hidden
  • Limited actions: Administrative actions restricted
  • Session scope: Viewing selection is per-chat app
// Configure for support team
siteFeatures: {
contentAdmin: {
enabled: true
}
}
// In auth provider
if (userData.department === 'support') {
roles.push('pika:content-admin');
}

Workflow:

  1. Customer reports issue with chat app
  2. Support agent logs in
  3. Opens content admin for affected chat app
  4. Searches for customer's user ID
  5. Views customer's chat history
  6. Identifies issue
  7. Provides solution
// QA team access
if (userData.roles?.includes('qa-engineer')) {
roles.push('pika:content-admin');
}

Workflow:

  1. QA needs to verify bug fix
  2. Accesses content admin
  3. Views affected user's sessions
  4. Confirms issue is resolved
  5. Documents findings
// Developers in non-production environments
if (userData.userType === 'internal-user' &&
userData.roles?.includes('developer') &&
process.env.NODE_ENV !== 'production') {
roles.push('pika:content-admin');
}

Workflow:

  1. Bug report with user ID
  2. Developer enables content admin for test environment
  3. Views user's chat history
  4. Reproduces issue
  5. Identifies root cause
  6. Implements fix
  • Verify contentAdmin.enabled: true in pika-config.ts
  • Check user has pika:content-admin role assigned
  • Confirm user is logged in with proper authentication
  • Clear browser cache and reload
  • Check console for JavaScript errors
  • Search requires user ID (not name or email)
  • Minimum 3 characters needed to start search
  • Verify user exists in chat-users DynamoDB table
  • Check search API endpoint is working
  • Review CloudWatch logs for search errors
  • Remember to refresh page after making selection
  • Check cookies are being set correctly
  • Verify browser isn't blocking cookie updates
  • Clear all cookies and re-login
  • Check session storage for persisted state

This is expected behavior - content admin is read-only:

  • Cannot send messages as another user
  • Cannot create new sessions
  • Cannot modify user data
  • This is by design for security
  • Verify role assignment in auth provider
  • Check DynamoDB user record has role in roles array
  • Ensure role is spelled exactly: pika:content-admin
  • Check role persists across login sessions
  • Review CloudWatch logs for authentication errors

Content admin relies on user data in DynamoDB:

Table: chat-users-{stack-name}

{
"userId": "user123",
"firstName": "John",
"lastName": "Doe",
"email": "john@example.com",
"userType": "internal-user",
"roles": ["pika:content-admin"],
"customData": { }
}

Viewing selections stored in user's session state:

{
"viewingContentFor": {
"chatapp-1": {
"userId": "target-user-123"
},
"chatapp-2": {
"userId": "another-user-456"
}
}
}

Storage Location: Session cookies or server-side session store

  • Limit role assignment: Only give to trusted personnel
  • Regular audits: Review who has content admin access
  • Rotate access: Remove role when no longer needed
  • Document usage: Keep records of why access was granted
  • User notification: Consider notifying users their content may be reviewed
  • Data minimization: Only view what's necessary for the task
  • Purpose limitation: Use only for legitimate support/debugging
  • Audit logging: Log all content admin activities
  • Compliance: Ensure alignment with GDPR, HIPAA, etc.
  • Clear purpose: Document why viewing is necessary
  • Time limits: Set viewing sessions to specific time frames
  • Supervisor approval: Require approval for content admin access
  • Training: Train staff on proper content admin usage
  • Incident response: Have procedures for abuse detection