Crea un chatbot
L'API di Creazione di app.neoagent.co fornisce la funzionalità per creare un nuovo chatbot inviando una richiesta POST all'endpoint /chat/Chatbot/Add.
Endpoint
URL della Richiesta: https://app.neoagent.co/chat/Chatbot/Add
Metodo: POST
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)
Corpo della Richiesta
Il corpo della richiesta deve contenere i seguenti parametri:
{
// string, obbligatorio - Il fuso orario del chatbot (es., Asia/Shanghai, America/New_York)
"timeZone": "Asia/Shanghai",
// integer, obbligatorio - Deve essere 0 per chatbot generico
"type": 0
}
Parametri
timeZone- string, obbligatorio - Il fuso orario del chatbot (es., Asia/Shanghai, America/New_York)type- integer, obbligatorio - Deve essere 0 per chatbot generico
Esempi di Richiesta
- JavaScript (Fetch API)
- Python (Requests)
- cURL
- HTTP Raw
const res = await fetch('https://app.neoagent.co/chat/Chatbot/Add', {
method: 'POST',
headers: {
"Authorization": "<Your-Secret-Key>",
"Content-Type": "application/json"
},
body: JSON.stringify({
"timeZone": "Asia/Shanghai",
"type": 0
})
});
const data = await res.json();
console.log(data);
import requests
import json
url = 'https://app.neoagent.co/chat/Chatbot/Add'
headers = {
"Authorization": "<Your-Secret-Key>",
"Content-Type": "application/json"
}
data = {
"timeZone": "Asia/Shanghai",
"type": 0
}
response = requests.post(url, headers=headers, json=data)
data = response.json()
print(data)
curl 'https://app.neoagent.co/chat/Chatbot/Add' \
-X POST \
-H 'Authorization: <Your-Secret-Key>' \
-H 'Content-Type: application/json' \
-d '{"timeZone":"Asia/Shanghai","type":0}'
POST /chat/Chatbot/Add HTTP/1.1
Host: app.neoagent.co
Authorization: <Your-Secret-Key>
Content-Type: application/json
{
"timeZone": "Asia/Shanghai",
"type": 0
}
Risposta
La risposta API sarà un oggetto JSON con la seguente struttura:
{
// string - L'identificativo unico (ID) del chatbot creato
"Data": "3254a9d0424c4806b9ea3d0763xxxxxx",
// string - Versione API
"Version": "1.0.0",
// boolean - Stato di successo dell'operazione
"Success": true,
// integer - Codice di stato HTTP
"Code": 200,
// string - Messaggio di errore se presente
"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
Importante
Assicurati di sostituire <Your-Secret-Key> con la tua chiave API valida.
Prossimi Passi
Dopo aver creato il chatbot, puoi: