💻 SDK Integration

Deep-dive into the JavaScript and Python SDKs for full control over your integration.

JavaScript SDK

Use the JavaScript SDK in Node.js, React, Next.js, or any JavaScript/TypeScript environment.

Installation

npm install @aether-support/sdk

Quick Start

import { AetherClient } from '@aether-support/sdk';

// Initialize the client
const aether = new AetherClient({
  apiKey: process.env.AETHER_API_KEY,
  appId: process.env.AETHER_APP_ID,
});

// Create a ticket
const ticket = await aether.tickets.create({
  subject: 'Need help with billing',
  description: 'I was charged twice for my subscription',
  priority: 'high',
  customer: {
    email: 'customer@example.com',
    name: 'John Doe',
  },
});

console.log(`Created ticket: ${ticket.id}`);

TypeScript Support

import {
  AetherClient,
  Ticket,
  TicketCreateParams,
  TicketPriority
} from '@aether-support/sdk';

const params: TicketCreateParams = {
  subject: 'API integration question',
  description: 'How do I set up webhooks?',
  priority: TicketPriority.Medium,
  tags: ['api', 'integration'],
};

const ticket: Ticket = await aether.tickets.create(params);

Python SDK

Use the Python SDK in Django, Flask, FastAPI, or any Python application.

Installation

pip install aether-support

Quick Start

from aether_support import AetherClient

# Initialize the client
aether = AetherClient(
    api_key=os.environ["AETHER_API_KEY"],
    app_id=os.environ["AETHER_APP_ID"],
)

# Create a ticket
ticket = aether.tickets.create(
    subject="Need help with billing",
    description="I was charged twice for my subscription",
    priority="high",
    customer={
        "email": "customer@example.com",
        "name": "John Doe",
    },
)

print(f"Created ticket: {ticket.id}")

Async Support

from aether_support import AsyncAetherClient

async def main():
    aether = AsyncAetherClient(
        api_key=os.environ["AETHER_API_KEY"],
        app_id=os.environ["AETHER_APP_ID"],
    )

    # Async operations
    tickets = await aether.tickets.list(status="open")

    for ticket in tickets:
        print(f"{ticket.id}: {ticket.subject}")

asyncio.run(main())

Authentication

Both SDKs support multiple authentication methods.

Authentication Options

API Key (Recommended)

Use for server-side integrations. Never expose in client-side code.

OAuth 2.0

Use for user-authenticated actions. Supports refresh tokens.

JWT Token

Short-lived tokens for secure client-side operations.

// OAuth 2.0 Example (JavaScript)
const aether = new AetherClient({
  clientId: process.env.AETHER_CLIENT_ID,
  clientSecret: process.env.AETHER_CLIENT_SECRET,
  accessToken: userAccessToken,
  refreshToken: userRefreshToken,
  onTokenRefresh: (tokens) => {
    // Save new tokens
    saveToDatabase(tokens);
  },
});

Managing Tickets

Full CRUD operations for ticket management.

// List tickets with filters
const tickets = await aether.tickets.list({
  status: ['open', 'in_progress'],
  priority: 'high',
  assignee: 'agent@company.com',
  createdAfter: '2024-01-01',
  limit: 50,
});

// Get a single ticket
const ticket = await aether.tickets.get('TKT-123');

// Update ticket
await aether.tickets.update('TKT-123', {
  status: 'in_progress',
  assignee: 'agent@company.com',
  tags: [...ticket.tags, 'escalated'],
});

// Add a comment
await aether.tickets.addComment('TKT-123', {
  body: 'I have looked into this issue...',
  isInternal: false, // Visible to customer
});

// Close ticket
await aether.tickets.resolve('TKT-123', {
  resolution: 'Issue was resolved by refunding the duplicate charge.',
});

Knowledge Base

Programmatically manage your knowledge base content.

// Create an article
const article = await aether.kb.articles.create({
  title: 'How to reset your password',
  content: 'Follow these steps to reset your password...',
  category: 'Account',
  tags: ['password', 'security'],
  status: 'published',
});

// Search the knowledge base
const results = await aether.kb.search({
  query: 'reset password',
  limit: 5,
});

// Get semantic search results with scores
for (const result of results) {
  console.log(`[${result.score}] ${result.title}`);
}

// Trigger a website crawl
const job = await aether.kb.crawl({
  url: 'https://docs.yoursite.com',
  maxDepth: 3,
});

// Check crawl status
const status = await aether.kb.getCrawlStatus(job.id);
console.log(`Crawled ${status.pagesProcessed} pages`);

AI Features

Leverage AI capabilities directly in your application.

// Get AI-suggested replies
const suggestions = await aether.ai.suggestReplies({
  ticketId: 'TKT-123',
  count: 3,
});

for (const suggestion of suggestions) {
  console.log(`[${suggestion.confidence}%] ${suggestion.text}`);
}

// Chat with AI (streaming)
const stream = await aether.ai.chat({
  message: 'How do I upgrade my plan?',
  conversationId: 'conv_123', // Optional for context
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.text);
}

// Analyze sentiment
const analysis = await aether.ai.analyzeSentiment({
  text: 'I am very frustrated with the service!',
});

console.log(`Sentiment: ${analysis.sentiment}`); // negative
console.log(`Urgency: ${analysis.urgency}`);     // high
console.log(`Should escalate: ${analysis.shouldEscalate}`); // true

Rate Limits: AI features are subject to rate limits based on your plan. The SDK automatically handles rate limiting with exponential backoff.

Error Handling

Handle errors gracefully with typed exceptions.

import {
  AetherError,
  RateLimitError,
  NotFoundError,
  ValidationError
} from '@aether-support/sdk';

try {
  const ticket = await aether.tickets.get('TKT-999');
} catch (error) {
  if (error instanceof NotFoundError) {
    console.log('Ticket not found');
  } else if (error instanceof RateLimitError) {
    console.log(`Rate limited. Retry after ${error.retryAfter}s`);
  } else if (error instanceof ValidationError) {
    console.log('Invalid request:', error.details);
  } else if (error instanceof AetherError) {
    console.log(`API error: ${error.message}`);
  }
}