# Business events structure (JSON) - Draft

For  clients we provide bussiness events in json webhooks. List of available events below.

Agent Login

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
    "message": {
     "event": {
       "agentId": "agentId",
       "orgId": "orgId",
       "firstName": "John",
       "lastName": "Doe",
       "email": "john.doe@example.com"
     },
     "description": {
       "kind": "event",
       "category": [
         "agent"
       ],
       "type": [
         "business_event"
       ],
       "action": "login",
       "outcome": "success"
     },
     "timestamp": 1635418772366
   }
}
```

Agent Logout

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
    "message": {
      "event": {
        "agentId": "agentId",
        "orgId": "orgId",
        "firstName": "Johin",
        "lastName": "Doe",
        "email": "john.doe@example.com"
      },
      "description": {
        "kind": "event",
        "category": [
          "agent"
        ],
        "type": [
          "business_event"
        ],
        "action": "logout",
        "outcome": "success"
      },
      "timestamp": 1635418772366
    }
 }
```

Agent Status Changed

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
      "message": {
        "event": {
          "agentId": "0000-0000...",
          "orgId": "0000-0000...",
          "status": "", // "AWAY", "AVAILABLE" and "UNAVAILABLE"
          "unavailableReason": "" // custom values
        },
        "description": {
          "kind": "event",
          "category": [
            "agent"
          ],
          "type": [
            "business_event"
          ],
          "action": "status_change",
          "outcome": "success"
        },
        "timestamp": 1635418772366
}
```

Conversation created

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
      "message": {
        "event": {
          "roomId": "0000-0000...",
          "orgId": "0000-0000...",
          "guestId": "0000-0000..."
        },
        "description": {
          "kind": "event",
          "category": [
            "conversation"
          ],
          "type": [
            "business_event"
          ],
          "action": "created",
          "outcome": "success"
        },
        "timestamp": 1635418772366
      }
}
```

Conversation backoffice data updated

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
    "message": {
      "event": {
        "roomId": "0000-0000...",
        "orgId": "0000-0000...",
        "guestId": "0000-0000...",
        "backofficeData": [
          {
            "key": "key",
            "value": "value"
          }
        ]
      },
      "description": {
        "kind": "event",
        "category": [
          "conversation"
        ],
        "type": [
          "business_event"
        ],
        "action": "backoffice_data_change",
        "outcome": "success"
      },
      "timestamp": 1635418772366
    }
  }
```

Conversation tag

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
    "message": {
      "event": {
        "roomId": "0000-0000...",
        "orgId": "0000-0000...",
        "tags": [
          "our-tag",
          "my-tag",
          "your-tag"
        ]
      },
      "description": {
        "kind": "event",
        "category": [
          "conversation"
        ],
        "type": [
          "business_event"
        ],
        "action": "tag_change",
        "outcome": "success"
      },
      "timestamp": 1635418772366
    }
}
```

Conversation assignee change

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
      "message": {
        "event": {
          "roomId": "0000-0000...",
          "orgId": "0000-0000...",
          "agentId": ""
        },
        "description": {
          "kind": "event",
          "category": [
            "conversation"
          ],
          "type": [
            "business_event"
          ],
          "action": "assignee_change",
          "outcome": "success"
        },
        "timestamp": 1635418772366
      }
}
```

Conversation unassigned

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
    "message": {
      "event": {
        "agentId": "0000-0000...",
        "orgId": "0000-0000...",
        "status": "unavailable",
        "unavailableReason": ""
      },
      "description": {
        "kind": "event",
        "category": [
          "agent"
        ],
        "type": [
          "business_event"
        ],
        "action": "status_change",
        "outcome": "success"
      },
      "timestamp": 1635418772366
    }
  }
```

Message sent

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
    "message": {
      "event": {
        "roomId": "0000-0000...",
        "orgId": "0000-0000...",
        "authorId": "0000-0000...",
        "body": "Hey!",
        "messageId": "0000-0000..."
      },
      "description": {
        "kind": "event",
        "category": [
          "conversation"
        ],
        "type": [
          "business_event"
          ],
          "action": "message_sent",
          "outcome": "success"
      },
      "timestamp": 1635418772366
   }
}
```

Custom message sent

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
    "message": {
      "event": {
        "roomId": "0000-0000...",
        "orgId": "0000-0000...",
        "subtag": "LEAD_TAGS_UPDATE", // may be custom (FORM, FORM_SUBMIT)
        "authorId": "0000-0000...",
        "payload": {
          "oldTags": [
            "tag1",
            "tag2"
          ],
          "oldTagGroupId": "0000-0000...",
          "tags": [
            "tag1",
            "tag2"
          ],
          "tagGroupId": "0000-0000..."
        },
        "messageId": "0000-0000..."
      },
      "description": {
        "kind": "event",
        "category": [
          "conversation"
        ],
        "type": [
          "business_event"
        ],
        "action": "custom_message_sent",
        "outcome": "success"
      },
      "timestamp": 1635418772366
    }
}
```

Custom message send (FORM metadata)

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
    "message": {
      "event": {
        "roomId": "0000-0000...",
        "orgId": "0000-0000...",
        "subtag": "MESSAGE_WITH_FORM",
        "authorId": "0000-0000...", // message (form submit) author id
        "payload": {
          "formId": "0000-0000..."
          "inputs": [
				{
					"name": "client-age",
					"value": "33"
				},
				{
					"name": "client-comment",
					"value": "The agent was very helpful!"
				},
				{
					"name": "external-form-id",
					"value": "0000-0000..."
				}
			],

        },
        "messageId": "0000-0000..."
      },
      "description": {
        "kind": "event",
        "category": [
          "conversation"
        ],
        "type": [
          "business_event"
        ],
        "action": "custom_message_sent",
        "outcome": "success"
      },
      "timestamp": 1635418772366
    }
  }
```

Conversation closed

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
    "message": {
      "event": {
        "roomId": "0000-0000..",
        "orgId": "0000-0000..",
        "status": "true",
        "sub_status": "solved"
      },
      "description": {
        "kind": "event",
        "category": [
          "conversation"
        ],
        "type": [
          "business_event"
        ],
        "action": "closed",
        "outcome": "success"
      },
      "timestamp": 1635418772366
    }
}
```

Conversation reopened / snoozed / unsnoozed

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
    "message": {
      "event": {
        "roomId": "0000-0000...",
        "orgId": "0000-0000...",
        "customerId": "0000-0000..."
      },
      "description": {
        "kind": "event",
        "category": [
          "conversation"
        ],
        "type": [
          "business_event"
        ],
        "action": "" // "reopened", "snoozed", "unsnoozed"
        "outcome": "success"
      },
      "timestamp": 1635418772366
    }
}
```

Conversation thread created

```
{
    "@timestamp": "2021-10-28T08:52:59.726+0000",
    "message": {
      "event": {
        "threadId": "0000-0000...",
        "roomId": "0000-0000...",
        "orgId": "0000-0000..."
      },
      "description": {
        "kind": "event",
        "category": [
          "conversation"
        ],
        "type": [
          "business_event"
        ],
        "action": "thread_created",
        "outcome": "success"
      },
      "timestamp": 1635418772366
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.closer.app/guide/upcoming-features-drafts/xbusiness-events-structure-json-draft.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
