Generate an agent
Now that we have a company, we can generate our agent.
For the purposes of this tutorial, we'll be using a standard template supplied by us.
You can find information on template lists and template creation in the following section: Templates.
We'll use this template ID : XXXX
.
In order to generate an agent, we need several pieces of information:
- companyId: The company ID you previously stored.
- templateId: The ID of the template you want to use. In our case, we'll use the one specified above.
- name: The agent name, which will be used on the various interfaces provided.
- cURL
- NodeJS
curl -X POST
-H "Authorization: Bearer <APIKEY>"
-H "Content-Type: application/json"
-d '{"companyId": "", "templateId": "", "name": ""}'
{{baseUrl}}/api/agents
const axios = require('axios');
const endpoint = "{{baseUrl}}/api/agents";
const apiKey = "YOUR API KEY";
const headers = {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
};
const data = {
companyId: "",
templateId: "XXXX",
name: "My First Agent"
};
axios.post(endpoint, data, { headers: headers })
.then(response => {
console.log('Status Code:', response.status);
console.log('Response Data:', response.data);
})
.catch(error => {
console.error('Error:', error.response.status);
console.error('Error Data:', error.response.data);
});
If everything works fine, API should return you this data.
{
"id": "ObjectID",
"name": "My First Agent",
"personalityId": "ObjectID",
"referee": {},
"scenarios": {},
"sentences": {},
"settings": {},
"setup": {},
"variables": {},
"partnerId": "ObjectID",
"companyId": "ObjectID",
"updatedAt": "2019-08-24T14:15:22Z",
"createdAt": "2019-08-24T14:15:22Z"
}