Use case 5: Creating employees for ingestion using Employee Management APIs

If the employee you want to ingest the interaction for is missing and you do not want to use the default agent, you can create the employee on the fly and ingest the interaction for the newly created employee.

In this example, you sent the following metadata POST request and it returned Bad Request (HTTP 400) because the employee with ID XXXXXXXXX could not be found.

Copy
"api": {
"allow_missing_agent": false
},
...
"contacts": [
{
...
"sessions": [
{
"agent_id": "XXXXXXXXX"
...
}
]
}
]

To create the employee named John Smith, you would use the Employee Management API, specifically POST /wfo/user-mgmt-api/v1/employees?organizationId=X.

Copy
 "data": {
"attributes": {
"person": {
"address": {
...
},
"contact": {
...
},
"firstName": "John",
"lastName": "Smith",
},
"user": {
"username": "johnsmith92"
}
...
}
}

This command creates the user John Smith and assigns him to the organization with ID X. You now need his Agent ID to reference him in the ingestion metadata POST request. In the headers from the previous POST request, you can see the employee ID in the Location header, GET wfo/user-mgmt-api/v1/employees/102. You can use this ID to query the user details.

Copy
 
"data": {
"id": "102",
"type": "employee",
"attributes": {
"qmAnalyticsId": 855000102
...
}
...
}

You would use qmAnalyticsID in your ingestion request.

Copy
"api": {
"allow_missing_agent": false
},
...
"contacts": [
{
...
"sessions": [
{
"agent_id": "855000102"
...
}
]
}
]
...

The agent_id is not the only field you can use to identify an employee. John can be associated with a workspace. Workspace can be queried with GET wfo/user-mgmt-api/v1/employees/102/workspace.

Copy
"data": {
"type": "workspace",
"id": "102",
"attributes": {
"assets": [
{
"dataSourceID": 8,
"employeeID": 102,
"loginName": "john_pbx_id",
"links": {
"related": [
...
]
}
}
]
}
}

The loginName from the response can be used in the pbx_login_id field to identify an employee. In this example, the agent_id field can be omitted as follows.

Copy
"api": {
"allow_missing_agent": false
},
...
"contacts": [
{
...
"sessions": [
{
"pbx_login_id": "john_pbx_id"
...
}
]
}
]
...

Use cases