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

# TikTok Shop Customer Service as a data source

> Bring your TikTok Shop buyer conversations and messages to your Lakehouse.

TikTok Shop is TikTok's e-commerce marketplace. Buyers talk to the shop through the TikTok Shop chat, where the shop owner, customer service agents, auto-replies and the chatbot answer them. The TikTok Shop Customer Service API gives access to those conversations: every message with its sender and time, the order a buyer shared in the chat, the customer service sessions with their topic, first response time and satisfaction rating, and the shop's daily customer service performance.

Use it to build a customer service dashboard: response times, open conversations, satisfaction, and which orders generated questions.

> [!NOTE]
>
> This connector only reads conversations; it never sends or marks messages as read. Your shop's orders, products and finance data come from the [TikTok Shop](https://docs.nekt.com/sources/tiktok-shop.md) connector, which uses a separate authorization.

## Configuring TikTok Shop Customer Service as a Source

In the [Sources](https://app.nekt.ai/sources) tab, click on the "Add source" button located on the top right of your screen. Then, select the TikTok Shop Customer Service option from the list of connectors.

Click **Next** and you'll be prompted to add your access.

### 1. Add account access

You'll need to authorize Nekt to read your TikTok Shop customer service data. You don't need to register anything in the TikTok Shop Partner Center: Nekt has its own app there, and you simply grant it access to your shop.

Click on the **Authorization** button. You'll be redirected to TikTok Shop, where you need to be signed in to the Seller Center account that owns the shop you want to sync. There you'll:

1. Confirm the **shop** the authorization applies to, choose the **access duration** (we recommend *Unlimited*, so the connection doesn't stop working on a fixed date) and enter a **contact email**, then click **Confirm installation**.
2. Review the permissions Nekt is requesting (including **Customer Service**), accept the acknowledgement, and click **Authorize**.

You'll be redirected back to Nekt with the connection filled in automatically. If you ever need to reconnect the shop, use the **Refresh** button next to the field.

The following configurations are also available:

* **Initial sync date**: Conversations and messages with activity since this date are synced. Leave it empty to sync the whole conversation history.

The following advanced settings are also available:

* **Max requests per run**: (Default: `5000`) The most requests one run sends to TikTok Shop's conversation and message APIs, which allow 10,000 requests per day. Whatever doesn't fit is read by the next runs.
* **Lookback (days)**: (Default: `7`) How many days the **Sessions** and **Daily Performance** tables read again on each run, so ratings, first responses and conversions that arrive later are captured.

> [!NOTE]
>
> Don't have access to the TikTok Shop account yourself? Use the **Share link** option at the top of this step to send the authorization to whoever manages the shop: they complete it without needing a Nekt account.

Once you're done, click **Next**.

### 2. Select streams

Choose which data streams you want to sync. For faster extractions, select only the streams that are relevant to your analysis.

> Tip: The stream can be found more easily by typing its name.

Select the streams and click **Next**.

### 3. Configure data streams

Customize how you want your data to appear in your catalog. Select the desired layer where the data will be placed, a folder to organize it inside the layer, a name for each table (which will effectively contain the fetched data) and the type of sync.

* **Layer**: choose between the existing layers on your catalog. This is where you will find your new extracted tables as the extraction runs successfully.
* **Folder**: a folder can be created inside the selected layer to group all tables being created from this new data source.
* **Table name**: we suggest a name, but feel free to customize it. You have the option to add a **prefix** to all tables at once and make this process faster!
* **Sync Type**: you can choose between INCREMENTAL and FULL\_TABLE.
  * Incremental: every time the extraction happens, we'll get only the new data, which is good if, for example, you want to keep every record ever fetched.
  * Full table: every time the extraction happens, we'll get the current state of the data, which is good if, for example, you don't want to have deleted data in your catalog.

> [!WARNING]
>
> Keep **Messages** on INCREMENTAL and avoid running a **Full sync** (or an **Additional Full Sync**) on it. As a full table it must read every conversation's whole history in one run, which TikTok Shop's daily request limit rarely allows: when it can't, the run fails and the table stays as it was. A Full sync of a large shop replaces the table with the most recent conversations first, and the older ones come back over the next runs.

> [!WARNING]
>
> Keep **Sessions** on INCREMENTAL. TikTok Shop only returns the last 90 days of sessions, so a full table sync (or an **Additional Full Sync**) replaces the table with those 90 days and drops older sessions you already have.

Once you are done configuring, click **Next**.

### 4. Configure data source

Describe your data source for easy identification within your organization, not exceeding 140 characters.

To define your [Trigger](https://docs.nekt.com/runs/scheduling-and-triggers.md), consider how often you want data to be extracted from this source. This decision usually depends on how frequently you need the new table data updated (every day, once a week, or only at specific times).

Optionally, you can define some additional settings:

* Configure Delta Log Retention and determine for how long we should store old states of this table as it gets updated. Read more about this resource [here](https://docs.nekt.com/get-started/core-concepts/resource-control).
* Determine when to execute an **Additional [Full Sync](https://docs.nekt.com/get-started/core-concepts/types-of-sync#additional-full-sync)**. This will complement the incremental data extractions, ensuring that your data is completely synchronized with your source every once in a while.

Once you are ready, click **Next** to finalize the setup.

### 5. Check your new source

You can view your new source on the [Sources](https://app.nekt.ai/sources) page. If needed, manually trigger the source extraction by clicking on the arrow button. Once executed, your data will appear in your Catalog.

> [!WARNING]
>
> For you to be able to see it on your [Catalog](https://app.nekt.ai/catalog), you need at least one successful source run.

## Good to know

* **Request limit**: TikTok Shop allows 10,000 requests per day to its conversation and message APIs (sessions and performance are not affected). Every run reads the list of conversations (20 per request) and then the new messages of each conversation that had activity. If a run reaches the limit, or the **Max requests per run**, it keeps everything it already read and the next run continues from where it stopped.
* **First sync of a large shop**: the messages of the most recent conversations are loaded first. Older conversations are loaded over the next runs, and a warning in the run log says how many are left. Until then, older messages are missing from the table.
* **New messages in old conversations** are captured: a conversation is read again whenever it gets a new message, whatever its age. Messages edited or recalled later are only updated when their conversation gets a new message.
* **Conversations TikTok Shop fails to return** are skipped and retried on the next runs, and the run shows a failure until they are read. A conversation that was never loaded keeps being retried; one that only missed recent messages is given up after 3 runs, and the run log names it.
* **A conversation list that comes back empty or much shorter than before** is treated as a TikTok Shop error: the run fails and the tables stay as they were. If the shorter list comes back the same in 3 runs in a row, it is taken as the shop's real list and syncing resumes.
* **Permission**: every table needs the **Customer Service** permission on the authorization. If it is missing, the run says so and you need to authorize the shop again.
* **Personal data**: buyer nicknames and the content of the messages are synced; profile pictures are not.

# Streams and Fields

## Available streams

The table below lists every stream, its **slug** (the exact identifier to pass when creating the source via API) and a short description.

| Stream | Slug | Description |
| - | - | - |
| Conversations | `conversations` | Buyer conversations of the shop, with the buyer, the latest message and the open session. |
| Messages | `messages` | Every message of each conversation, with sender, time and linked order or product. |
| Sessions | `sessions` | Customer service sessions with topic, first response time and satisfaction rating (last 90 days). |
| Daily Performance | `daily_performance` | The shop's customer service metrics per day. |

## Fields by stream

> [accordion] Conversations
>
> One row per conversation between a buyer and the shop. The whole list is read on every run (full table). Conversations without activity since the **Initial sync date** are not included.
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `id` | String | Conversation ID |
> | `shop_id` | String | Shop the conversation belongs to |
> | `create_time` | Datetime | When the conversation was created (UTC) |
> | `last_activity_at` | Datetime | Time of the latest message (UTC), or the creation time when there is none |
> | `participant_count` | Integer | 2 (shop and buyer), or 3 when a customer service agent joined |
> | `can_send_message` | Boolean | Whether an agent can currently send messages in the conversation |
> | `unread_count` | Integer | Messages not yet read by the customer service agent |
> | `buyer_user_id` | String | Buyer's TikTok Shop user ID; the same value as the buyer ID on orders, so it links conversations to orders |
> | `buyer_nickname` | String | Buyer's TikTok nickname |
> | `buyer_platform` | String | Platform the buyer comes from (Indonesian shops only) |
> | `participants` | JSON | Participants: role (BUYER, SHOP, CUSTOMER\_SERVICE), user IDs and nickname |
> | `latest_message_id` | String | ID of the latest message |
> | `latest_message_type` | String | Type of the latest message |
> | `latest_message_sender_role` | String | Who sent the latest message (BUYER, SHOP, CUSTOMER\_SERVICE, SYSTEM, ROBOT) |
> | `latest_message_create_time` | Datetime | When the latest message was sent (UTC) |
> | `current_session_id` | String | Open customer service session, if any |
> | `current_session_phase` | String | AUTO\_REPLY (chatbot), QUEUED (waiting for an agent) or ASSIGNED (with an agent) |

> [accordion] Messages
>
> One row per message. Synced incrementally by `create_time`: each run reads the new messages of every conversation that had activity since the previous run.
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `id` | String | Message ID |
> | `conversation_id` | String | Conversation the message belongs to |
> | `shop_id` | String | Shop the conversation belongs to |
> | `create_time` | Datetime | When the message was sent (UTC), used as the incremental replication key |
> | `type` | String | TEXT, IMAGE, VIDEO, EMOTICONS, PRODUCT\_CARD, ORDER\_CARD, LOGISTICS\_CARD, RETURN\_REFUND\_CARD, COUPON\_CARD, NOTIFICATION, ALLOCATED\_SERVICE, BUYER\_ENTER\_FROM\_ORDER, BUYER\_ENTER\_FROM\_PRODUCT, BUYER\_ENTER\_FROM\_TRANSFER or OTHER |
> | `sender_role` | String | BUYER, SHOP (auto-replies and FAQs), CUSTOMER\_SERVICE (an agent), SYSTEM or ROBOT (chatbot) |
> | `sender_nickname` | String | Shop name, agent name or buyer nickname |
> | `sender_im_user_id` | String | Sender's ID in the TikTok Shop chat (tells agents apart) |
> | `text` | String | Text of text-like messages (empty for cards and media) |
> | `order_id` | String | Order shared in the chat (order, return/refund and logistics cards, or when the buyer came from an order) |
> | `product_id` | String | Product shared in the chat (product cards, or when the buyer came from a product) |
> | `sku_id` | String | SKU of a return/refund card |
> | `package_id` | String | Package of a logistics card |
> | `coupon_id` | String | Coupon of a coupon card |
> | `content` | JSON | The message content as TikTok Shop sends it (text, image or video links, card IDs) |
> | `is_visible` | Boolean | Whether the message is shown to customer service (hidden ones are system messages such as the rating request) |
> | `message_index` | String | Position of the message in the conversation (larger is newer) |

> [accordion] Sessions
>
> One row per customer service session (a buyer's request, from the first message until it is closed). Synced incrementally by `begin_time`; each run also reads the last days again (**Lookback**) and every session that was still open, so end time, first response and rating are updated. TikTok Shop only returns the last 90 days.
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `id` | String | Session ID |
> | `conversation_id` | String | Conversation the session belongs to |
> | `shop_id` | String | Shop the session belongs to |
> | `begin_time` | Datetime | When the session began (UTC), used as the incremental replication key |
> | `end_time` | Datetime | When the session ended (UTC); empty while it is open |
> | `buyer_nickname` | String | Buyer's TikTok nickname |
> | `chat_tags` | Array | Topics: AfterSale, Logistics, Presale |
> | `satisfaction_score` | Integer | Buyer's rating (1 to 5); empty when not rated |
> | `dissatisfaction_reason` | String | Reason given for a low rating |
> | `first_response_late` | Boolean | Whether the first response came after the expected time |
> | `first_response_time` | Integer | Seconds between the buyer's first message and the shop's first response |

> [accordion] Daily Performance
>
> One row per shop and day, from TikTok Shop's customer service performance report. Synced incrementally by `date`, reading the last days again on each run (**Lookback**). Today (in the shop's timezone) is not included until the day is over. Without an **Initial sync date**, it starts 90 days back.
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `shop_id` | String | Shop the metrics belong to |
> | `date` | Date | Day the metrics cover |
> | `support_session_count` | Integer | Chat sessions started by customers that day |
> | `response_percentage` | Number | Percentage of sessions answered within 24 hours |
> | `satisfaction_percentage` | Number | Percentage of rated sessions rated 4 or 5 stars |
> | `response_time_mins` | Number | Average first response time, in minutes |
> | `conversion_rate` | Number | Percentage of potential customers who converted |
> | `cs_guided_gmv` | Number | Revenue of orders placed within 7 days of a customer service response |
> | `currency` | String | Currency of `cs_guided_gmv` |

## Example query: conversations handled per agent

```sql theme={null}
SELECT
  m.sender_nickname AS agent,
  COUNT(DISTINCT m.conversation_id) AS conversations,
  COUNT(*) AS messages_sent
FROM messages m
WHERE m.sender_role = 'CUSTOMER_SERVICE'
GROUP BY m.sender_nickname
ORDER BY conversations DESC
```

To see the order behind a question, join `messages.order_id` with the `orders` table of the [TikTok Shop](https://docs.nekt.com/sources/tiktok-shop.md) connector.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.