Skip to content

Commit

Permalink
Update API reference from "consumers" to "contacts"
Browse files Browse the repository at this point in the history
  • Loading branch information
gharbat committed Jun 9, 2024
1 parent c0483aa commit 592f427
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 118 deletions.
42 changes: 0 additions & 42 deletions docs/api-reference/consumers/delete.mdx

This file was deleted.

36 changes: 0 additions & 36 deletions docs/api-reference/consumers/introduction.mdx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
---
title: "Create Consumer"
api: "POST https://api-v2.opencopilot.so/backend/consumers/:organization_id"
description: "Create a new consumer for a specific Organization ID."
title: "Create contact"
api: "POST https://api-v2.opencopilot.so/backend/contact/:organization_id"
description: "Create a new contact for a specific Organization ID."
---

<Warning>
This endpoint is protected by the same JWT that the user uses to call other APIs. The response will include data for the specified chatbot, along with other metadata information.
</Warning>


You can create a new consumer in your organization at Open by calling this endpoint, a consumer is a user that can interact with the chatbot, phone AI or email AI, a single consumer might have multiple conversations across different channels.
You can create a new contact in your organization at Open by calling this endpoint, a contact is a user that can interact with the chatbot, phone AI or email AI, a single contact might have multiple conversations across different channels.



<ParamField path="organization_id" type="string" required>
The unique identifier for the copilot (organization) you want to create a consumer for. This is a required parameter.
The unique identifier for the copilot (organization) you want to create a contact for. This is a required parameter.
</ParamField>

<ParamField body="copilot_id" type="string" default="uuid" required>
The unique identifier for the copilot_id (organization_id) you want to create a consumer for. This is a required parameter.
The unique identifier for the copilot_id (organization_id) you want to create a contact for. This is a required parameter.
</ParamField>

<ParamField body="email" type="string" default="string">
The email address of the consumer.
The email address of the contact.
</ParamField>

<ParamField body="name" type="string" default="string">
The name of the consumer.
The name of the contact.
</ParamField>

<ParamField body="phone_number" type="string" default="string">
The phone number of the consumer.
The phone number of the contact.
</ParamField>

<ParamField body="custom_data" type="object" default="{}">
An object containing any custom data you want to associate with the consumer.
An object containing any custom data you want to associate with the contact.
</ParamField>


<RequestExample>
```bash Example Request
curl --location 'https://api-v2.opencopilot.so/backend/consumers/:organization_id' \
curl --location 'https://api-v2.opencopilot.so/backend/contact/:organization_id' \
--header 'Authorization: Bearer TOKEN' \
--header 'Content-Type: application/json'
```
Expand All @@ -62,5 +62,5 @@ curl --location 'https://api-v2.opencopilot.so/backend/consumers/:organization_i
</ResponseExample>

<Info>
You can pass any custom data you want to associate with the consumer. This data will be returned in the response and can be used for any purpose you want, just make sure it's a valid JSON string object.
You can pass any custom data you want to associate with the contact. This data will be returned in the response and can be used for any purpose you want, just make sure it's a valid JSON string object.
</Info>
42 changes: 42 additions & 0 deletions docs/api-reference/contacts/delete.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: "Delete a contact"
api: "DELETE https://api-v2.opencopilot.so/backend/contact/:organization_id/:contact_id"
description: "Delete a contact for a specific Organization ID."
---

<Warning>
This endpoint is protected by the same JWT that the user uses to call other APIs. The response will include data for the specified chatbot, along with other metadata information.
</Warning>


You can delete a contact in your organization at Open by calling this endpoint, a contact is a user that can interact with the chatbot, phone AI or email AI, a single contact might have multiple conversations across different channels.

<Warning>
**Important**: Deleting a contact will **not** delete any conversations that the contact has had with the copilot. You will need to manually delete any conversations that you want to delete.
</Warning>


<ParamField path="organization_id" type="string" required>
The unique identifier for the copilot (organization) you want to create a contact for. This is a required parameter.
</ParamField>

<ParamField path="contact_id" type="string" required>
The unique identifier for the contact you want to delete. This is a required parameter.
</ParamField>


<RequestExample>
```bash Example Request
curl --location 'https://api-v2.opencopilot.so/backend/contact/:organization_id/:contact_id' \
--header 'Authorization: Bearer TOKEN' \
--header 'Content-Type: application/json'
```
</RequestExample>

<ResponseExample>
```json Response
{
"message": "contact deleted successfully"
}
```
</ResponseExample>
47 changes: 47 additions & 0 deletions docs/api-reference/contacts/introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: "Introduction to contact APIs"
description: "Some of the APIs in the contact APIs section allow you to create, list, and delete contacts."
icon: "user"
---


## What is a contact?

A contact is a user that can interact with the chatbot, phone AI or email AI, a single contact might have multiple conversations across different channels.


## How do I create a contact?

You can create a contact in your organization in two ways:

#### 1. Using the API
We have a simple public API that allows you to manage contacts in your organization, you can use the API to create, list, and delete contacts.

#### 2. Using the widget
Whenever you embed the copilot widget in your application, you can use the widget options to create a contact, read more about this option in the [widget documentation](/widget/embed#identifying-chat-users-consumers).


### Adding custom data to a contact

We support attaching a phone, email or a name to a contact, however, you can also add any custom data you want to associate with the contact. This data will be returned in the response and can be used for any purpose you want, just make sure it's a valid JSON string object.
The custom data is just a simple JSON object, you can add any key-value pairs you want to it, for example:

```jsx
const widgetOptions = {
initialMessage: "Hello! How can I help you?",
token: "your_copilot_token_goes_here",
user: {
name: "your_user_name",
email: "your_user_email",
avatar: "your_user_avatar_url",
phone: "your_user_phone",
customData: {
// any custom data you want to send to the copilot backend
"key1": "value1",
"balance": 100,
"age": 25,
}
},
```
You can use the API or the widget to add custom data to a contact.
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
---
title: "List Consumers"
api: "GET https://api-v2.opencopilot.so/backend/consumers/:organization_id"
description: "List all consumers for a specific Organization ID."
title: "List contacts"
api: "GET https://api-v2.opencopilot.so/backend/contact/:organization_id"
description: "List all contacts for a specific Organization ID."
---

<Warning>
This endpoint is protected by the same JWT that the user uses to call other APIs. The response will include data for the specified chatbot, along with other metadata information.
</Warning>


You can list all consumers in your organization at Open by calling this endpoint, a consumer is a user that can interact with the chatbot, phone AI or email AI, a single consumer might have multiple conversations across different channels.
You can list all contacts in your organization at Open by calling this endpoint, a contact is a user that can interact with the chatbot, phone AI or email AI, a single contact might have multiple conversations across different channels.


<ParamField path="organization_id" type="string" required>
The unique identifier for the copilot (organization) you want to list consumers for. This is a required parameter.
The unique identifier for the copilot (organization) you want to list contacts for. This is a required parameter.
</ParamField>


<RequestExample>
```bash Example Request
curl --location 'https://api-v2.opencopilot.so/backend/consumers/:organization_id' \
curl --location 'https://api-v2.opencopilot.so/backend/contact/:organization_id' \
--header 'Authorization: Bearer TOKEN' \
--header 'Content-Type: application/json'
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
---
title: "Update a Consumer"
api: "PUT https://api-v2.opencopilot.so/backend/consumers/:organization_id/:consumer_id"
description: "Update a consumer for a specific Organization ID."
title: "Update a contact"
api: "PUT https://api-v2.opencopilot.so/backend/contact/:organization_id/:contact_id"
description: "Update a contact for a specific Organization ID."
---

<Warning>
This endpoint is protected by the same JWT that the user uses to call other APIs. The response will include data for the specified chatbot, along with other metadata information.
</Warning>


You can update a consumer in your organization at Open by calling this endpoint, a consumer is a user that can interact with the chatbot, phone AI or email AI, a single consumer might have multiple conversations across different channels.
You can update a contact in your organization at Open by calling this endpoint, a contact is a user that can interact with the chatbot, phone AI or email AI, a single contact might have multiple conversations across different channels.

<ParamField path="organization_id" type="string" required>
The unique identifier for the copilot (organization) you want to list consumers for. This is a required parameter.
The unique identifier for the copilot (organization) you want to list contacts for. This is a required parameter.
</ParamField>

<ParamField path="consumer_id" type="string" required>
The unique identifier for the consumer you want to update. This is a required parameter.
<ParamField path="contact_id" type="string" required>
The unique identifier for the contact you want to update. This is a required parameter.
</ParamField>


<ParamField body="copilot_id" type="string" default="uuid" required>
The unique identifier for the copilot_id (organization_id) you want to create a consumer for. This is a required parameter.
The unique identifier for the copilot_id (organization_id) you want to create a contact for. This is a required parameter.
</ParamField>

<ParamField body="email" type="string" default="string">
The email address of the consumer.
The email address of the contact.
</ParamField>

<ParamField body="name" type="string" default="string">
The name of the consumer.
The name of the contact.
</ParamField>

<ParamField body="phone_number" type="string" default="string">
The phone number of the consumer.
The phone number of the contact.
</ParamField>

<ParamField body="custom_data" type="object" default="{}">
An object containing any custom data you want to associate with the consumer.
An object containing any custom data you want to associate with the contact.
</ParamField>



<RequestExample>
```bash Example Request
curl --location 'https://api-v2.opencopilot.so/backend/consumers/:organization_id' \
curl --location 'https://api-v2.opencopilot.so/backend/contact/:organization_id/:contact_id' \
--header 'Authorization: Bearer TOKEN' \
--header 'Content-Type: application/json'
```
Expand Down
12 changes: 6 additions & 6 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@
]
},
{
"group": "Consumers",
"group": "Contacts",
"pages": [
"api-reference/consumers/introduction",
"api-reference/consumers/create",
"api-reference/consumers/delete",
"api-reference/consumers/list",
"api-reference/consumers/update"
"api-reference/contacts/introduction",
"api-reference/contacts/create",
"api-reference/contacts/delete",
"api-reference/contacts/list",
"api-reference/contacts/update"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/widget/embed.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ The chat widget is highly customizable, here is a list of all the available opti
</ResponseField>


## Identifying chat users/consumers
## Identifying chat users/contacts

One of the helpful options in the chat widget is the ability to identify the user/consumer of the chat. This is useful if you want to track the usage of the chat widget and you want to know who is using it.
One of the helpful options in the chat widget is the ability to identify the user/contact of the chat. This is useful if you want to track the usage of the chat widget and you want to know who is using it.

To start identifying the user/consumer, you can pass the `user` object as and option to the chat widget, for example:
To start identifying the user/contact, you can pass the `user` object as and option to the chat widget, for example:

```jsx
const options = {
Expand Down

0 comments on commit 592f427

Please sign in to comment.