> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thinnest.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Other Platforms

> Deploy your thinnestAI agent to Discord, custom apps, mobile apps, and any platform via the REST API.

# Other Platforms

Beyond the main channels, you can connect your agent to virtually any platform using webhooks or the REST API.

## Discord

Deploy your agent as a Discord bot for community servers.

### Setup

1. Go to [Discord Developer Portal](https://discord.com/developers/applications)
2. Click **New Application** and name it
3. Go to **Bot** > **Add Bot**
4. Copy the **Bot Token**
5. Under **Privileged Gateway Intents**, enable:
   * Message Content Intent
   * Server Members Intent
6. Go to **OAuth2 > URL Generator**:
   * Scopes: `bot`
   * Bot Permissions: `Send Messages`, `Read Message History`
7. Copy the generated URL and open it to invite the bot to your server

### Configure in thinnestAI

1. Open your agent > **Deploy** tab
2. Select **Discord**
3. Enter:
   * **Bot Token** — From Discord Developer Portal
   * **Application ID** — From General Information
4. Click **Save & Enable**

### Set Webhook

Configure the webhook URL in your Discord bot's interactions settings:

```
https://api.thinnest.ai/webhooks/discord/YOUR_AGENT_ID
```

### How It Works

* Users @mention the bot or DM it
* The bot responds in the same channel/DM
* Each user gets their own conversation session
* Leads are automatically captured with Discord user ID

## Mobile Apps

### React Native

```javascript theme={null}
import { useState } from 'react';

const AGENT_ID = 'agent_abc123';
const API_KEY = 'ak_your_key';

export function useAgent() {
  const [messages, setMessages] = useState([]);
  const [sessionId] = useState(() => `mobile_${Date.now()}`);

  const sendMessage = async (text) => {
    setMessages(prev => [...prev, { role: 'user', content: text }]);

    const response = await fetch(`https://api.thinnest.ai/v1/agents/${AGENT_ID}/chat`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        message: text,
        session_id: sessionId,
      }),
    });

    const data = await response.json();
    setMessages(prev => [...prev, { role: 'assistant', content: data.response }]);
  };

  return { messages, sendMessage };
}
```

### Flutter

```dart theme={null}
import 'dart:convert';
import 'package:http/http.dart' as http;

class AgentService {
  static const _agentId = 'agent_abc123';
  static const _apiKey = 'ak_your_key';
  final String sessionId;

  AgentService() : sessionId = 'flutter_${DateTime.now().millisecondsSinceEpoch}';

  Future<String> sendMessage(String message) async {
    final response = await http.post(
      Uri.parse('https://api.thinnest.ai/v1/agents/$_agentId/chat'),
      headers: {
        'Authorization': 'Bearer $_apiKey',
        'Content-Type': 'application/json',
      },
      body: jsonEncode({
        'message': message,
        'session_id': sessionId,
      }),
    );

    final data = jsonDecode(response.body);
    return data['response'];
  }
}
```

### Swift (iOS)

```swift theme={null}
import Foundation

struct AgentService {
    static let agentId = "agent_abc123"
    static let apiKey = "ak_your_key"
    let sessionId = "ios_\(Int(Date().timeIntervalSince1970))"

    func sendMessage(_ message: String) async throws -> String {
        let url = URL(string: "https://api.thinnest.ai/v1/agents/\(Self.agentId)/chat")!
        var request = URLRequest(url: url)
        request.httpMethod = "POST"
        request.setValue("Bearer \(Self.apiKey)", forHTTPHeaderField: "Authorization")
        request.setValue("application/json", forHTTPHeaderField: "Content-Type")
        request.httpBody = try JSONEncoder().encode([
            "message": message,
            "session_id": sessionId,
        ])

        let (data, _) = try await URLSession.shared.data(for: request)
        let response = try JSONDecoder().decode([String: String].self, from: data)
        return response["response"] ?? ""
    }
}
```

## Custom Webhooks

Build your own integration by forwarding messages to the REST API:

```python theme={null}
# Example: Custom webhook handler
from fastapi import FastAPI
import httpx

app = FastAPI()
AGENT_ID = "agent_abc123"
API_KEY = "ak_your_key"

@app.post("/my-webhook")
async def handle_webhook(request: dict):
    user_message = request["message"]
    user_id = request["user_id"]

    async with httpx.AsyncClient() as client:
        response = await client.post(
            f"https://api.thinnest.ai/v1/agents/{AGENT_ID}/chat",
            headers={"Authorization": f"Bearer {API_KEY}"},
            json={
                "message": user_message,
                "session_id": f"custom_{user_id}",
            },
        )

    return {"reply": response.json()["response"]}
```

## Shopify

Add the chat widget to your Shopify store:

1. Go to **Online Store > Themes > Edit code**
2. Open `theme.liquid`
3. Before the closing `</body>` tag, add:

```html theme={null}
<script
  src="https://app.thinnest.ai/embed.js"
  data-agent-id="YOUR_AGENT_ID"
  data-theme="light"
  data-welcome-message="Hi! Need help finding something?"
  async
></script>
```

4. Save

## Webflow

1. Go to **Project Settings > Custom Code**
2. In the **Footer Code** section, add the embed script
3. Publish your site

## Squarespace

1. Go to **Settings > Advanced > Code Injection**
2. In the **Footer** section, add the embed script
3. Save

## Wix

1. Go to your site editor
2. Click **Add** > **Embed** > **Custom Embeds** > **Embed a Widget**
3. Click **Enter Code** and paste the embed script
4. Position the widget and publish

## Bubble.io

1. Add an **HTML** element to your page
2. Paste the embed script in the element's HTML content
3. Preview and deploy

## Any Platform

The [REST API](/docs/deploy/rest-api) works with any platform that can make HTTP requests. The general pattern is:

1. Receive a message from your platform
2. Forward it to `POST /v1/agents/{agent_id}/chat` with your API key
3. Return the response to the user

This works for:

* Email bots (via SendGrid, Mailgun webhooks)
* SMS (via Twilio, directly — not WhatsApp)
* Voice assistants (via speech-to-text + text-to-speech)
* IoT devices
* Game chat systems
* Internal tools and dashboards
