ข้ามไปยังเนื้อหา

นำเข้าแชทและรายชื่อติดต่อจากแพลตฟอร์มอื่น

เริ่มการนำเข้าได้ในแอปเจ้าหน้าที่ที่ แอป > นำเข้าจากแพลตฟอร์มอื่น หรือด้วย API โทเค็นต้องมี settings.manage และขอบเขตสิทธิ์สำหรับข้อมูลแต่ละประเภทที่จะเขียน ได้แก่ team.manage สำหรับกลุ่ม และเจ้าหน้าที่ tags.manage สำหรับแท็ก canned.manage สำหรับข้อความตอบกลับสำเร็จรูป customers.write สำหรับลูกค้า และ archives.write คู่กับ customers.write สำหรับแชท การนำเข้าทำได้ครั้งละหนึ่งรายการ การนำเข้าเดิมซ้ำอีกครั้ง ทำได้อย่างปลอดภัย โดยข้อมูลที่นำเข้าแล้วจะถูกข้าม และแชทจะคง id และเวลาเดิมไว้ เจ้าหน้าที่จะถูกนำเข้าในรูปแบบคำเชิญ เพราะรหัสผ่านจะไม่ถูกส่งออกจากแพลตฟอร์มเดิม

ต้นทางวิธีนำเข้าข้อมูลที่นำเข้า
LiveChatผ่าน API ของระบบนั้น ด้วยโทเค็นของคุณgroups, agents, tags, canned responses, customers, archives
Intercomผ่าน API ของระบบนั้น ด้วยโทเค็นของคุณgroups, agents, tags, customers, archives
Crispผ่าน API ของระบบนั้น ด้วยโทเค็นของคุณagents, customers, archives
Zendesk Chatผ่าน API ของระบบนั้น ด้วยโทเค็นของคุณgroups, agents, canned responses, archives
tawk.toไฟล์ส่งออก (json, csv)customers, archives
Tidioไฟล์ส่งออก (csv, json)customers, archives
Olarkไฟล์ส่งออก (csv, json)customers, archives
CSV or JSON fileไฟล์ส่งออก (json, ndjson, csv)groups, agents, tags, canned responses, customers, archives

สำหรับแหล่งข้อมูลแบบ API ฟอร์มนำเข้าจะขอข้อมูลรับรองที่จำเป็นและบอกว่าหาได้จากที่ใด ข้อมูลรับรองจะถูกเก็บแบบเข้ารหัสไว้จนกว่าการนำเข้าจะสิ้นสุด GET /v1/imports/sources แสดงรายการเดียวกันนี้

หากข้อมูลของคุณมาจากที่อื่น ให้ใส่ข้อมูลในไฟล์รูปแบบใดรูปแบบหนึ่งต่อไปนี้ source_id ของแต่ละรายการคือ id ที่คุณกำหนดเอง ซึ่งช่วยป้องกันไม่ให้การรันครั้งที่สองนำเข้ารายการเดิมซ้ำ ส่วนแท็กจะจับคู่ด้วย name แทน

ออบเจกต์เดียวที่มีรายการแยกตามประเภทข้อมูล ประเภทที่คุณไม่มีให้ละไว้:

import.json
{
"groups": [{ "source_id": "g-sales", "name": "Sales" }],
"agents": [{ "source_id": "a-1", "email": "maria@example.com", "name": "Maria Lopez", "role": "agent", "group_source_ids": ["g-sales"] }],
"tags": [{ "name": "refund", "color": "#e5484d" }],
"canned_responses": [{ "source_id": "c-1", "text": "Thanks for reaching out! How can I help?", "shortcuts": ["hi"], "group_source_id": null }],
"customers": [{ "source_id": "u-1", "name": "Ana Silva", "email": "ana@example.com", "phone": null, "external_user_id": "user-1001", "session_fields": [["plan", "pro"]] }],
"archives": [
{
"source_id": "chat-1",
"customer": { "source_id": "u-1", "name": "Ana Silva", "email": "ana@example.com" },
"threads": [
{
"source_id": "thread-1",
"created_at": "2026-03-02T10:15:00Z",
"closed_at": "2026-03-02T10:21:00Z",
"tags": ["refund"],
"rating": "good",
"group_source_id": "g-sales",
"events": [
{ "source_id": "e-1", "created_at": "2026-03-02T10:15:00Z", "author": { "type": "customer", "source_id": "u-1", "name": "Ana Silva" }, "body": { "type": "message", "text": "Hi, can I get a refund for order 1001?" } },
{ "source_id": "e-2", "created_at": "2026-03-02T10:16:30Z", "author": { "type": "agent", "source_id": "a-1", "name": "Maria Lopez", "email": "maria@example.com" }, "body": { "type": "message", "text": "Of course. I have started it, you will see it in 3 to 5 days." } },
{ "source_id": "e-3", "created_at": "2026-03-02T10:17:00Z", "author": { "type": "agent", "source_id": "a-1", "name": "Maria Lopez" }, "visibility": "agents", "body": { "type": "message", "text": "Refund approved under the 30-day policy." } }
]
}
]
}
]
}

ฟิลด์ที่จำเป็นแสดงเป็นตัวหนา ฟิลด์อื่นทั้งหมดละไว้ได้

  • groups: source_id, name
  • agents: source_id, email, name, role (admin หรือ agent), group_source_ids
  • tags: name, color ในรูปแบบ #rrggbb
  • canned_responses: source_id, text, shortcuts, group_source_id
  • customers: source_id, name, email, phone, external_user_id (id ผู้ใช้ของคุณเอง), session_fields เป็นคู่ชื่อและค่า, first_seen_at, last_seen_at
  • archives: แชทที่มี source_id, customer ของแชท และ threads (อย่างน้อยหนึ่งรายการ) เธรดมี source_id, created_at, events รวมถึง closed_at, tags, rating (good หรือ bad) และ group_source_id เหตุการณ์มี created_at, author (ซึ่ง type เป็น customer, agent หรือ system), body รวมถึง source_id และ visibility (agents สำหรับโน้ตภายใน) โดย type ของ body คือ message พร้อม text, file พร้อม url และ name, filled_form พร้อม form_kind และ answers, system พร้อม text หรือ custom

เวลาใช้รูปแบบ ISO 8601 พร้อม Z หรือค่าชดเชยเขตเวลา เช่น 2026-03-02T10:15:00Z หรือ 2026-03-02T17:15:00+07:00 ส่วนเซลล์ CSV รับวินาทีหรือมิลลิวินาทีแบบ Unix ได้ด้วย

หนึ่งรายการต่อหนึ่งบรรทัด โดยระบุประเภทไว้ใน type เหมาะสำหรับข้อมูลส่งออกขนาดใหญ่ เพราะประมวลผลแบบสตรีมได้

import.ndjson
{"type": "groups", "source_id": "g-sales", "name": "Sales"}
{"type": "tags", "name": "refund", "color": "#e5484d"}
{"type": "customers", "source_id": "u-1", "name": "Ana Silva", "email": "ana@example.com"}
{"type": "archives", "source_id": "chat-1", "customer": {"source_id": "u-1", "name": "Ana Silva"}, "threads": [{"source_id": "thread-1", "created_at": "2026-03-02T10:15:00Z", "events": [{"created_at": "2026-03-02T10:15:00Z", "author": {"type": "customer", "source_id": "u-1"}, "body": {"type": "message", "text": "Hi, can I get a refund for order 1001?"}}]}]}

หนึ่งไฟล์ต่อหนึ่งประเภทข้อมูล โดยแถวหัวตารางระบุชื่อฟิลด์ของรายการ และระบุประเภทเมื่อเริ่มการนำเข้า (csv_entity) CSV ของ archives มีหนึ่งแถวต่อหนึ่งข้อความ และแถวของแชทเดียวกันต้องอยู่ติดกัน:

archives.csv
chat_id,thread_id,created_at,author_type,author_name,author_email,text
chat-1,thread-1,2026-03-02T10:15:00Z,customer,Ana Silva,ana@example.com,"Hi, can I get a refund for order 1001?"
chat-1,thread-1,2026-03-02T10:16:30Z,agent,Maria Lopez,maria@example.com,"Of course. I have started it, you will see it in 3 to 5 days."
chat-2,thread-2,2026-03-03T08:02:00Z,customer,Joe Park,joe@example.com,Do you ship to Canada?

ไฟล์ CSV หรือ NDJSON มีขนาดได้สูงสุด 50 MB ส่วนไฟล์ JSON ซึ่งต้องอ่านทั้งไฟล์ มีขนาดได้สูงสุด

20 MB

อัปโหลดไฟล์ไปยัง signed URL เริ่มการนำเข้า แล้วตรวจสอบสถานะเป็นระยะ:

import-file.mjs
// Import an export file in the generic format, then wait for the import to finish. Node 18 or later.
// Usage: node import-file.mjs import-generic.json (a CSV also needs its entity: archives.csv archives)
import { readFile } from "node:fs/promises";
import { basename } from "node:path";
const api = process.env.C2R_API || "https://api.click2reply.com";
const auth = { authorization: `Bearer ${process.env.C2R_TOKEN}` };
const [path, csvEntity] = process.argv.slice(2);
async function call(route, body) {
const res = await fetch(`${api}${route}`, body === undefined ? { headers: auth } : { method: "POST", headers: { ...auth, "content-type": "application/json" }, body: JSON.stringify(body) });
const json = await res.json();
if (!res.ok) throw new Error(`${res.status} ${json.error.code}: ${json.error.message}`);
return json;
}
// 1. A signed URL to upload the file to, then the upload itself.
const file = await readFile(path);
const ticket = await call("/v1/imports:upload_url", { name: basename(path), size: file.length });
const put = await fetch(ticket.upload_url, { method: "PUT", body: file });
if (!put.ok) throw new Error(`upload answered ${put.status}`);
// 2. Start the import. Leave out options.include to import every record type the file holds.
let job = await call("/v1/imports", { source: "generic", file_key: ticket.file_key, options: { csv_entity: csvEntity ?? null } });
// 3. Poll until it ends; progress counts what each step imported, skipped and failed.
while (job.status === "queued" || job.status === "running") {
await new Promise((r) => setTimeout(r, 3000));
job = await call(`/v1/imports/${job.id}`);
}
console.log(JSON.stringify({ id: job.id, status: job.status, error_code: job.error_code, progress: job.progress }));

การนำเข้าที่ล้มเหลวหรือถูกยกเลิกจะดำเนินการต่อจากจุดที่หยุดไว้ด้วย POST /v1/imports/{id}:resume ส่วน POST /v1/imports/{id}:cancel ใช้หยุดการนำเข้าที่กำลังทำงานอยู่