feat: Add an API to support querying metrics by ChannelType (#13255)

This API gives you how many conversations exist per channel, broken down
by status in a given time period. The max time period is capped to 6
months for now.

**Input Params:**
- **since:** Unix timestamp (seconds) - start of date range
- **until:** Unix timestamp (seconds) - end of date range


**Response Payload:**

```json
{
  "Channel::Sms": {
    "resolved": 85,
    "snoozed": 10,
    "open": 5,
    "pending": 5,
    "total": 100
  },
  "Channel::Email": {
    "resolved": 72,
    "snoozed": 15,
    "open": 13,
    "pending": 13,
    "total": 100
  },
  "Channel::WebWidget": {
    "resolved": 90,
    "snoozed": 7,
    "open": 3,
    "pending": 3,
    "total": 100
  }
}
```

**Definitons:**
resolved = Number of conversations created within the selected time
period that are currently marked as resolved.
snoozed = Number of conversations created within the selected time
period that are currently marked as snoozed.
pending = Number of conversations created within the selected time
period that are currently marked as pending.
open = Number of conversations created within the selected time period
that are currently open.
total = Total number of conversations created within the selected time
period, across all statuses.
This commit is contained in:
Pranav
2026-01-12 23:18:47 -08:00
committed by GitHub
parent 9407cc2ad5
commit 0917e1a646
16 changed files with 686 additions and 10 deletions

View File

@@ -223,6 +223,8 @@ account_summary:
$ref: './resource/reports/summary.yml'
agent_conversation_metrics:
$ref: './resource/reports/conversation/agent.yml'
channel_summary:
$ref: './resource/reports/channel_summary.yml'
contact_detail:
$ref: ./resource/contact_detail.yml

View File

@@ -0,0 +1,34 @@
type: object
description: Channel summary report containing conversation counts grouped by channel type and status. Available in version 4.10.0+.
additionalProperties:
type: object
description: Conversation statistics for a specific channel type (e.g., Channel::WebWidget, Channel::Api)
properties:
open:
type: number
description: Number of open conversations
resolved:
type: number
description: Number of resolved conversations
pending:
type: number
description: Number of pending conversations
snoozed:
type: number
description: Number of snoozed conversations
total:
type: number
description: Total number of conversations
example:
Channel::WebWidget:
open: 10
resolved: 20
pending: 5
snoozed: 2
total: 37
Channel::Api:
open: 5
resolved: 15
pending: 3
snoozed: 1
total: 24

View File

@@ -0,0 +1,30 @@
tags:
- Reports
operationId: get-channel-summary-report
summary: Get conversation statistics grouped by channel type
security:
- userApiKey: []
description: |
Get conversation counts grouped by channel type and status for a given date range.
Returns statistics for each channel type including open, resolved, pending, snoozed, and total conversation counts.
**Note:** This API endpoint is available only in Chatwoot version 4.10.0 and above. The date range is limited to a maximum of 6 months.
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/channel_summary'
'400':
description: Date range exceeds 6 months limit
content:
application/json:
schema:
$ref: '#/components/schemas/bad_request_error'
'403':
description: Access denied
content:
application/json:
schema:
$ref: '#/components/schemas/bad_request_error'

View File

@@ -639,6 +639,28 @@
get:
$ref: './application/reports/conversation/agent.yml'
# Channel summary report (Available in 4.10.0+)
/api/v2/accounts/{account_id}/summary_reports/channel:
parameters:
- $ref: '#/components/parameters/account_id'
- in: query
name: since
schema:
type: string
description: The timestamp from where report should start (Unix timestamp).
- in: query
name: until
schema:
type: string
description: The timestamp from where report should stop (Unix timestamp).
- in: query
name: business_hours
schema:
type: boolean
description: Whether to filter by business hours.
get:
$ref: './application/reports/channel_summary.yml'
# Conversations Messages
/accounts/{account_id}/conversations/{conversation_id}/messages:
parameters:

View File

@@ -7870,6 +7870,82 @@
}
}
},
"/api/v2/accounts/{account_id}/summary_reports/channel": {
"parameters": [
{
"$ref": "#/components/parameters/account_id"
},
{
"in": "query",
"name": "since",
"schema": {
"type": "string"
},
"description": "The timestamp from where report should start (Unix timestamp)."
},
{
"in": "query",
"name": "until",
"schema": {
"type": "string"
},
"description": "The timestamp from where report should stop (Unix timestamp)."
},
{
"in": "query",
"name": "business_hours",
"schema": {
"type": "boolean"
},
"description": "Whether to filter by business hours."
}
],
"get": {
"tags": [
"Reports"
],
"operationId": "get-channel-summary-report",
"summary": "Get conversation statistics grouped by channel type",
"security": [
{
"userApiKey": []
}
],
"description": "Get conversation counts grouped by channel type and status for a given date range.\nReturns statistics for each channel type including open, resolved, pending, snoozed, and total conversation counts.\n\n**Note:** This API endpoint is available only in Chatwoot version 4.10.0 and above. The date range is limited to a maximum of 6 months.\n",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/channel_summary"
}
}
}
},
"400": {
"description": "Date range exceeds 6 months limit",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/bad_request_error"
}
}
}
},
"403": {
"description": "Access denied",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/bad_request_error"
}
}
}
}
}
}
},
"/accounts/{account_id}/conversations/{conversation_id}/messages": {
"parameters": [
{
@@ -11659,6 +11735,52 @@
}
}
},
"channel_summary": {
"type": "object",
"description": "Channel summary report containing conversation counts grouped by channel type and status. Available in version 4.10.0+.",
"additionalProperties": {
"type": "object",
"description": "Conversation statistics for a specific channel type (e.g., Channel::WebWidget, Channel::Api)",
"properties": {
"open": {
"type": "number",
"description": "Number of open conversations"
},
"resolved": {
"type": "number",
"description": "Number of resolved conversations"
},
"pending": {
"type": "number",
"description": "Number of pending conversations"
},
"snoozed": {
"type": "number",
"description": "Number of snoozed conversations"
},
"total": {
"type": "number",
"description": "Total number of conversations"
}
}
},
"example": {
"Channel::WebWidget": {
"open": 10,
"resolved": 20,
"pending": 5,
"snoozed": 2,
"total": 37
},
"Channel::Api": {
"open": 5,
"resolved": 15,
"pending": 3,
"snoozed": 1,
"total": 24
}
}
},
"contact_detail": {
"type": "object",
"properties": {

View File

@@ -6412,6 +6412,82 @@
}
}
}
},
"/api/v2/accounts/{account_id}/summary_reports/channel": {
"parameters": [
{
"$ref": "#/components/parameters/account_id"
},
{
"in": "query",
"name": "since",
"schema": {
"type": "string"
},
"description": "The timestamp from where report should start (Unix timestamp)."
},
{
"in": "query",
"name": "until",
"schema": {
"type": "string"
},
"description": "The timestamp from where report should stop (Unix timestamp)."
},
{
"in": "query",
"name": "business_hours",
"schema": {
"type": "boolean"
},
"description": "Whether to filter by business hours."
}
],
"get": {
"tags": [
"Reports"
],
"operationId": "get-channel-summary-report",
"summary": "Get conversation statistics grouped by channel type",
"security": [
{
"userApiKey": []
}
],
"description": "Get conversation counts grouped by channel type and status for a given date range.\nReturns statistics for each channel type including open, resolved, pending, snoozed, and total conversation counts.\n\n**Note:** This API endpoint is available only in Chatwoot version 4.10.0 and above. The date range is limited to a maximum of 6 months.\n",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/channel_summary"
}
}
}
},
"400": {
"description": "Date range exceeds 6 months limit",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/bad_request_error"
}
}
}
},
"403": {
"description": "Access denied",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/bad_request_error"
}
}
}
}
}
}
}
},
"components": {
@@ -10166,6 +10242,52 @@
}
}
},
"channel_summary": {
"type": "object",
"description": "Channel summary report containing conversation counts grouped by channel type and status. Available in version 4.10.0+.",
"additionalProperties": {
"type": "object",
"description": "Conversation statistics for a specific channel type (e.g., Channel::WebWidget, Channel::Api)",
"properties": {
"open": {
"type": "number",
"description": "Number of open conversations"
},
"resolved": {
"type": "number",
"description": "Number of resolved conversations"
},
"pending": {
"type": "number",
"description": "Number of pending conversations"
},
"snoozed": {
"type": "number",
"description": "Number of snoozed conversations"
},
"total": {
"type": "number",
"description": "Total number of conversations"
}
}
},
"example": {
"Channel::WebWidget": {
"open": 10,
"resolved": 20,
"pending": 5,
"snoozed": 2,
"total": 37
},
"Channel::Api": {
"open": 5,
"resolved": 15,
"pending": 3,
"snoozed": 1,
"total": 24
}
}
},
"contact_detail": {
"type": "object",
"properties": {

View File

@@ -4378,6 +4378,52 @@
}
}
},
"channel_summary": {
"type": "object",
"description": "Channel summary report containing conversation counts grouped by channel type and status. Available in version 4.10.0+.",
"additionalProperties": {
"type": "object",
"description": "Conversation statistics for a specific channel type (e.g., Channel::WebWidget, Channel::Api)",
"properties": {
"open": {
"type": "number",
"description": "Number of open conversations"
},
"resolved": {
"type": "number",
"description": "Number of resolved conversations"
},
"pending": {
"type": "number",
"description": "Number of pending conversations"
},
"snoozed": {
"type": "number",
"description": "Number of snoozed conversations"
},
"total": {
"type": "number",
"description": "Total number of conversations"
}
}
},
"example": {
"Channel::WebWidget": {
"open": 10,
"resolved": 20,
"pending": 5,
"snoozed": 2,
"total": 37
},
"Channel::Api": {
"open": 5,
"resolved": 15,
"pending": 3,
"snoozed": 1,
"total": 24
}
}
},
"contact_detail": {
"type": "object",
"properties": {

View File

@@ -3793,6 +3793,52 @@
}
}
},
"channel_summary": {
"type": "object",
"description": "Channel summary report containing conversation counts grouped by channel type and status. Available in version 4.10.0+.",
"additionalProperties": {
"type": "object",
"description": "Conversation statistics for a specific channel type (e.g., Channel::WebWidget, Channel::Api)",
"properties": {
"open": {
"type": "number",
"description": "Number of open conversations"
},
"resolved": {
"type": "number",
"description": "Number of resolved conversations"
},
"pending": {
"type": "number",
"description": "Number of pending conversations"
},
"snoozed": {
"type": "number",
"description": "Number of snoozed conversations"
},
"total": {
"type": "number",
"description": "Total number of conversations"
}
}
},
"example": {
"Channel::WebWidget": {
"open": 10,
"resolved": 20,
"pending": 5,
"snoozed": 2,
"total": 37
},
"Channel::Api": {
"open": 5,
"resolved": 15,
"pending": 3,
"snoozed": 1,
"total": 24
}
}
},
"contact_detail": {
"type": "object",
"properties": {

View File

@@ -4554,6 +4554,52 @@
}
}
},
"channel_summary": {
"type": "object",
"description": "Channel summary report containing conversation counts grouped by channel type and status. Available in version 4.10.0+.",
"additionalProperties": {
"type": "object",
"description": "Conversation statistics for a specific channel type (e.g., Channel::WebWidget, Channel::Api)",
"properties": {
"open": {
"type": "number",
"description": "Number of open conversations"
},
"resolved": {
"type": "number",
"description": "Number of resolved conversations"
},
"pending": {
"type": "number",
"description": "Number of pending conversations"
},
"snoozed": {
"type": "number",
"description": "Number of snoozed conversations"
},
"total": {
"type": "number",
"description": "Total number of conversations"
}
}
},
"example": {
"Channel::WebWidget": {
"open": 10,
"resolved": 20,
"pending": 5,
"snoozed": 2,
"total": 37
},
"Channel::Api": {
"open": 5,
"resolved": 15,
"pending": 3,
"snoozed": 1,
"total": 24
}
}
},
"contact_detail": {
"type": "object",
"properties": {