API Integration
Push data programmatisk til din AI SmartTalk vidensbase ved hjælp af vores REST API. Ideel til tilpassede integrationer, automatiserede pipelines og enhver datakilde, der ikke dækkes af vores native connectors.
Oversigt
API-integrationen gør det muligt for dig at:
- Push dokumenter direkte til din vidensbase
- Opdatere indhold programmatisk
- Slette forældede poster
- Bygge tilpassede datapipelines
- Integrere med ethvert system, der kan foretage HTTP-anmodninger
Forudsætninger
Før du begynder, skal du sikre dig, at du har:
- En aktiv AI SmartTalk-konto
- API-adgang aktiveret (tjek din plan)
- Grundlæggende viden om REST APIs
- Et værktøj til at foretage HTTP-anmodninger (curl, Postman eller din applikationskode)
Få Dine API-legitimationsoplysninger
Trin 1: Adgang til API-indstillinger
- Log ind på din AI SmartTalk-konto
- Naviger til Indstillinger → Integrationer
- Find API og klik på Konfigurer
Trin 2: Generer API-token
- Klik på Generer nyt token
- Kopier dit Chat Model ID og API-token
- Opbevar disse sikkert—token vises kun én gang!
⚠️ Sikkerhedsadvarsel: Udsæt aldrig dit API-token i klient-side kode eller offentlige repositories.
API Endpoints
Base URL
https://api.aismarttalk.tech/v1
Autentificering
Alle anmodninger kræver dit API-token i headeren:
Authorization: Bearer YOUR_API_TOKEN
API Endpoints
Base URL
https://api.aismarttalk.tech/v1
Authentication
Alle anmodninger kræver din API-token i headeren:
Authorization: Bearer YOUR_API_TOKEN
Import Documents
Endpoint
POST /documents/import
Request Body
{
"chatModelId": "your-chat-model-id",
"documents": [
{
"title": "Produktdokumentation",
"content": "Det fulde indhold af dit dokument går her...",
"url": "https://example.com/docs/product",
"metadata": {
"category": "dokumentation",
"language": "en"
}
}
]
}
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
chatModelId | string | ✅ | Dit unikke chatmodel-id |
documents | array | ✅ | Array af dokumentobjekter |
documents[].title | string | ✅ | Dokumenttitel til identifikation |
documents[].content | string | ✅ | Fuld tekstindhold |
documents[].url | string | ❌ | Kilde-URL (til reference) |
documents[].metadata | object | ❌ | Brugerdefinerede nøgle-værdi-par |
Response
{
"success": true,
"imported": 1,
"documents": [
{
"id": "doc_abc123",
"title": "Produktdokumentation",
"status": "behandler"
}
]
}
Example: cURL
curl -X POST https://api.aismarttalk.tech/v1/documents/import \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"chatModelId": "your-chat-model-id",
"documents": [
{
"title": "Kom godt i gang guide",
"content": "Velkommen til vores platform. Her er hvordan du kommer i gang...",
"url": "https://docs.example.com/getting-started"
}
]
}'
Query Documents
Stil spørgsmål til din vidensbase programmatisk.
Endpoint
POST /chat/query
Request Body
{
"chatModelId": "your-chat-model-id",
"query": "Hvordan nulstiller jeg min adgangskode?",
"options": {
"maxTokens": 500,
"temperature": 0.7
}
}
Response
{
"success": true,
"response": "For at nulstille din adgangskode, gå til Indstillinger > Sikkerhed > Ændre adgangskode...",
"sources": [
{
"documentId": "doc_abc123",
"title": "Sikkerhedsguide",
"relevance": 0.95
}
]
}
Retrieve Documents
Hent dokumenter, der matcher en forespørgsel (uden AI-respons).
Endpoint
POST /documents/search
Request Body
{
"chatModelId": "your-chat-model-id",
"query": "adgangskode sikkerhed",
"limit": 10
}
Response
{
"success": true,
"documents": [
{
"id": "doc_abc123",
"title": "Bedste praksis for sikkerhed",
"content": "...",
"relevance": 0.92
}
]
}
Kodeeksempler
Python
import requests
API_TOKEN = "your-api-token"
CHAT_MODEL_ID = "your-chat-model-id"
def import_document(title: str, content: str, url: str = None):
response = requests.post(
"https://api.aismarttalk.tech/v1/documents/import",
headers={
"Authorization": f"Bearer {API_TOKEN}",
"Content-Type": "application/json"
},
json={
"chatModelId": CHAT_MODEL_ID,
"documents": [{
"title": title,
"content": content,
"url": url
}]
}
)
return response.json()
# Importer et dokument
result = import_document(
title="FAQ: Forsendelse",
content="Vi tilbyder gratis forsendelse på ordrer over $50...",
url="https://shop.example.com/faq/shipping"
)
print(result)
JavaScript / Node.js
const API_TOKEN = 'your-api-token';
const CHAT_MODEL_ID = 'your-chat-model-id';
async function importDocument(title, content, url = null) {
const response = await fetch('https://api.aismarttalk.tech/v1/documents/import', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
chatModelId: CHAT_MODEL_ID,
documents: [{
title,
content,
url
}]
})
});
return response.json();
}
// Importer et dokument
importDocument(
'FAQ: Returneringer',
'Du kan returnere varer inden for 30 dage efter køb...',
'https://shop.example.com/faq/returns'
).then(console.log);
PHP
<?php
$apiToken = 'your-api-token';
$chatModelId = 'your-chat-model-id';
$data = [
'chatModelId' => $chatModelId,
'documents' => [
[
'title' => 'Produktspecifikationer',
'content' => 'Vores widget har følgende specifikationer...',
'url' => 'https://example.com/products/widget'
]
]
];
$ch = curl_init('https://api.aismarttalk.tech/v1/documents/import');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiToken,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
curl_close($ch);
print_r(json_decode($response, true));
Anvendelsessager
Tilpasset CMS-integration
Synk indhold fra et proprietært CMS:
- Hook ind i CMS publiceringsbegivenheder
- Push nyt/opdateret indhold til AI SmartTalk
- Fjern slettet indhold
Datapipeline
Importer fra datalagre:
- Eksporter relevante data til JSON
- Batchimport via API
- Planlæg regelmæssige opdateringer
E-handelsprodukter
Synk produktdata fra tilpassede systemer:
- Produktbeskrivelser
- Specifikationer
- Prisinformation
Interne systemer
Forbind interne værktøjer, der ikke understøttes nativt:
- Tilpassede wikis
- Arv databaser
- Proprietære applikationer
Rate Limits
| Endpoint | Rate Limit |
|---|---|
| Document Import | 100 requests/minute |
| Query | 60 requests/minute |
| Search | 60 requests/minute |
Note: Rate limits varierer afhængigt af planen. Kontakt support for højere grænser.
Error Handling
Error Response Format
{
"success": false,
"error": {
"code": "INVALID_TOKEN",
"message": "The provided API token is invalid or expired"
}
}
Common Error Codes
| Code | Description | Solution |
|---|---|---|
INVALID_TOKEN | Bad or expired token | Regenerate API token |
INVALID_MODEL_ID | Unknown chat model ID | Check your Chat Model ID |
RATE_LIMITED | Too many requests | Implement backoff, retry later |
INVALID_REQUEST | Malformed request body | Check JSON structure |
DOCUMENT_TOO_LARGE | Content exceeds limit | Split into smaller documents |
QUOTA_EXCEEDED | Plan limits reached | Upgrade or contact support |
Troubleshooting
Authentication Fails
| Issue | Solution |
|---|---|
| 401 Unauthorized | Check token is correct and active |
| Token not working | Regenerate token in settings |
| Expired token | Tokens don't expire, but can be revoked |
Import Issues
| Issue | Solution |
|---|---|
| Empty response | Check Content-Type is application/json |
| Document not appearing | Wait for processing; check Knowledge section |
| Partial import | Some documents may have validation errors |
Performance Issues
| Issue | Solution |
|---|---|
| Slow imports | Batch documents (max 100 per request) |
| Timeouts | Reduce batch size, retry with backoff |
| Rate limited | Implement exponential backoff |
Best Practices
- Batch imports: Send multiple documents per request (up to 100)
- Unique titles: Use descriptive, unique titles for each document
- Structured content: Well-formatted content improves AI responses
- Metadata tagging: Use metadata for categorization and filtering
- Secure tokens: Store tokens in environment variables
- Handle errors: Implement retry logic with exponential backoff
- Monitor usage: Track API calls against your plan limits