# Sendbird
URL: https://docs.awellhealth.com/docs/marketplace/sendbird

> For the complete documentation index, see [llms.txt](https://docs.awellhealth.com/llms.txt).



<img src="/marketplace/sendbird.jpg" width="48" height="48" />

Sendbird is a cloud-based chat and messaging platform.

Category: Communication. Adds 13 actions to a care flow.

## What to configure [#what-to-configure]

Set these once, on the extension in Awell Studio. An action fails at run time if a
required setting is missing.

| Setting        | Required | Notes                                                                                                                                                               |
| -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Application ID | Yes      | Visit [https://dashboard.sendbird.com/](https://dashboard.sendbird.com/) to retrieve Application ID for the app of your choosing Stored as a secret.                |
| Chat API token | Yes      | Visit Application's settings and go to Settings > Application > General > API tokens to retrieve either Master API token or Secondary API token Stored as a secret. |
| Desk API token | Yes      | Visit Application's settings and go to Settings > Desk > Credentials to retrieve Desk API token Stored as a secret.                                                 |

## Actions [#actions]

Sendbird adds these 13 actions to a care flow. Add one to a step, then fill in its inputs.

### Activate user [#activate-user]

Activates a user using the Chat API.

This action can be previewed in Studio before you publish.

| Input   | Type     | Required | Description                       |
| ------- | -------- | -------- | --------------------------------- |
| User ID | `string` | Yes      | The user's unique ID in Sendbird. |

Activates a user, using the "Update user" endpoint, in the Chat API. The user is activated by setting `is_active` to true.

### Create customer [#create-customer]

Creates a customer using the Desk API.

This action can be previewed in Studio before you publish.

| Input       | Type     | Required | Description                                                                                      |
| ----------- | -------- | -------- | ------------------------------------------------------------------------------------------------ |
| Sendbird ID | `string` | Yes      | The Sendbird ID of a customer which must be an ID that already exists in Sendbird (eg: user id). |

Returns:

| Data point   | Type     |
| ------------ | -------- |
| `customerId` | `number` |

Creates a customer using the Desk API. Only the `sendbirdId` is passed and it must be an ID that already exists in Sendbird's Chat platform (eg: the `userId` of an existing user). The `customerId` of the newly created customer is stored as data point.

To add custom fields to your customer, use the [Update custom fields action](#update-customers-custom-fields).

### Create ticket [#create-ticket]

Creates a ticket using the Desk API.

This action can be previewed in Studio before you publish.

| Input                | Type      | Required | Description                                                                                                                                                         |
| -------------------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Customer ID          | `numeric` | Yes      | A customer's unique ID.                                                                                                                                             |
| Channel name         | `string`  | Yes      | Specifies the title of a ticket, which will be the group channel name in Sendbird Chat platform as well. Maximum length is 100 characters.                          |
| Related channel URLs | `string`  | No       | A comma-separated string of group channel URLs for reference, where the corresponding customer belongs. Can have up to 3 group channel URLs.                        |
| Group key            | `string`  | No       | Specifies the unique key of a group for ticket assignment. The key can be a mix of lowercase letters, hyphens, underscores, or numbers.                             |
| Priority             | `string`  | No       | Specifies the priority of a ticket. Acceptable values are the following: "LOW", "MEDIUM", "HIGH", and "URGENT". Defaults to: "MEDIUM".                              |
| Custom fields        | `json`    | No       | A JSON object that can store up to twenty key-value items for additional customer information. The specified keys must be registered as a custom field in Sendbird. |

Returns:

| Data point           | Type     |
| -------------------- | -------- |
| `channelUrl`         | `string` |
| `relatedChannelUrls` | `string` |
| `ticketId`           | `number` |

Creates a ticket using the Desk API. The `ticketId` of the newly created ticket is stored as data point.

Please note that the Ticket won't be shown in the Sendbird console **until** the user for which that Ticket was created writes a message inside the Chat.

### Create user [#create-user]

Creates a user using the Chat API.

This action can be previewed in Studio before you publish.

| Input              | Type      | Required | Description                                                                                                                                                                                                                                                                                                                     |
| ------------------ | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| User ID            | `string`  | Yes      | Specify a unique ID for the user, maximum length is 80 characters. Don't use personally identifiable information (PII) for the ID.                                                                                                                                                                                              |
| Nickname           | `string`  | No       | The user's nickname. Maximum length is 80 characters. If left empty, we will use the patient's first and last name.                                                                                                                                                                                                             |
| Issue access token | `boolean` | No       | Determines whether to create an access token for the user.                                                                                                                                                                                                                                                                      |
| Profile URL        | `string`  | No       | The URL of the user's profile image.                                                                                                                                                                                                                                                                                            |
| Metadata           | `json`    | No       | Specifies a JSON object to store up to five key-value items for additional user information such as a phone number, an email address, or a long description of the user. The key must not have a comma (,) and its length is limited to 128 characters. The value must be a string and its length is limited to 190 characters. |

Returns:

| Data point | Type     |
| ---------- | -------- |
| `userId`   | `string` |

Creates a user in Sendbird using the Chat API. See [Update metadata](#update-metadata) to check metadata field details. The `userId` of the newly created user is then saved as a data point.

### Deactivate user [#deactivate-user]

Deactivates a user using the Chat API.

This action can be previewed in Studio before you publish.

| Input                                      | Type      | Required | Description                                                                                                        |
| ------------------------------------------ | --------- | -------- | ------------------------------------------------------------------------------------------------------------------ |
| User ID                                    | `string`  | Yes      | The user's unique ID in Sendbird.                                                                                  |
| Leave all group channels upon deactivation | `boolean` | No       | Determines whether the user leaves all joined group channels upon deactivation. Defaults to true if not specified. |

Deactivates a user, using the "Update user" endpoint, in the Chat API. Optionally, it can be set for the user to `Leave all group channels upon deactivation`.

The user is deactivated by setting `is_active` to false.

### Delete metadata [#delete-metadata]

Deletes metadata from a user using the Chat API.

This action can be previewed in Studio before you publish.

| Input        | Type     | Required | Description                                                                                      |
| ------------ | -------- | -------- | ------------------------------------------------------------------------------------------------ |
| User ID      | `string` | Yes      | The user's unique ID in Sendbird.                                                                |
| Metadata key | `string` | No       | The key of the metadata item to delete. If not specified, all items of the metadata are deleted. |

Deletes user metadata using the Chat API. Takes the key of a metadata item to be deleted (deletes one key at a time if a key is provided). If not specified, all items of the metadata are deleted.

### Delete user [#delete-user]

Deletes a user using the Chat API.

This action can be previewed in Studio before you publish.

| Input   | Type     | Required | Description                       |
| ------- | -------- | -------- | --------------------------------- |
| User ID | `string` | Yes      | The user's unique ID in Sendbird. |

Deletes a user in Sendbird using the Chat API.

### Get customer [#get-customer]

Retrieve information about a customer using the Desk API.

This action can be previewed in Studio before you publish.

| Input       | Type      | Required | Description                           |
| ----------- | --------- | -------- | ------------------------------------- |
| Customer ID | `numeric` | Yes      | The customer's unique ID in Sendbird. |

Returns:

| Data point     | Type     |
| -------------- | -------- |
| `channelType`  | `string` |
| `createdAt`    | `date`   |
| `customFields` | `string` |
| `displayName`  | `string` |
| `project`      | `number` |
| `sendbirdId`   | `string` |

Retrieves information on a specific customer using the Desk API. The following fields are saved as a data point:

* Sendbird ID
* Channel Type
* Project
* Created At
* Display Name
* Custom Fields (stored as string)

### Get user [#get-user]

Gets user using Chat API.

This action can be previewed in Studio before you publish.

| Input   | Type     | Required | Description                       |
| ------- | -------- | -------- | --------------------------------- |
| User ID | `string` | Yes      | The user's unique ID in Sendbird. |

Returns:

| Data point        | Type      |
| ----------------- | --------- |
| `accessToken`     | `string`  |
| `createdAt`       | `date`    |
| `hasEverLoggedIn` | `boolean` |
| `isActive`        | `boolean` |
| `lastSeenAt`      | `date`    |
| `metadata`        | `string`  |
| `nickname`        | `string`  |

Retrieve information about a user using the Chat API. The following fields are saved as a data point:

* Nickname
* Access token
* Is active
* Created at
* Last seen at
* Has ever logged in
* Metadata (stored as string)

### Update customer's custom fields [#update-customers-custom-fields]

Updates custom fields of a customer using the Desk API.

This action can be previewed in Studio before you publish.

| Input         | Type      | Required | Description                                                                                                                                                         |
| ------------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Customer ID   | `numeric` | Yes      | The customer's unique ID in Sendbird.                                                                                                                               |
| Custom fields | `json`    | Yes      | A JSON object that can store up to twenty key-value items for additional customer information. The specified keys must be registered as a custom field in Sendbird. |

Updates a customer's custom fields using the Desk API.

Custom fields is a JSON object that can store up to twenty key-value items for additional customer information such as a phone number, an email address, or a long description of the customer.

The specified keys must be registered as a custom field in Settings > Customer fields of your dashboard beforehand. The key must not have a comma (,) and its length is limited to 20 characters. The value's length is limited to 190 characters.

### Update metadata [#update-metadata]

Updates user metadata using Chat API.

This action can be previewed in Studio before you publish.

| Input    | Type     | Required | Description                                                                              |
| -------- | -------- | -------- | ---------------------------------------------------------------------------------------- |
| User ID  | `string` | Yes      | The user's unique ID in Sendbird.                                                        |
| Metadata | `json`   | Yes      | A JSON object that can store up to five key-value items for additional user information. |

Updates the user's metadata using the Chat API. Only updates existing or adds new fields to metadata. To delete some metedata fields, check the [Delete metadata action](#delete-metadata).

Metadata is a JSON object that can store up to five key-value items of additional user information such as a phone number, an email address, or a long description of the user. The key must not have a comma (,) and its length is limited to 128 characters. The value must be a string and its length is limited to 190 characters.

### Update ticket [#update-ticket]

Update a ticket using the Desk API.

This action can be previewed in Studio before you publish.

| Input                | Type      | Required | Description                                                                                                                                  |
| -------------------- | --------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| Ticket ID            | `numeric` | Yes      | A customer's unique ID.                                                                                                                      |
| Priority             | `string`  | No       | Specifies the priority of a ticket. Acceptable values are the following: "LOW", "MEDIUM", "HIGH", and "URGENT". Defaults to: "MEDIUM".       |
| Related channel URLs | `string`  | No       | A comma-separated string of group channel URLs for reference, where the corresponding customer belongs. Can have up to 3 group channel URLs. |

### Update user [#update-user]

Updates a user using the Chat API.

This action can be previewed in Studio before you publish.

| Input              | Type      | Required | Description                                                                               |
| ------------------ | --------- | -------- | ----------------------------------------------------------------------------------------- |
| User ID            | `string`  | Yes      | The user's unique ID in Sendbird.                                                         |
| Nickname           | `string`  | No       | The user's nickname. Maximum length is 80 characters.                                     |
| Issue access token | `boolean` | No       | Determines whether to revoke the existing access token and create a new one for the user. |
| Profile URL        | `string`  | No       | The URL of the user's profile image.                                                      |

Updates a user using the Chat API.

Please note that updating `metadata` of a user needs to be done with the [Update metadata action](#update-metadata).

## Setup and notes [#setup-and-notes]

Sendbird is a cloud-based chat and messaging platform that enables developers to integrate real-time messaging functionality into their applications.

Sendbird offers a range of features, including real-time chat, group chat, one-on-one messaging, push notifications, and file sharing. It supports various platforms and programming languages, making it flexible and accessible for developers to integrate with different applications.

### Extension settings [#extension-settings]

In order to set up this extension, you will need:

1. An **Application ID** - visit [https://dashboard.sendbird.com/](https://dashboard.sendbird.com/) to retrieve \*\*Application ID for the app of your choosing
2. A Chat API token\*\* - visit Application's settings and go to \*\*Settings > Application > General > API tokens to retrieve either Master API token or Secondary API token
3. A Desk API token\*\* - visit Application's settings and go to **Settings > Desk > Credentials** to retrieve Desk API token

## Changelog [#changelog]

### 2023-08-22 [#2023-08-22]

* add `relatedChannelUrls` field to `Create ticket` action

## Where this page comes from [#where-this-page-comes-from]

The settings, actions, inputs, outputs and webhooks above are generated from the
extension's own code, at `@awell-health/awell-extensions` v2.1.159. They match what the
platform actually does rather than a description of it.

Field-level detail also appears in Awell Studio when you configure the action.
Something wrong or missing? Email [support@awellhealth.com](mailto:support@awellhealth.com).
