feat: add code samples for conversation and messages

This commit is contained in:
Shivam Mishra
2026-02-19 12:48:29 +05:30
parent 594333a183
commit 70a9895c51
15 changed files with 549 additions and 0 deletions
@@ -21,6 +21,37 @@ requestBody:
type: number
description: Id of the team. If the assignee_id is present, this param would be ignored
example: 1
x-codeSamples:
- lang: python
label: "Assign to an agent"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
conversation = client.conversations.assign(
account_id=1,
conversation_id=42,
assignee_id=10
)
- lang: python
label: "Assign to a team"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
conversation = client.conversations.update(
account_id=1,
conversation_id=42,
team_id=5
)
responses:
'200':
description: Success
@@ -5,6 +5,24 @@ description: Filter conversations with custom filter options and pagination
summary: Conversations Filter
security:
- userApiKey: []
x-codeSamples:
- lang: python
label: "Filter conversations"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
# Use the list method with built-in filters
conversations = client.conversations.list(
account_id=1,
status="pending",
assignee_type="unassigned",
inbox_id=5
)
parameters:
- name: page
in: query
@@ -50,6 +50,43 @@ get:
default: 1
description: paginate through conversations
x-codeSamples:
- lang: python
label: "List open conversations"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
conversations = client.conversations.list(
account_id=1,
status="open",
assignee_type="me",
page=1
)
for conversation in conversations:
print(conversation.id, conversation.status)
- lang: python
label: "Search conversations"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
conversations = client.conversations.list(
account_id=1,
q="billing issue",
inbox_id=5,
labels=["support"]
)
responses:
'200':
description: Success
@@ -79,6 +116,25 @@ post:
application/json:
schema:
$ref: '#/components/schemas/conversation_create_payload'
x-codeSamples:
- lang: python
label: "Create a conversation"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
conversation = client.conversations.create(
account_id=1,
source_id="user-123",
inbox_id=5,
contact_id=100
)
print(conversation.id, conversation.inbox_id)
responses:
'200':
description: Success
@@ -5,6 +5,26 @@ summary: Add Labels
security:
- userApiKey: []
description: Add labels to a conversation. Note that this API would overwrite the existing list of labels associated to the conversation.
x-codeSamples:
- lang: python
label: "Add labels to conversation"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
# Note: this overwrites existing labels
labels = client.conversations.labels.add(
account_id=1,
conversation_id=42,
labels=["support", "billing"]
)
print(labels)
# ['support', 'billing']
requestBody:
required: true
content:
@@ -5,6 +5,24 @@ summary: List Labels
security:
- userApiKey: []
description: Lists all the labels of a conversation
x-codeSamples:
- lang: python
label: "List conversation labels"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
labels = client.conversations.labels.list(
account_id=1,
conversation_id=42
)
print(labels)
# ['support', 'billing', 'urgent']
responses:
'200':
description: Success
@@ -56,6 +56,40 @@ description: |
security:
- userApiKey: []
- agentBotApiKey: []
x-codeSamples:
- lang: python
label: "Send a message"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
message = client.messages.create(
account_id=1,
conversation_id=42,
content="Hello, how can I help you today?"
)
print(message.id, message.content)
- lang: python
label: "Send a private note"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
note = client.messages.create(
account_id=1,
conversation_id=42,
content="Internal note: Customer needs follow-up",
private=True
)
requestBody:
required: true
content:
@@ -5,6 +5,21 @@ summary: Delete a message
security:
- userApiKey: []
description: Delete a message and it's attachments from the conversation.
x-codeSamples:
- lang: python
label: "Delete a message"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
client.messages.delete(
account_id=1,
message_id=123
)
responses:
'200':
description: Success
@@ -5,6 +5,24 @@ summary: Get messages
security:
- userApiKey: []
description: List all messages of a conversation
x-codeSamples:
- lang: python
label: "List messages"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
messages = client.messages.list(
account_id=1,
conversation_id=42
)
for message in messages:
print(message.content, message.message_type)
responses:
'200':
description: Success
@@ -37,6 +37,25 @@ get:
items:
type: string
x-codeSamples:
- lang: python
label: "Get conversation counts"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
counts = client.conversations.get_counts(
account_id=1,
status="open"
)
print(counts)
# {'mine_count': 5, 'unassigned_count': 12, 'assigned_count': 8, 'all_count': 25}
responses:
'200':
description: Success
@@ -5,6 +5,25 @@ summary: Conversation Details
security:
- userApiKey: []
description: Get all details regarding a conversation with all messages in the conversation
x-codeSamples:
- lang: python
label: "Get conversation details"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
conversation = client.conversations.get(
account_id=1,
conversation_id=42
)
print(conversation.id, conversation.status)
print(conversation.meta)
print(conversation.messages)
responses:
'200':
description: Success
@@ -20,6 +20,22 @@ requestBody:
enum: ['urgent', 'high', 'medium', 'low', 'none']
description: 'The priority of the conversation'
example: 'high'
x-codeSamples:
- lang: python
label: "Set conversation priority"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
conversation = client.conversations.update(
account_id=1,
conversation_id=42,
priority="urgent"
)
responses:
'200':
description: Success
@@ -33,6 +33,39 @@ requestBody:
customer reply. The conversation always reopens when the
customer replies.
example: 1757506877
x-codeSamples:
- lang: python
label: "Resolve a conversation"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
result = client.conversations.toggle_status(
account_id=1,
conversation_id=42,
status="resolved"
)
print(result.success, result.current_status)
- lang: python
label: "Reopen a conversation"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
result = client.conversations.toggle_status(
account_id=1,
conversation_id=42,
status="open"
)
responses:
'200':
description: Success
@@ -22,6 +22,22 @@ requestBody:
type: number
description: 'The ID of the SLA policy (Available only in Enterprise edition)'
example: 1
x-codeSamples:
- lang: python
label: "Update conversation priority"
source: |
from chatwoot import ChatwootClient
client = ChatwootClient(
base_url="https://app.chatwoot.com",
api_token="your-api-token"
)
conversation = client.conversations.update(
account_id=1,
conversation_id=42,
priority="high"
)
responses:
'200':
description: Success
+118
View File
@@ -4282,6 +4282,13 @@
}
}
],
"x-codeSamples": [
{
"lang": "python",
"label": "Get conversation counts",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\ncounts = client.conversations.get_counts(\n account_id=1,\n status=\"open\"\n)\n\nprint(counts)\n# {'mine_count': 5, 'unassigned_count': 12, 'assigned_count': 8, 'all_count': 25}\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -4417,6 +4424,18 @@
"description": "paginate through conversations"
}
],
"x-codeSamples": [
{
"lang": "python",
"label": "List open conversations",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversations = client.conversations.list(\n account_id=1,\n status=\"open\",\n assignee_type=\"me\",\n page=1\n)\n\nfor conversation in conversations:\n print(conversation.id, conversation.status)\n"
},
{
"lang": "python",
"label": "Search conversations",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversations = client.conversations.list(\n account_id=1,\n q=\"billing issue\",\n inbox_id=5,\n labels=[\"support\"]\n)\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -4465,6 +4484,13 @@
}
}
},
"x-codeSamples": [
{
"lang": "python",
"label": "Create a conversation",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversation = client.conversations.create(\n account_id=1,\n source_id=\"user-123\",\n inbox_id=5,\n contact_id=100\n)\n\nprint(conversation.id, conversation.inbox_id)\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -4521,6 +4547,13 @@
"userApiKey": []
}
],
"x-codeSamples": [
{
"lang": "python",
"label": "Filter conversations",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\n# Use the list method with built-in filters\nconversations = client.conversations.list(\n account_id=1,\n status=\"pending\",\n assignee_type=\"unassigned\",\n inbox_id=5\n)\n"
}
],
"parameters": [
{
"name": "page",
@@ -4642,6 +4675,13 @@
}
],
"description": "Get all details regarding a conversation with all messages in the conversation",
"x-codeSamples": [
{
"lang": "python",
"label": "Get conversation details",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversation = client.conversations.get(\n account_id=1,\n conversation_id=42\n)\n\nprint(conversation.id, conversation.status)\nprint(conversation.meta)\nprint(conversation.messages)\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -4719,6 +4759,13 @@
}
}
},
"x-codeSamples": [
{
"lang": "python",
"label": "Update conversation priority",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversation = client.conversations.update(\n account_id=1,\n conversation_id=42,\n priority=\"high\"\n)\n"
}
],
"responses": {
"200": {
"description": "Success"
@@ -4801,6 +4848,18 @@
}
}
},
"x-codeSamples": [
{
"lang": "python",
"label": "Resolve a conversation",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nresult = client.conversations.toggle_status(\n account_id=1,\n conversation_id=42,\n status=\"resolved\"\n)\n\nprint(result.success, result.current_status)\n"
},
{
"lang": "python",
"label": "Reopen a conversation",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nresult = client.conversations.toggle_status(\n account_id=1,\n conversation_id=42,\n status=\"open\"\n)\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -4911,6 +4970,13 @@
}
}
},
"x-codeSamples": [
{
"lang": "python",
"label": "Set conversation priority",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversation = client.conversations.update(\n account_id=1,\n conversation_id=42,\n priority=\"urgent\"\n)\n"
}
],
"responses": {
"200": {
"description": "Success"
@@ -5068,6 +5134,18 @@
}
}
},
"x-codeSamples": [
{
"lang": "python",
"label": "Assign to an agent",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversation = client.conversations.assign(\n account_id=1,\n conversation_id=42,\n assignee_id=10\n)\n"
},
{
"lang": "python",
"label": "Assign to a team",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversation = client.conversations.update(\n account_id=1,\n conversation_id=42,\n team_id=5\n)\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -5123,6 +5201,13 @@
}
],
"description": "Lists all the labels of a conversation",
"x-codeSamples": [
{
"lang": "python",
"label": "List conversation labels",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nlabels = client.conversations.labels.list(\n account_id=1,\n conversation_id=42\n)\n\nprint(labels)\n# ['support', 'billing', 'urgent']\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -5168,6 +5253,13 @@
}
],
"description": "Add labels to a conversation. Note that this API would overwrite the existing list of labels associated to the conversation.",
"x-codeSamples": [
{
"lang": "python",
"label": "Add labels to conversation",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\n# Note: this overwrites existing labels\nlabels = client.conversations.labels.add(\n account_id=1,\n conversation_id=42,\n labels=[\"support\", \"billing\"]\n)\n\nprint(labels)\n# ['support', 'billing']\n"
}
],
"requestBody": {
"required": true,
"content": {
@@ -6039,6 +6131,13 @@
}
],
"description": "List all messages of a conversation",
"x-codeSamples": [
{
"lang": "python",
"label": "List messages",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nmessages = client.messages.list(\n account_id=1,\n conversation_id=42\n)\n\nfor message in messages:\n print(message.content, message.message_type)\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -6124,6 +6223,18 @@
"agentBotApiKey": []
}
],
"x-codeSamples": [
{
"lang": "python",
"label": "Send a message",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nmessage = client.messages.create(\n account_id=1,\n conversation_id=42,\n content=\"Hello, how can I help you today?\"\n)\n\nprint(message.id, message.content)\n"
},
{
"lang": "python",
"label": "Send a private note",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nnote = client.messages.create(\n account_id=1,\n conversation_id=42,\n content=\"Internal note: Customer needs follow-up\",\n private=True\n)\n"
}
],
"requestBody": {
"required": true,
"content": {
@@ -6199,6 +6310,13 @@
}
],
"description": "Delete a message and it's attachments from the conversation.",
"x-codeSamples": [
{
"lang": "python",
"label": "Delete a message",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nclient.messages.delete(\n account_id=1,\n message_id=123\n)\n"
}
],
"responses": {
"200": {
"description": "Success"
+118
View File
@@ -2825,6 +2825,13 @@
}
}
],
"x-codeSamples": [
{
"lang": "python",
"label": "Get conversation counts",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\ncounts = client.conversations.get_counts(\n account_id=1,\n status=\"open\"\n)\n\nprint(counts)\n# {'mine_count': 5, 'unassigned_count': 12, 'assigned_count': 8, 'all_count': 25}\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -2960,6 +2967,18 @@
"description": "paginate through conversations"
}
],
"x-codeSamples": [
{
"lang": "python",
"label": "List open conversations",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversations = client.conversations.list(\n account_id=1,\n status=\"open\",\n assignee_type=\"me\",\n page=1\n)\n\nfor conversation in conversations:\n print(conversation.id, conversation.status)\n"
},
{
"lang": "python",
"label": "Search conversations",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversations = client.conversations.list(\n account_id=1,\n q=\"billing issue\",\n inbox_id=5,\n labels=[\"support\"]\n)\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -3008,6 +3027,13 @@
}
}
},
"x-codeSamples": [
{
"lang": "python",
"label": "Create a conversation",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversation = client.conversations.create(\n account_id=1,\n source_id=\"user-123\",\n inbox_id=5,\n contact_id=100\n)\n\nprint(conversation.id, conversation.inbox_id)\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -3064,6 +3090,13 @@
"userApiKey": []
}
],
"x-codeSamples": [
{
"lang": "python",
"label": "Filter conversations",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\n# Use the list method with built-in filters\nconversations = client.conversations.list(\n account_id=1,\n status=\"pending\",\n assignee_type=\"unassigned\",\n inbox_id=5\n)\n"
}
],
"parameters": [
{
"name": "page",
@@ -3185,6 +3218,13 @@
}
],
"description": "Get all details regarding a conversation with all messages in the conversation",
"x-codeSamples": [
{
"lang": "python",
"label": "Get conversation details",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversation = client.conversations.get(\n account_id=1,\n conversation_id=42\n)\n\nprint(conversation.id, conversation.status)\nprint(conversation.meta)\nprint(conversation.messages)\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -3262,6 +3302,13 @@
}
}
},
"x-codeSamples": [
{
"lang": "python",
"label": "Update conversation priority",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversation = client.conversations.update(\n account_id=1,\n conversation_id=42,\n priority=\"high\"\n)\n"
}
],
"responses": {
"200": {
"description": "Success"
@@ -3344,6 +3391,18 @@
}
}
},
"x-codeSamples": [
{
"lang": "python",
"label": "Resolve a conversation",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nresult = client.conversations.toggle_status(\n account_id=1,\n conversation_id=42,\n status=\"resolved\"\n)\n\nprint(result.success, result.current_status)\n"
},
{
"lang": "python",
"label": "Reopen a conversation",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nresult = client.conversations.toggle_status(\n account_id=1,\n conversation_id=42,\n status=\"open\"\n)\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -3454,6 +3513,13 @@
}
}
},
"x-codeSamples": [
{
"lang": "python",
"label": "Set conversation priority",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversation = client.conversations.update(\n account_id=1,\n conversation_id=42,\n priority=\"urgent\"\n)\n"
}
],
"responses": {
"200": {
"description": "Success"
@@ -3611,6 +3677,18 @@
}
}
},
"x-codeSamples": [
{
"lang": "python",
"label": "Assign to an agent",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversation = client.conversations.assign(\n account_id=1,\n conversation_id=42,\n assignee_id=10\n)\n"
},
{
"lang": "python",
"label": "Assign to a team",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nconversation = client.conversations.update(\n account_id=1,\n conversation_id=42,\n team_id=5\n)\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -3666,6 +3744,13 @@
}
],
"description": "Lists all the labels of a conversation",
"x-codeSamples": [
{
"lang": "python",
"label": "List conversation labels",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nlabels = client.conversations.labels.list(\n account_id=1,\n conversation_id=42\n)\n\nprint(labels)\n# ['support', 'billing', 'urgent']\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -3711,6 +3796,13 @@
}
],
"description": "Add labels to a conversation. Note that this API would overwrite the existing list of labels associated to the conversation.",
"x-codeSamples": [
{
"lang": "python",
"label": "Add labels to conversation",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\n# Note: this overwrites existing labels\nlabels = client.conversations.labels.add(\n account_id=1,\n conversation_id=42,\n labels=[\"support\", \"billing\"]\n)\n\nprint(labels)\n# ['support', 'billing']\n"
}
],
"requestBody": {
"required": true,
"content": {
@@ -4582,6 +4674,13 @@
}
],
"description": "List all messages of a conversation",
"x-codeSamples": [
{
"lang": "python",
"label": "List messages",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nmessages = client.messages.list(\n account_id=1,\n conversation_id=42\n)\n\nfor message in messages:\n print(message.content, message.message_type)\n"
}
],
"responses": {
"200": {
"description": "Success",
@@ -4667,6 +4766,18 @@
"agentBotApiKey": []
}
],
"x-codeSamples": [
{
"lang": "python",
"label": "Send a message",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nmessage = client.messages.create(\n account_id=1,\n conversation_id=42,\n content=\"Hello, how can I help you today?\"\n)\n\nprint(message.id, message.content)\n"
},
{
"lang": "python",
"label": "Send a private note",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nnote = client.messages.create(\n account_id=1,\n conversation_id=42,\n content=\"Internal note: Customer needs follow-up\",\n private=True\n)\n"
}
],
"requestBody": {
"required": true,
"content": {
@@ -4742,6 +4853,13 @@
}
],
"description": "Delete a message and it's attachments from the conversation.",
"x-codeSamples": [
{
"lang": "python",
"label": "Delete a message",
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nclient.messages.delete(\n account_id=1,\n message_id=123\n)\n"
}
],
"responses": {
"200": {
"description": "Success"