> ## Documentation Index
> Fetch the complete documentation index at: https://www.text.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Methods

## acceptGreeting

You can use this method to inform that a customer has seen a greeting. Based on that, the Reports section displays only the greetings seen by Customers instead of all the sent greetings. If a customer started a chat from a greeting but you didn't execute `acceptGreeting` method, the greeting counts as seen in Reports anyway.

As arguments to this method you should use `uniqueId` & `greetingId` received in the [`incoming_greeting`](#incoming_greeting) or [`connected`](#connected) event.

```js theme={null}
customerSDK
  .acceptGreeting({
    greetingId: 7,
    uniqueId: "Q10X0W041P",
  })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   |
| ---------- | ------ |
| greetingId | number |
| uniqueId   | string |

### Errors

* `GREETING_NOT_FOUND` - a given `uniqueId` couldn't be found on the server

## cancelGreeting

Cancels a greeting (an invitation to the chat). For example, Customers could cancel greetings by clicking close icon on the displayed greeting.

```js theme={null}
customerSDK
  .cancelGreeting({
    uniqueId: "Q10X0W041P",
  })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   |
| ---------- | ------ |
| uniqueId   | string |

### Errors

* `GREETING_NOT_FOUND` - given `uniqueId` could not be found on the server

## cancelRate

Cancels rate-related thread properties.

```js theme={null}
customerSDK
  .cancelRate({
    chatId: "ON0X0R0L67",
    properties: ["score", "comment"],
  })
  .then((response) => {
    console.log(response);
  })
  .catch(() => {
    console.log(error);
  });
```

### Errors

* `MISSING_CHAT_THREAD` - the targeted chat is empty and has no threads.

## connect

Starts the connection process to our servers. It is needed when:

* The `autoConnect: false` argument has been passed to the `init` method.

```js theme={null}
const customerSDK = CustomerSDK.init({
  organizationId: ORGANIZATION_ID,
  clientId: CLIENT_ID,
  autoConnect: false,
});

/* later in the code... */

customerSDK.connect();
```

* You get disconnected for a reason that suspends reconnection attempts (e.g. [`inactivity_timeout`](#inactivity_timeout)).

```js theme={null}
customerSDK.on("disconnected", ({ reason }) => {
  if (reason === "inactivity_timeout") {
    customerSDK.connect();
  }
});
```

## deactivateChat

```js theme={null}
customerSDK
  .deactivateChat({ id: "ON0X0R0L67" })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   | description                                              |
| ---------- | ------ | -------------------------------------------------------- |
| id         | string | The ID of the chat in which the thread should be closed. |

Returned value:

| properties | type    |
| ---------- | ------- |
| success    | boolean |

## deleteChatProperties

Deletes given chat properties.

```js theme={null}
customerSDK
  .deleteChatProperties({
    id: "ON0X0R0L67",
    properties: {
      property_namespace: ["sample"],
    },
  })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   | description                                         |
| ---------- | ------ | --------------------------------------------------- |
| id         | string | ID of the chat whose properties you want to delete. |
| properties | object | The chat properties to delete.                      |

Returned value:

| properties | type    |
| ---------- | ------- |
| success    | boolean |

## deleteEventProperties

Deletes given event properties.

```js theme={null}
customerSDK
  .deleteEventProperties({
    chatId: "ON0X0R0L67",
    threadId: "OS0C0W0Z1B",
    eventId: "Q50W0A0P0Y",
    properties: {
      property_namespace: ["sample"],
    },
  })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   | description                                           |
| ---------- | ------ | ----------------------------------------------------- |
| chatId     | string | ID of the chat whose properties you want to delete.   |
| threadId   | string | ID of the thread whose properties you want to delete. |
| eventId    | string | ID of the event whose properties you want to delete.  |
| properties | object | The properties to delete.                             |

Returned value:

| properties | type    |
| ---------- | ------- |
| success    | boolean |

## deleteThreadProperties

Deletes given chat thread properties.

```js theme={null}
customerSDK
  .deleteThreadProperties({
    chatId: "ON0X0R0L67",
    threadId: "OS0C0W0Z1B",
    properties: {
      property_namespace: ["sample"],
    },
  })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   | description                                           |
| ---------- | ------ | ----------------------------------------------------- |
| chatId     | string | ID of the chat whose properties you want to delete.   |
| threadId   | string | ID of the thread whose properties you want to delete. |
| properties | object | The properties to delete.                             |

Returned value:

| properties | type    |
| ---------- | ------- |
| success    | boolean |

## destroy

Clears any stored resources, removes all listeners, and disconnects from the network.
After using this method, you won't be able to use the destroyed Customer SDK instance.

```js theme={null}
customerSDK.destroy();
```

## disconnect

Disconnects from the server.

```js theme={null}
customerSDK.disconnect();
```

## getChat

Returns the chat data about the requested chat ID together with a single thread's data. If the method is called with the `threadId` parameter, then this particular thread is being returned. If no `threadId` is given, the latest thread is automatically returned.

```js theme={null}
customerSDK
  .getChat({
    chatId: "ON0X0R0L67",
  })
  .then((chat) => {
    const { id, access, users, properties, thread } = chat;
    console.log({ id, access, users, properties, thread });
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   | description              |
| ---------- | ------ | ------------------------ |
| chatId     | string | The chat ID.             |
| threadId   | string | Optional. The thread ID. |

Returned value:

| properties | type      | description                            |
| ---------- | --------- | -------------------------------------- |
| id         | string    | The chat ID.                           |
| access     | object    | The initial chat access configuration. |
| users      | object\[] | The users participating in the chat.   |
| properties | object    | The chat properties.                   |
| thread     | object    | The thread object.                     |

## getChatHistory

Helps loading in historical thread events.

First, call `getChatHistory` to access the `history` object of a particular chat.
The returned `history` object has only one method, `next`, which gives you a `Promise` with a `{ done, value }` object.

* `done` - indicates if there is anything more to load
* `value` - an object with an array of threads, each containing an array of its events

Then, you can keep calling `history.next()` multiple times to load previous historical events. They're going to be grouped into threads and might require merging with already loaded events.
This is useful for implementing an infinite scroll or otherwise showing your customer's archival chats.
Keep in mind, though, that you generally shouldn't call `next` while the history is loading - we queue those requests, so the previous one must resolve before we proceed with the next one.

The structure such as our `history` object is called an **async iterator**.

```js theme={null}
let wholeChatHistoryLoaded = false;

const history = customerSDK.getChatHistory({ chatId: "OU0V0P0OWT" });

history.next().then((result) => {
  if (result.done) {
    wholeChatHistoryLoaded = true;
  }

  const { threads } = result.value;

  const events = threads
    .map((thread) => thread.events || [])
    .reduce((acc, current) => acc.concat(current), []);

  console.log(events);
});
```

Parameters:

| parameters | type   | description                                 |
| ---------- | ------ | ------------------------------------------- |
| chatId     | string | The ID of the chat to retrieve history for. |

## getCustomer

Returns the info about the customer requesting it.

```js theme={null}
customerSDK
  .getCustomer()
  .then((customer) => {
    console.log(customer);
  })
  .catch((error) => {
    console.log(error);
  });
```

Returned value:

| properties                        | type       | description                                         |
| --------------------------------- | ---------- | --------------------------------------------------- |
| type                              | 'customer' |                                                     |
| id                                | string     |                                                     |
| name                              | string     | The customer's name. Returned only if set.          |
| email                             | string     | The customer's email address. Returned only if set. |
| avatar                            | string     | The customer's avatar URL. Returned only if set.    |
| sessionFields                     | object     |                                                     |
| statistics                        | object     |                                                     |
| statistics.chatsCount             | number     |                                                     |
| statistics.threadsCount           | number     |                                                     |
| statistics.visitsCount            | number     |                                                     |
| statistics.pageViewsCount         | number     |                                                     |
| statistics.greetingsShownCount    | number     |                                                     |
| statistics.greetingsAcceptedCount | number     |                                                     |

## getForm

Allows you to fetch a form template for a given group and form type.

```js theme={null}
customerSDK
  .getForm({
    groupId: 0,
    type: "prechat",
  })
  .then((response) => {
    if (response.enabled) {
      // prechat form is enabled for this group in the configurator
      console.log(response.form);
    }
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type                              |
| ---------- | --------------------------------- |
| groupId    | number                            |
| type       | 'prechat', 'postchat' or 'ticket' |

Returned value:

| properties  | type      | description                                                 |
| ----------- | --------- | ----------------------------------------------------------- |
| enabled     | boolean   |                                                             |
| form        | object    | The form template. Available only when the form is enabled. |
| form.id     | string    |                                                             |
| form.fields | object\[] |                                                             |

## getUrlInfo

It returns the info on a given URL.

```js theme={null}
customerSDK
  .getUrlInfo({ url: "https://www.livechat.com" })
  .then((urlDetails) => {
    if (urlDetails.title) {
      console.log(`The title of requested URL is: ${urlDetails.title}`);
    }
    if (urlDetails.description) {
      console.log(
        `The description of requested URL is: ${urlDetails.description}`,
      );
    }
    if (urlDetails.imageUrl) {
      console.log(
        `The preview image of requested URL is available under: ${urlDetails.imageUrl}`,
      );
      if (urlDetails.imageWidth && urlDetails.imageHeight) {
        console.log(`Its width is: ${urlDetails.imageWidth}`);
        console.log(`Its height is: ${urlDetails.imageHeight}`);
      }
    }
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   |
| ---------- | ------ |
| url        | string |

Returned value:

| properties  | type   | description |
| ----------- | ------ | ----------- |
| url         | string |             |
| title       | string | Optional    |
| description | string | Optional    |
| imageUrl    | string | Optional    |
| imageWidth  | number | Optional    |
| imageHeight | number | Optional    |

## off

Unsubscribes from emitted events, which are described [here](#events).

## on

Subscribes to emitted events, which are described [here](#events).

## once

Subscribes to emitted events, which are described [here](#events). Unsubscribes immediately after the callback gets called.

## listChats

It returns summaries of the chats a customer participated in.

```js theme={null}
customerSDK
  .listChats({
    pageId: "MTU5MTEwMTUxNDM5NTk5OTpkZXNj",
    limit: 10,
  })
  .then(({ chatsSummary, totalChats }) => {
    console.log(chatsSummary);
    console.log(totalChats);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   | description                                                       |
| ---------- | ------ | ----------------------------------------------------------------- |
| pageId     | string | Optional. The cursor returned from the previous `listChats` call. |
| limit      | number | Optional. The maximum number of results to return.                |

Returned value:

| properties                         | type      | description                                |
| ---------------------------------- | --------- | ------------------------------------------ |
| chatsSummary                       | object\[] |                                            |
| chatsSummary\[].id                 | string    | The chat ID.                               |
| chatsSummary\[].active             | boolean   |                                            |
| chatsSummary\[].users              | object\[] | The users participating in the chat.       |
| chatsSummary\[].lastEvent          | object    | The last event in the chat.                |
| chatsSummary\[].lastEventsPerType  | object    | A map of event types to event objects.     |
| chatsSummary\[].lastSeenTimestamps | object    | A map of user IDs to last-seen timestamps. |
| chatsSummary\[].lastThread         | string    | The ID of the last thread.                 |
| totalChats                         | number    |                                            |

## listGroupStatuses

Returns availability statuses of the requested groups.

```js theme={null}
customerSDK
  .listGroupStatuses({
    groupIds: [3, 10],
  })
  .then((statusMap) => {
    console.log(`Status of the group 3: ${statusMap[3]}`);
    console.log(`Status of the group 10: ${statusMap[10]}`);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type      | description                                                                                |
| ---------- | --------- | ------------------------------------------------------------------------------------------ |
| groupsIds  | number\[] | Optional. The IDs of the groups to check. If omitted, statuses of all groups are returned. |

Returned value:

| properties | type   | description                                  |
| ---------- | ------ | -------------------------------------------- |
| statusMap  | object | A map of group IDs to availability statuses. |

## listThreads

Returns a list of thread objects together with the previous and next page ID cursors that can be used to load more threads.
If you want to load consecutive events, consider using [`getChatHistory`](#getchathistory).

```js theme={null}
customerSDK
  .listThreads({
    chatId: "ON0X0R0L67",
  })
  .then((response) => {
    console.log(response.threads);
    console.log(response.previousPageId);
    console.log(response.nextPageId);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters     | type            | description                                                         |
| -------------- | --------------- | ------------------------------------------------------------------- |
| chatId         | string          |                                                                     |
| pageId         | string          | Optional. The cursor returned from the previous `listThreads` call. |
| sortOrder      | 'desc' \| 'asc' | Optional. The sort order of the results.                            |
| limit          | number          | Optional. Cannot be used together with `minEventsCount`.            |
| minEventsCount | number          | Optional. Cannot be used together with `limit`.                     |

Returned value:

| properties                | type      | description                                                         |
| ------------------------- | --------- | ------------------------------------------------------------------- |
| threads                   | object\[] |                                                                     |
| threads\[].id             | string    | The thread ID.                                                      |
| threads\[].chatId         | string    | The chat ID.                                                        |
| threads\[].active         | boolean   | If set to `true`: the thread is currently active.                   |
| threads\[].createdAt      | string    | The thread creation date in RFC 3339 format.                        |
| threads\[].userIds        | string\[] | The IDs of users in the thread.                                     |
| threads\[].events         | object\[] | The events in the thread.                                           |
| threads\[].properties     | object    | The thread properties.                                              |
| threads\[].access         | object    |                                                                     |
| threads\[].queue          | object    | Optional. The queue information for the thread.                     |
| threads\[].queue.position | number    | The current position in the queue.                                  |
| threads\[].queue.waitTime | number    | The estimated waiting time for an agent to be assigned, in seconds. |
| threads\[].queue.queuedAt | string    | The time at which the customer was queued, in RFC 3339 format.      |
| previousPageId            | string    |                                                                     |
| nextPageId                | string    |                                                                     |

## markEventsAsSeen

Marks events as seen by the current customer up to the given date.

```js theme={null}
customerSDK
  .markEventsAsSeen({
    chatId: "ON0X0R0L67",
    seenUpTo: "2017-10-12T15:19:21.010200Z",
  })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   | description                                                                              |
| ---------- | ------ | ---------------------------------------------------------------------------------------- |
| chatId     | string | ID of the chat in which you want to mark events as seen.                                 |
| seenUpTo   | string | RFC 3339 date-time format; you should use the event's `createdAt` value as the argument. |

Returned value:

| properties | type    |
| ---------- | ------- |
| success    | boolean |

## rateChat

Sends chat rating and a comment for the most recent chat thread.

```js theme={null}
customerSDK
  .rateChat({
    chatId: "ON0X0R0L67",
    rating: {
      score: 1,
      comment: "Agent helped me a lot!",
    },
  })
  .then(() => {
    console.log("Rating has been set");
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters     | type   | description                                  |
| -------------- | ------ | -------------------------------------------- |
| chatId         |        | The ID of the chat to rate.                  |
| rating         |        |                                              |
| rating.score   | 0 or 1 | The rating value: `0` for bad, `1` for good. |
| rating.comment | string | Optional. A comment on the rating.           |

Returned value:

| properties | type    |
| ---------- | ------- |
| success    | boolean |

### Errors

* `MISSING_CHAT_THREAD` - the targeted chat cannot be rated because it has no threads.

## getPredictedAgent

```js theme={null}
customerSDK
  .getPredictedAgent({
    groupId: 0,
  })
  .then((agent) => {
    console.log(agent);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   | description                                                   |
| ---------- | ------ | ------------------------------------------------------------- |
| groupId    | number | Optional. The ID of the group to get the predicted agent for. |

Returned value:

| properties     | type    | description                                                                |
| -------------- | ------- | -------------------------------------------------------------------------- |
| agent          | object  |                                                                            |
| agent.id       | string  |                                                                            |
| agent.name     | string  |                                                                            |
| agent.jobTitle | string  |                                                                            |
| agent.type     | 'agent' |                                                                            |
| agent.isBot    | boolean | If set to `true`: the predicted agent is a bot.                            |
| queue          | boolean | If set to `true`: the current group has reached its concurrent chat limit. |

### Errors

* `GROUP_OFFLINE` - the requested group is offline, and it was not possible to return a predicted agent for it.
* `GROUP_UNAVAILABLE` - thrown when manual routing is enabled for the group and a predicted agent is requested for it. If you call `startChat` or `resumeChat` accordingly, you'll end up in the queue.

## resumeChat

Resumes an archived chat.

```js theme={null}
customerSDK
  .resumeChat({
    chat: {
      id: "OU0V0P0OWT",
      thread: {
        events: [],
      },
    },
  })
  .then((chat) => {
    console.log(chat);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters                  | type     | description                                                               |
| --------------------------- | -------- | ------------------------------------------------------------------------- |
| data.active                 | boolean  | Optional. If set to `false`: the thread will be immediately inactive.     |
| data.continuous             | boolean  | Optional                                                                  |
| data.chat.id                | string   |                                                                           |
| data.chat.access            | Access   | Optional. The chat access to set.                                         |
| data.chat.properties        | object   | Optional. The chat properties.                                            |
| data.chat.thread.events     | Event\[] | Optional. Initial events that will immediately become part of the thread. |
| data.chat.thread.properties | object   | Optional. The thread properties.                                          |

### Errors

* `CHAT_ALREADY_ACTIVE` - the chat is already active and you can't activate it again.
* `GROUPS_OFFLINE` - a group in the targeted chat is offline. It can happen for licenses without continuous chats enabled.

## sendEvent

Sends a provided object as an event with a specified type.

```js theme={null}
const event = {
  type: "message",
  // ... other properties specific for the event's type
};

customerSDK
  .sendEvent({
    chatId: "ON0X0R0L67",
    event,
  })
  .then((event) => {
    console.log(event);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters         | type    | description                                                                                                                                                     |
| ------------------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| chatId             | string  | The ID of the destination chat.                                                                                                                                 |
| event              |         |                                                                                                                                                                 |
| event.type         | string  | Type of the event; accepts only **message, file, filled\_form, system\_message,** and **custom** [event types](/api/customer-chat/v3.6/data-structures#events). |
| attachToLastThread | boolean | Optional. If set to `true`: the event is attached to the last thread instead of creating a new one.                                                             |

## sendRichMessagePostback

Sends information to the server about a user's interaction with a rich message button.

```js theme={null}
customerSDK
  .sendRichMessagePostback({
    chatId: "ON0X0R0L67",
    threadId: "OS0C0W0Z1B",
    eventId: "OS0C0W0Z1B01",
    postback: {
      id: "OS0C0W0Z1B01002",
      toggled: true,
    },
  })
  .then(() => {
    console.log("success");
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters       | type    | default | description                                                  |
| ---------------- | ------- | ------- | ------------------------------------------------------------ |
| chatId           | string  |         | The chat ID of the postback.                                 |
| threadId         | string  |         | The thread ID of the postback.                               |
| eventId          | string  |         | The event ID of the postback.                                |
| postback         |         |         |                                                              |
| postback.id      | string  |         | The postback button ID.                                      |
| postback.toggled | boolean | true    | If set to `true`: the postback button is in a toggled state. |

## setCustomerSessionFields

Sends the request to set customer's session fields. They are available for the duration of the session.

```js theme={null}
customerSDK.setCustomerSessionFields({
  sessionFields: {
    foo: "bar",
    test: "qwerty",
  },
});
```

Parameters:

| parameters    | type   |
| ------------- | ------ |
| sessionFields | object |

## setSneakPeek

You can use it to update the sneak peek in the Agent App.
It is sent to the server only if the target chat is active. This method doesn't return a promise.

```js theme={null}
customerSDK.setSneakPeek({
  chatId: "ON0X0R0L67",
  sneakPeekText: "what is the price for your ",
});
```

Parameters:

| parameters    | type   | description                                      |
| ------------- | ------ | ------------------------------------------------ |
| chatId        | string | The target chat ID.                              |
| sneakPeekText | string | The message preview text broadcast to the agent. |

## startChat

Starts a new chat. For one customer, you can only start one chat.
In order to activate a previously started chat, use [`resumeChat`](#resumeChat).

```js theme={null}
customerSDK
  .startChat({
    chat: {
      thread: {
        events: [],
      },
    },
  })
  .then((chat) => {
    console.log(chat);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters             | type     | description                                                                                  |
| ---------------------- | -------- | -------------------------------------------------------------------------------------------- |
| active                 | boolean  | Optional. If set to `false`: the thread will be immediately inactive.                        |
| continuous             | boolean  | Optional. If set to `true`: starts the chat as continuous — an online group is not required. |
| chat.access            | access   | Optional. The chat access to set.                                                            |
| chat.properties        | object   | Optional. The chat properties.                                                               |
| chat.thread.events     | event\[] | Optional. Initial events that will immediately become part of the thread.                    |
| chat.thread.properties | object   | Optional. The thread properties.                                                             |

### Errors

* `CHAT_LIMIT_REACHED` - the maximum limit of chats per customer has been reached, and it's not possible to start a new one. You should activate one of the existing chats. The limit is 1.
* `GROUPS_OFFLINE` - a group in the target chat is offline. It can happen for licenses, which don't allow Customers to chat during their unavailability.

## updateChatProperties

```js theme={null}
const properties = {
  property_namespace: {
    sample: "property",
  },
};
customerSDK
  .updateChatProperties({ id: "ON0X0R0L67", properties })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   | description                                                              |
| ---------- | ------ | ------------------------------------------------------------------------ |
| id         | string | ID of the chat whose properties you want to update.                      |
| properties | object | [Default properties docs](/api/events-and-properties/default-properties) |

## updateCustomer

Updates the specified customer properties and fields.

```js theme={null}
const properties = {
  name: "John Doe",
  email: "john.doe@example.com",
  sessionFields: {
    custom_property: "BasketValue=10usd",
    any_key_is_ok: "sample custom field",
  },
};
customerSDK.updateCustomer(properties);
```

Parameters:

| parameters               | type   | description                                         |
| ------------------------ | ------ | --------------------------------------------------- |
| properties               |        |                                                     |
| properties.name          | string | Optional. The customer's name.                      |
| properties.email         | string | Optional. The customer's email address.             |
| properties.sessionFields | object | Optional. Custom session fields with string values. |

### Errors

* `CUSTOMER_SESSION_FIELDS_LIMIT_REACHED` - total amount of session fields would have been exceeded after requested update

## updateCustomerPage

Updates information about the customer page using the provided page object.

```js theme={null}
const page = {
  url: "https://platform.text.com/",
  title: "Text for Developers",
};
customerSDK.updateCustomerPage(page);
```

Parameters:

| parameters | type   |
| ---------- | ------ |
| page       |        |
| page.url   | string |
| page.title | string |

## updateEventProperties

Updates given properties of an event.

```js theme={null}
const properties = {
  property_namespace: {
    sample: "property",
  },
};
customerSDK
  .updateEventProperties({
    chatId: "ON0X0R0L67",
    threadId: "OS0C0W0Z1B",
    eventId: "Q50W0A0P0Y",
    properties,
  })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   | description                                                              |
| ---------- | ------ | ------------------------------------------------------------------------ |
| chatId     | string | ID of the chat whose properties you want to update.                      |
| threadId   | string | ID of the thread whose properties you want to update.                    |
| eventId    | string | ID of the event whose properties you want to update.                     |
| properties | object | [Default properties docs](/api/events-and-properties/default-properties) |

## updateThreadProperties

```js theme={null}
const properties = {
  property_namespace: {
    sample: "property",
  },
};
customerSDK
  .updateThreadProperties({
    chatId: "ON0X0R0L67",
    threadId: "OS0C0W0Z1B",
    properties,
  })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type   | description                                                               |
| ---------- | ------ | ------------------------------------------------------------------------- |
| chatId     | string | ID of the chat whose properties you want to update.                       |
| threadId   | string | ID of the thread whose properties you want to update.                     |
| properties | object | [Default properties docs](/api/events-and-properties/default-properties). |

## uploadFile

Returns both a `promise` and a `cancel`. You can use `cancel` to abort a file upload.
It also lets you pass the `onProgress` callback function. Keep in mind that the maximum accepted file size is 10 MB.

It returns a URL that expires after 24 hours unless the URL is used in [`sendEvent`](#sendevent)

```js theme={null}
const { promise, cancel } = customerSDK.uploadFile({
  file,
  onProgress: (progress) => console.log(`upload progress: ${progress}`),
});

document.getElementById("cancel-upload").onclick = () => {
  cancel();
};

promise
  .then((response) => {
    console.log(response.url);
  })
  .catch((error) => {
    console.log(error);
  });
```

Parameters:

| parameters | type     | description                                   |
| ---------- | -------- | --------------------------------------------- |
| file       | blob     |                                               |
| onProgress | function | A callback that receives the upload progress. |

onProgress parameters:

| parameters | type   | min | max |
| ---------- | ------ | --- | --- |
| progress   | number | 0   | 1   |

Returned value:

| properties | type   |
| ---------- | ------ |
| url        | string |

In React Native, instead of passing a blob you need to pass an object of
[such a shape](https://github.com/facebook/react-native/blob/56fef9b6225ffc1ba87f784660eebe842866c57d/Libraries/Network/FormData.js#L34-L38):

```js theme={null}
const file = {
  uri: uriFromCameraRoll,
  type: "image/jpeg", // optional
  name: "photo.jpg", // optional
};
```
