API & Development min read Intermediate

AI Assistant API Integration Guide

# AI Assistant API Integration Guide Transform your AI assistants into seamless extensions of your creator brand across any platform. Selgora's AI Assistant API enables you to embed intelligent, cont...

By george.olah@code24.ro Sep 29, 2025 6 views

AI Assistant API Integration Guide

Transform your AI assistants into seamless extensions of your creator brand across any platform. Selgora's AI Assistant API enables you to embed intelligent, context-aware customer support directly into external GPTs, websites, and applications, creating cohesive customer experiences that maintain access control and usage tracking.

The Power of Distributed AI Assistance

Success scales when your expertise becomes accessible everywhere your customers need help. By integrating Selgora's AI Assistant API with external platforms like ChatGPT, you create omnipresent support that maintains subscriber verification, tracks usage analytics, and provides consistent value regardless of where customers interact with your AI.

Why External AI Integration Matters

Expanded Accessibility: Meet customers where they already spend time, whether that's ChatGPT, custom applications, or integrated business tools.

Seamless Experience: Customers access your AI expertise without switching platforms or remembering multiple login credentials.

Usage Analytics: Track AI assistant utilization across all integration points to understand customer behavior and optimize your AI training.

Revenue Protection: Maintain subscriber verification and access control even when AI interactions occur outside Selgora's platform.

Understanding Selgora's AI Assistant Architecture

Access Verification System

Real-time Subscription Checking: Every AI interaction triggers a verification request to Selgora, ensuring only active subscribers can access your AI assistance.

Automatic Access Management: When subscriptions expire or are cancelled, AI access is immediately revoked across all integration points without manual intervention.

Usage Tracking and Analytics: All AI interactions are logged with detailed metrics including:

  • User identification and verification status
  • Interaction timestamps and frequency
  • Success/failure rates for access attempts
  • Geographic and usage pattern analytics

API Key Authentication

Unique Assistant Keys: Each AI assistant generates a unique API key that identifies both the assistant and the creator tenant:

Key Format: sk_live_[40-character-string] Example: sk_live_abc123def456ghi789jkl012mno345pqr678stu

Automatic Generation: API keys are created automatically when you create new AI assistants, ensuring immediate integration capability.

Setting Up Your AI Assistant for External Access

Creating AI Assistants in Selgora

Navigate to AI Assistant Management:

  1. Dashboard → AI Assistants → Create New Assistant
  2. Configure assistant name and description
  3. Set up knowledge base and response parameters
  4. Link assistant to specific offers for access control
  5. Copy the generated API key for external integration

Essential Configuration:

  • Assistant Name: Clear, descriptive name for customer recognition
  • Description: Purpose and capabilities explanation
  • Linked Offers: Specific subscriptions that grant access
  • Usage Limits: Optional rate limiting for cost control

GPT Integration Setup

Custom GPT Configuration: When creating custom GPTs that integrate with your Selgora AI assistant:

System Prompt Example:

You are [Assistant Name], a specialized assistant created by [Your Name] to help customers with [specific expertise area].

Before responding to any user request, you MUST verify their access by calling the Selgora verification API with their email address.

If verification succeeds, provide helpful, detailed responses within your area of expertise.

If verification fails, politely inform them they need an active subscription and provide the signup URL.

Always maintain a professional, helpful tone that reflects [Your Name]'s brand values.

API Action Configuration:

{
  "openapi": "3.0.0",
  "info": {
    "title": "Selgora AI Assistant Access Verification",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://app.selgora.com/api"
    }
  ],
  "paths": {
    "/v1/verify-access": {
      "post": {
        "summary": "Verify customer access to AI assistant",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_email": {
                    "type": "string",
                    "description": "Customer's email address"
                  }
                },
                "required": ["user_email"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Access verification result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "access": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "signup_url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}

Access Verification API Details

Endpoint Information

URL: https://app.selgora.com/api/v1/verify-access Method: POST Authentication: Bearer token using your AI assistant's API key Rate Limit: 60 requests per minute

Request Format

Headers:

Authorization: Bearer sk_live_your_assistant_api_key
Content-Type: application/json

Request Body:

{
  "user_email": "customer@example.com"
}

Alternative Parameter Name: The API accepts either user_email or email as the parameter name for flexibility with different integration systems.

Response Formats

Successful Verification (Customer Has Access):

{
  "access": true,
  "message": "Active subscription"
}

Access Denied - User Not Found:

{
  "access": false,
  "message": "You don't have access to this assistant. Please sign up for an offer to get access.",
  "signup_url": "https://your-landing-page-url.com"
}

Access Denied - Subscription Expired:

{
  "access": false,
  "message": "Your subscription has expired or you don't have an active offer. Please renew your subscription.",
  "signup_url": "https://your-landing-page-url.com"
}

Authentication Error:

{
  "message": "Unauthenticated."
}

Implementation Examples

GPT-4 Integration with Access Control

GPT System Behavior:

import requests
import json

def verify_customer_access(email, api_key):
    """Verify if customer has access to AI assistant"""
    url = "https://app.selgora.com/api/v1/verify-access"
    headers = {
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json"
    }
    data = {"user_email": email}

    try:
        response = requests.post(url, headers=headers, json=data)
        return response.json()
    except Exception as e:
        return {"access": False, "message": "Verification failed"}

def handle_customer_request(customer_email, customer_question, api_key):
    """Handle customer request with access verification"""
    # Verify access first
    access_result = verify_customer_access(customer_email, api_key)

    if access_result.get("access"):
        # Customer has access, provide assistance
        return provide_ai_assistance(customer_question)
    else:
        # Access denied, provide signup information
        message = access_result.get("message", "Access verification failed")
        signup_url = access_result.get("signup_url", "")

        return f"{message}\n\nGet access here: {signup_url}"

def provide_ai_assistance(question):
    """Provide AI assistance for verified customers"""
    # Your AI assistant logic here
    return "Helpful AI response based on your expertise..."

Custom Web Application Integration

JavaScript Implementation:

class SelgoraAIAssistant {
  constructor(apiKey) {
    this.apiKey = apiKey;
    this.baseUrl = 'https://app.selgora.com/api/v1';
  }

  async verifyAccess(email) {
    try {
      const response = await fetch(`${this.baseUrl}/verify-access`, {
        method: 'POST',
        headers: {
          'Authorization': `Bearer ${this.apiKey}`,
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({ user_email: email })
      });

      return await response.json();
    } catch (error) {
      return { 
        access: false, 
        message: 'Verification service unavailable' 
      };
    }
  }

  async handleChatMessage(userEmail, message) {
    const accessCheck = await this.verifyAccess(userEmail);

    if (accessCheck.access) {
      // Provide AI assistance
      return this.generateAIResponse(message);
    } else {
      // Return access denied message
      return {
        type: 'access_denied',
        message: accessCheck.message,
        signupUrl: accessCheck.signup_url
      };
    }
  }

  generateAIResponse(message) {
    // Your AI response logic here
    return {
      type: 'ai_response',
      message: 'AI-generated helpful response...'
    };
  }
}

// Usage
const assistant = new SelgoraAIAssistant('sk_live_your_api_key');

Mobile App Integration

React Native Example:

import AsyncStorage from '@react-native-async-storage/async-storage';

class SelgoraAIClient {
  constructor(apiKey) {
    this.apiKey = apiKey;
  }

  async verifyUserAccess() {
    try {
      const userEmail = await AsyncStorage.getItem('userEmail');
      if (!userEmail) {
        return { access: false, message: 'Please provide your email' };
      }

      const response = await fetch('https://app.selgora.com/api/v1/verify-access', {
        method: 'POST',
        headers: {
          'Authorization': `Bearer ${this.apiKey}`,
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({ user_email: userEmail })
      });

      return await response.json();
    } catch (error) {
      return { access: false, message: 'Connection error' };
    }
  }

  async sendMessage(message) {
    const accessCheck = await this.verifyUserAccess();

    if (accessCheck.access) {
      // Show AI interface and provide assistance
      return this.renderAIChat(message);
    } else {
      // Show subscription prompt
      return this.renderSubscriptionPrompt(accessCheck);
    }
  }
}

Usage Analytics and Monitoring

Built-in Analytics Tracking

Automatic Logging: Every access verification request generates detailed logs including:

  • Timestamp and user identification
  • Access granted/denied status
  • Reason for denial (no subscription, expired, etc.)
  • Geographic location and user agent information

Analytics Dashboard: View AI assistant performance through Selgora's analytics:

  • Total verification requests over time
  • Success vs. failure rates
  • Customer usage patterns and frequency
  • Geographic distribution of usage

Custom Analytics Integration

Webhook Notifications: Configure webhooks to receive real-time notifications about AI assistant usage:

  • Successful access verifications
  • Access denial patterns
  • High-usage customers requiring attention
  • API key usage approaching limits

External Analytics Platforms: Integrate usage data with your existing analytics stack:

  • Google Analytics for customer journey tracking
  • Mixpanel for user behavior analysis
  • Custom dashboards for business intelligence

Advanced Integration Patterns

Multi-Assistant Management

Assistant Specialization: Create multiple AI assistants for different customer segments or expertise areas:

  • Beginner-focused assistant for new customers
  • Advanced assistant for premium subscribers
  • Industry-specific assistants for niche audiences

Progressive Access Unlocking: Use different assistants for different subscription tiers:

  • Basic subscribers access foundational assistant
  • Premium subscribers unlock advanced AI capabilities
  • VIP subscribers gain access to specialized industry assistants

Cross-Platform Consistency

Brand Voice Maintenance: Ensure consistent AI personality and expertise across all integration points through:

  • Standardized system prompts and training
  • Regular assistant performance monitoring
  • Customer feedback collection and optimization
  • Consistent response quality standards

Knowledge Base Synchronization: Keep AI assistant knowledge current across all platforms:

  • Regular training data updates
  • Version control for assistant capabilities
  • Consistent response accuracy standards
  • Performance optimization based on usage analytics

Troubleshooting Common Issues

Access Verification Problems

API Key Issues:

  • Verify API key format and validity
  • Check that key corresponds to correct AI assistant
  • Ensure key has necessary permissions
  • Monitor key usage for rate limit breaches

Customer Email Problems:

  • Validate email format before API calls
  • Handle case sensitivity appropriately
  • Account for customer email changes
  • Provide clear error messages for invalid emails

Integration Performance

Response Time Optimization:

  • Implement caching for frequent access checks
  • Use asynchronous processing where possible
  • Monitor API response times and optimize
  • Implement fallback mechanisms for service unavailability

Rate Limit Management:

  • Monitor API usage against limits
  • Implement exponential backoff for retries
  • Cache verification results when appropriate
  • Consider usage patterns in system design

Success Indicators:

  • AI assistant access verification working reliably
  • Customer satisfaction with AI assistance quality
  • Usage analytics showing consistent engagement
  • Zero unauthorized access to AI capabilities
  • Smooth integration with external platforms

Integration Best Practices:

  • Always verify access before providing AI assistance
  • Provide clear messaging for access denied scenarios
  • Monitor usage patterns and optimize performance
  • Maintain consistent brand voice across all platforms
  • Implement proper error handling and fallback mechanisms

Remember: Your AI assistant API integration extends your expertise and customer service capabilities beyond Selgora's platform while maintaining complete access control and usage visibility. Focus on creating seamless customer experiences that provide value while protecting your intellectual property.

Was this article helpful?

Your feedback helps us improve our content

Table of Contents

Need Help?

Can't find what you're looking for? Our support team is ready to assist you.

Contact Support