Ottieni conoscenza base
L'API per l'ottenimento dei modelli di app.neoagent.co fornisce la funzionalità per creare un nuovo chatbot inviando una richiesta POST all'endpoint /chat/Chatbot/GetSource.
Endpoint
URL della Richiesta: https://app.neoagent.co/chat/Chatbot/GetSource
Metodo: POST
Corpo della Richiesta
Il corpo della richiesta deve contenere i seguenti parametri:
{
// string, required - The unique identifier (ID) of the chatbot
"serialNumber": "3254a9d0424c4806b9ea3d0763xxxxxx"
}
Parametri
serialNumber- string, obbligatorio - L'identificativo unico (ID) del chatbot da eliminare
Headers richiesti
La richiesta API deve includere i seguenti header:
Authorization: <Your-Secret-Key>- string, obbligatorio - La chiave segreta per autenticare la richiesta APIContent-Type: application/json- string, obbligatorio - Il tipo di contenuto del payload della richiesta (deve essere application/json)
Esempi di Richiesta
- JavaScript (Fetch API)
- Python (Requests)
- cURL
- HTTP Raw
const res = await fetch('https://app.neoagent.co/chat/Chatbot/GetSource', {
method: 'POST',
headers: {
"Authorization": "<Your-Secret-Key>",
"Content-Type": "application/json"
},
body: JSON.stringify({
"serialNumber": "3254a9d0424c4806b9ea3d0763xxxxxx"
})
});
const data = await res.json();
console.log(data);
import requests
import json
url = 'https://app.neoagent.co/chat/Chatbot/GetSource'
headers = {
"Authorization": "<Your-Secret-Key>",
"Content-Type": "application/json"
}
data = {
"serialNumber": "3254a9d0424c4806b9ea3d0763xxxxxx"
}
response = requests.post(url, headers=headers, json=data)
data = response.json()
print(data)
curl 'https://app.neoagent.co/chat/Chatbot/GetSource' \
-X POST \
-H 'Authorization: <Your-Secret-Key>' \
-H 'Content-Type: application/json' \
-d '{"serialNumber":"3254a9d0424c4806b9ea3d0763xxxxxx"}'
POST /chat/Chatbot/GetSource HTTP/1.1
Host: app.neoagent.co
Authorization: <Your-Secret-Key>
Content-Type: application/json
{
"serialNumber": "3254a9d0424c4806b9ea3d0763xxxxxx"
}
Risposta
La risposta API sarà un oggetto JSON con la seguente struttura:
{
// array - List of knowledge items
"Data": [
{
"Type": "FileList",
"Name": "34321",
"Value": "FAQ_0403.txt",
"Length": 12043,
"Status": 2,
"StatusMessage": "Succeeded",
"ID": 377631,
"SourceLink": ""
},
{
"Type": "CompanyInfo",
"Name": "CompanyInfo",
"Value": "",
"Length": 286,
"Status": 2,
"StatusMessage": "Succeeded",
"ID": 377634,
"SourceLink": ""
},
{
"Type": "UrlList",
"Name": "www.example.com",
"Value": "",
"Length": 0,
"Status": 3,
"StatusMessage": "Failed",
"ID": 377635,
"SourceLink": "www.example.com"
},
{
"Type": "Text",
"Name": "111111111",
"Value": "",
"Length": 9,
"Status": 2,
"StatusMessage": "Succeeded",
"ID": 377636,
"SourceLink": ""
},
{
"Type": "QAList",
"Name": "Question",
"Value": "Answer",
"Length": 9,
"Status": 2,
"StatusMessage": "Succeeded",
"ID": 377627,
"SourceLink": ""
}
],
// string - API version
"Version": "1.0.0",
// boolean - Operation success status
"Success": true,
// integer - HTTP status code
"Code": 200,
// string - Error message if any
"Message": ""
}
Gestione degli Errori
Se la richiesta fallisce, dovresti:
- Controllare il codice di stato HTTP per errori a livello di rete
- Esaminare i campi
CodeeMessagenella risposta per errori a livello business - Il campo
Messageconterrà informazioni dettagliate sull'errore