Hop til hovedindhold

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​

  1. Log ind på din AI SmartTalk-konto
  2. Naviger til Indstillinger → Integrationer
  3. Find API og klik på Konfigurer

Trin 2: Generer API-token​

  1. Klik på Generer nyt token
  2. Kopier dit Chat Model ID og API-token
  3. 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​

FieldTypeRequiredDescription
chatModelIdstring✅Dit unikke chatmodel-id
documentsarray✅Array af dokumentobjekter
documents[].titlestring✅Dokumenttitel til identifikation
documents[].contentstring✅Fuld tekstindhold
documents[].urlstring❌Kilde-URL (til reference)
documents[].metadataobject❌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​

EndpointRate Limit
Document Import100 requests/minute
Query60 requests/minute
Search60 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​

CodeDescriptionSolution
INVALID_TOKENBad or expired tokenRegenerate API token
INVALID_MODEL_IDUnknown chat model IDCheck your Chat Model ID
RATE_LIMITEDToo many requestsImplement backoff, retry later
INVALID_REQUESTMalformed request bodyCheck JSON structure
DOCUMENT_TOO_LARGEContent exceeds limitSplit into smaller documents
QUOTA_EXCEEDEDPlan limits reachedUpgrade or contact support

Troubleshooting​

Authentication Fails​

IssueSolution
401 UnauthorizedCheck token is correct and active
Token not workingRegenerate token in settings
Expired tokenTokens don't expire, but can be revoked

Import Issues​

IssueSolution
Empty responseCheck Content-Type is application/json
Document not appearingWait for processing; check Knowledge section
Partial importSome documents may have validation errors

Performance Issues​

IssueSolution
Slow importsBatch documents (max 100 per request)
TimeoutsReduce batch size, retry with backoff
Rate limitedImplement exponential backoff

Best Practices​

  1. Batch imports: Send multiple documents per request (up to 100)
  2. Unique titles: Use descriptive, unique titles for each document
  3. Structured content: Well-formatted content improves AI responses
  4. Metadata tagging: Use metadata for categorization and filtering
  5. Secure tokens: Store tokens in environment variables
  6. Handle errors: Implement retry logic with exponential backoff
  7. Monitor usage: Track API calls against your plan limits

Klar til at løfte din
brugeroplevelse?

Implementer AI-assistenter, der glæder kunderne og skalerer med din virksomhed.

GDPR Overholdelse