feat: add sdk examples for contacts
This commit is contained in:
@@ -22,6 +22,24 @@ get:
|
||||
description: ID of the contact
|
||||
security:
|
||||
- userApiKey: []
|
||||
x-codeSamples:
|
||||
- lang: python
|
||||
label: "Get contact conversations"
|
||||
source: |
|
||||
from chatwoot import ChatwootClient
|
||||
|
||||
client = ChatwootClient(
|
||||
base_url="https://app.chatwoot.com",
|
||||
api_token="your-api-token"
|
||||
)
|
||||
|
||||
conversations = client.contacts.conversations(
|
||||
account_id=1,
|
||||
contact_id=100
|
||||
)
|
||||
|
||||
for conversation in conversations:
|
||||
print(conversation.id, conversation.status)
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
|
||||
@@ -15,6 +15,20 @@ get:
|
||||
security:
|
||||
- userApiKey: []
|
||||
description: Get a contact belonging to the account using ID
|
||||
x-codeSamples:
|
||||
- lang: python
|
||||
label: "Get contact details"
|
||||
source: |
|
||||
from chatwoot import ChatwootClient
|
||||
|
||||
client = ChatwootClient(
|
||||
base_url="https://app.chatwoot.com",
|
||||
api_token="your-api-token"
|
||||
)
|
||||
|
||||
contact = client.contacts.get(account_id=1, contact_id=100)
|
||||
|
||||
print(contact.name, contact.email, contact.phone_number)
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
@@ -43,6 +57,26 @@ put:
|
||||
security:
|
||||
- userApiKey: []
|
||||
description: Update a contact belonging to the account using ID
|
||||
x-codeSamples:
|
||||
- lang: python
|
||||
label: "Update a contact"
|
||||
source: |
|
||||
from chatwoot import ChatwootClient
|
||||
|
||||
client = ChatwootClient(
|
||||
base_url="https://app.chatwoot.com",
|
||||
api_token="your-api-token"
|
||||
)
|
||||
|
||||
contact = client.contacts.update(
|
||||
account_id=1,
|
||||
contact_id=100,
|
||||
name="Jane Doe",
|
||||
email="jane@example.com",
|
||||
custom_attributes={"plan": "premium"}
|
||||
)
|
||||
|
||||
print(contact.id, contact.name)
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
@@ -77,6 +111,18 @@ delete:
|
||||
security:
|
||||
- userApiKey: []
|
||||
description: Delete a contact belonging to the account using ID
|
||||
x-codeSamples:
|
||||
- lang: python
|
||||
label: "Delete a contact"
|
||||
source: |
|
||||
from chatwoot import ChatwootClient
|
||||
|
||||
client = ChatwootClient(
|
||||
base_url="https://app.chatwoot.com",
|
||||
api_token="your-api-token"
|
||||
)
|
||||
|
||||
client.contacts.delete(account_id=1, contact_id=100)
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
|
||||
@@ -6,6 +6,22 @@ post:
|
||||
summary: Contact Filter
|
||||
security:
|
||||
- userApiKey: []
|
||||
x-codeSamples:
|
||||
- lang: python
|
||||
label: "Filter contacts"
|
||||
source: |
|
||||
from chatwoot import ChatwootClient
|
||||
|
||||
client = ChatwootClient(
|
||||
base_url="https://app.chatwoot.com",
|
||||
api_token="your-api-token"
|
||||
)
|
||||
|
||||
# Use search to find contacts by name, email, or phone
|
||||
contacts = client.contacts.search(
|
||||
account_id=1,
|
||||
query="example.com"
|
||||
)
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/account_id'
|
||||
- name: page
|
||||
|
||||
@@ -15,6 +15,24 @@ get:
|
||||
description: Lists all the labels of a contact
|
||||
security:
|
||||
- userApiKey: []
|
||||
x-codeSamples:
|
||||
- lang: python
|
||||
label: "List contact labels"
|
||||
source: |
|
||||
from chatwoot import ChatwootClient
|
||||
|
||||
client = ChatwootClient(
|
||||
base_url="https://app.chatwoot.com",
|
||||
api_token="your-api-token"
|
||||
)
|
||||
|
||||
labels = client.contacts.labels.list(
|
||||
account_id=1,
|
||||
contact_id=100
|
||||
)
|
||||
|
||||
print(labels)
|
||||
# ['vip', 'enterprise']
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
@@ -43,6 +61,26 @@ post:
|
||||
description: Add labels to a contact. Note that this API would overwrite the existing list of labels associated to the conversation.
|
||||
security:
|
||||
- userApiKey: []
|
||||
x-codeSamples:
|
||||
- lang: python
|
||||
label: "Add labels to contact"
|
||||
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.contacts.labels.add(
|
||||
account_id=1,
|
||||
contact_id=100,
|
||||
labels=["vip", "enterprise"]
|
||||
)
|
||||
|
||||
print(labels)
|
||||
# ['vip', 'enterprise']
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
|
||||
@@ -10,6 +10,21 @@ get:
|
||||
- $ref: '#/components/parameters/account_id'
|
||||
- $ref: '#/components/parameters/contact_sort_param'
|
||||
- $ref: '#/components/parameters/page'
|
||||
x-codeSamples:
|
||||
- lang: python
|
||||
label: "List all contacts"
|
||||
source: |
|
||||
from chatwoot import ChatwootClient
|
||||
|
||||
client = ChatwootClient(
|
||||
base_url="https://app.chatwoot.com",
|
||||
api_token="your-api-token"
|
||||
)
|
||||
|
||||
contacts = client.contacts.list(account_id=1, page=1)
|
||||
|
||||
for contact in contacts:
|
||||
print(contact.name, contact.email)
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
@@ -34,6 +49,26 @@ post:
|
||||
- userApiKey: []
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/account_id'
|
||||
x-codeSamples:
|
||||
- lang: python
|
||||
label: "Create a contact"
|
||||
source: |
|
||||
from chatwoot import ChatwootClient
|
||||
|
||||
client = ChatwootClient(
|
||||
base_url="https://app.chatwoot.com",
|
||||
api_token="your-api-token"
|
||||
)
|
||||
|
||||
result = client.contacts.create(
|
||||
account_id=1,
|
||||
inbox_id=5,
|
||||
name="John Doe",
|
||||
email="john@example.com",
|
||||
phone_number="+1234567890"
|
||||
)
|
||||
|
||||
print(result.contact.id, result.contact_inbox.source_id)
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
|
||||
@@ -15,6 +15,35 @@ get:
|
||||
description: Search using contact `name`, `identifier`, `email` or `phone number`
|
||||
- $ref: '#/components/parameters/contact_sort_param'
|
||||
- $ref: '#/components/parameters/page'
|
||||
x-codeSamples:
|
||||
- lang: python
|
||||
label: "Search by email"
|
||||
source: |
|
||||
from chatwoot import ChatwootClient
|
||||
|
||||
client = ChatwootClient(
|
||||
base_url="https://app.chatwoot.com",
|
||||
api_token="your-api-token"
|
||||
)
|
||||
|
||||
contacts = client.contacts.search(
|
||||
account_id=1,
|
||||
query="john@example.com"
|
||||
)
|
||||
|
||||
for contact in contacts:
|
||||
print(contact.name, contact.email)
|
||||
- lang: python
|
||||
label: "Search by name"
|
||||
source: |
|
||||
from chatwoot import ChatwootClient
|
||||
|
||||
client = ChatwootClient(
|
||||
base_url="https://app.chatwoot.com",
|
||||
api_token="your-api-token"
|
||||
)
|
||||
|
||||
contacts = client.contacts.search(account_id=1, query="John Doe")
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
|
||||
@@ -2674,6 +2674,13 @@
|
||||
"$ref": "#/components/parameters/page"
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "List all contacts",
|
||||
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\ncontacts = client.contacts.list(account_id=1, page=1)\n\nfor contact in contacts:\n print(contact.name, contact.email)\n"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
@@ -2714,6 +2721,13 @@
|
||||
"$ref": "#/components/parameters/account_id"
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Create a contact",
|
||||
"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.contacts.create(\n account_id=1,\n inbox_id=5,\n name=\"John Doe\",\n email=\"john@example.com\",\n phone_number=\"+1234567890\"\n)\n\nprint(result.contact.id, result.contact_inbox.source_id)\n"
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
@@ -2775,6 +2789,13 @@
|
||||
}
|
||||
],
|
||||
"description": "Get a contact belonging to the account using ID",
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Get contact details",
|
||||
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\ncontact = client.contacts.get(account_id=1, contact_id=100)\n\nprint(contact.name, contact.email, contact.phone_number)\n"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
@@ -2820,6 +2841,13 @@
|
||||
}
|
||||
],
|
||||
"description": "Update a contact belonging to the account using ID",
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Update a contact",
|
||||
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\ncontact = client.contacts.update(\n account_id=1,\n contact_id=100,\n name=\"Jane Doe\",\n email=\"jane@example.com\",\n custom_attributes={\"plan\": \"premium\"}\n)\n\nprint(contact.id, contact.name)\n"
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
@@ -2875,6 +2903,13 @@
|
||||
}
|
||||
],
|
||||
"description": "Delete a contact belonging to the account using ID",
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Delete a contact",
|
||||
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nclient.contacts.delete(account_id=1, contact_id=100)\n"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success"
|
||||
@@ -2940,6 +2975,13 @@
|
||||
"userApiKey": []
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Get contact 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.contacts.conversations(\n account_id=1,\n contact_id=100\n)\n\nfor conversation in conversations:\n print(conversation.id, conversation.status)\n"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
@@ -3001,6 +3043,13 @@
|
||||
"userApiKey": []
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "List contact 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.contacts.labels.list(\n account_id=1,\n contact_id=100\n)\n\nprint(labels)\n# ['vip', 'enterprise']\n"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
@@ -3046,6 +3095,13 @@
|
||||
"userApiKey": []
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Add labels to contact",
|
||||
"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.contacts.labels.add(\n account_id=1,\n contact_id=100,\n labels=[\"vip\", \"enterprise\"]\n)\n\nprint(labels)\n# ['vip', 'enterprise']\n"
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
@@ -3138,6 +3194,18 @@
|
||||
"$ref": "#/components/parameters/page"
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Search by email",
|
||||
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\ncontacts = client.contacts.search(\n account_id=1,\n query=\"john@example.com\"\n)\n\nfor contact in contacts:\n print(contact.name, contact.email)\n"
|
||||
},
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Search by name",
|
||||
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\ncontacts = client.contacts.search(account_id=1, query=\"John Doe\")\n"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
@@ -3175,6 +3243,13 @@
|
||||
"userApiKey": []
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Filter contacts",
|
||||
"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 search to find contacts by name, email, or phone\ncontacts = client.contacts.search(\n account_id=1,\n query=\"example.com\"\n)\n"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"$ref": "#/components/parameters/account_id"
|
||||
|
||||
@@ -1217,6 +1217,13 @@
|
||||
"$ref": "#/components/parameters/page"
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "List all contacts",
|
||||
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\ncontacts = client.contacts.list(account_id=1, page=1)\n\nfor contact in contacts:\n print(contact.name, contact.email)\n"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
@@ -1257,6 +1264,13 @@
|
||||
"$ref": "#/components/parameters/account_id"
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Create a contact",
|
||||
"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.contacts.create(\n account_id=1,\n inbox_id=5,\n name=\"John Doe\",\n email=\"john@example.com\",\n phone_number=\"+1234567890\"\n)\n\nprint(result.contact.id, result.contact_inbox.source_id)\n"
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
@@ -1318,6 +1332,13 @@
|
||||
}
|
||||
],
|
||||
"description": "Get a contact belonging to the account using ID",
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Get contact details",
|
||||
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\ncontact = client.contacts.get(account_id=1, contact_id=100)\n\nprint(contact.name, contact.email, contact.phone_number)\n"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
@@ -1363,6 +1384,13 @@
|
||||
}
|
||||
],
|
||||
"description": "Update a contact belonging to the account using ID",
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Update a contact",
|
||||
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\ncontact = client.contacts.update(\n account_id=1,\n contact_id=100,\n name=\"Jane Doe\",\n email=\"jane@example.com\",\n custom_attributes={\"plan\": \"premium\"}\n)\n\nprint(contact.id, contact.name)\n"
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
@@ -1418,6 +1446,13 @@
|
||||
}
|
||||
],
|
||||
"description": "Delete a contact belonging to the account using ID",
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Delete a contact",
|
||||
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\nclient.contacts.delete(account_id=1, contact_id=100)\n"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success"
|
||||
@@ -1483,6 +1518,13 @@
|
||||
"userApiKey": []
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Get contact 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.contacts.conversations(\n account_id=1,\n contact_id=100\n)\n\nfor conversation in conversations:\n print(conversation.id, conversation.status)\n"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
@@ -1544,6 +1586,13 @@
|
||||
"userApiKey": []
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "List contact 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.contacts.labels.list(\n account_id=1,\n contact_id=100\n)\n\nprint(labels)\n# ['vip', 'enterprise']\n"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
@@ -1589,6 +1638,13 @@
|
||||
"userApiKey": []
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Add labels to contact",
|
||||
"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.contacts.labels.add(\n account_id=1,\n contact_id=100,\n labels=[\"vip\", \"enterprise\"]\n)\n\nprint(labels)\n# ['vip', 'enterprise']\n"
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
@@ -1681,6 +1737,18 @@
|
||||
"$ref": "#/components/parameters/page"
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Search by email",
|
||||
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\ncontacts = client.contacts.search(\n account_id=1,\n query=\"john@example.com\"\n)\n\nfor contact in contacts:\n print(contact.name, contact.email)\n"
|
||||
},
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Search by name",
|
||||
"source": "from chatwoot import ChatwootClient\n\nclient = ChatwootClient(\n base_url=\"https://app.chatwoot.com\",\n api_token=\"your-api-token\"\n)\n\ncontacts = client.contacts.search(account_id=1, query=\"John Doe\")\n"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
@@ -1718,6 +1786,13 @@
|
||||
"userApiKey": []
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "python",
|
||||
"label": "Filter contacts",
|
||||
"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 search to find contacts by name, email, or phone\ncontacts = client.contacts.search(\n account_id=1,\n query=\"example.com\"\n)\n"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"$ref": "#/components/parameters/account_id"
|
||||
|
||||
Reference in New Issue
Block a user