Zum Inhalt springen

Chats und Kontakte importieren

Starten Sie einen Import in der Agenten-App unter Apps > Aus anderer Plattform importieren oder über die API. Ein Token braucht settings.manage und die Berechtigung, die jeder Datensatztyp schreibt: team.manage für Gruppen und Agenten, tags.manage für Tags, canned.manage für Textbausteine, customers.write für Kunden und archives.write zusammen mit customers.write für Chats. Es läuft immer nur ein Import gleichzeitig. Denselben Import erneut auszuführen, ist gefahrlos: Bereits Importiertes wird übersprungen, und Chats behalten ihre ursprünglichen IDs und Zeiten. Agenten werden als Einladungen angelegt, da Passwörter die andere Plattform nie verlassen.

VonWieWas übernommen wird
LiveChatÜber die API der Plattform, mit Ihrem Tokengroups, agents, tags, canned responses, customers, archives
IntercomÜber die API der Plattform, mit Ihrem Tokengroups, agents, tags, customers, archives
CrispÜber die API der Plattform, mit Ihrem Tokenagents, customers, archives
Zendesk ChatÜber die API der Plattform, mit Ihrem Tokengroups, agents, canned responses, archives
tawk.toEine Exportdatei (json, csv)customers, archives
TidioEine Exportdatei (csv, json)customers, archives
OlarkEine Exportdatei (csv, json)customers, archives
CSV or JSON fileEine Exportdatei (json, ndjson, csv)groups, agents, tags, canned responses, customers, archives

Bei einer API-Quelle fragt das Importformular die nötigen Zugangsdaten ab und sagt, wo Sie sie finden; sie werden verschlüsselt aufbewahrt, bis der Import endet. GET /v1/imports/sources liefert dieselbe Liste.

Wenn Ihre Daten von anderswo stammen, bringen Sie sie in eine dieser Dateien. Die source_id eines Datensatzes ist Ihre eigene ID dafür; sie verhindert, dass ein zweiter Durchlauf ihn doppelt importiert. Tags werden stattdessen über name zugeordnet.

Ein Objekt mit einer Liste pro Datensatztyp. Lassen Sie die Typen weg, die Sie nicht haben:

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." } }
]
}
]
}
]
}

Pflichtfelder sind fett gedruckt; alles andere kann entfallen.

  • groups: source_id, name.
  • agents: source_id, email, name, role (admin oder agent), group_source_ids.
  • tags: name, color als #rrggbb.
  • canned_responses: source_id, text, shortcuts, group_source_id.
  • customers: source_id, name, email, phone, external_user_id (Ihre eigene Nutzer-ID), session_fields als Paare aus Name und Wert, first_seen_at, last_seen_at.
  • archives: ein Chat mit source_id, seinem customer und threads (mindestens einer). Ein Thread hat source_id, created_at, events sowie closed_at, tags, rating (good oder bad) und group_source_id. Ein Ereignis hat created_at, einen author (dessen type ist customer, agent oder system), einen body sowie source_id und visibility (agents für eine interne Notiz). Der type des Body ist message mit text, file mit url und name, filled_form mit form_kind und answers, system mit text oder custom.

Zeiten sind im Format ISO 8601 mit Z oder einem Offset angegeben, etwa 2026-03-02T10:15:00Z oder 2026-03-02T17:15:00+07:00; eine CSV-Zelle akzeptiert auch Unix-Sekunden oder -Millisekunden.

Ein Datensatz pro Zeile, sein Typ in type. Nutzen Sie dieses Format für einen großen Export: Es wird gestreamt.

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?"}}]}]}

Eine Datei pro Datensatztyp, deren Kopfzeile die Felder des Datensatzes benennt; der Typ wird beim Start des Imports angegeben (csv_entity). Eine Archiv-CSV hat eine Zeile pro Nachricht, und die Zeilen eines Chats stehen direkt hintereinander:

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?

Eine CSV- oder NDJSON-Datei darf bis zu 50 MB groß sein; eine JSON-Datei, die als Ganzes gelesen wird, bis zu 20 MB.

Laden Sie die Datei an eine signierte URL hoch, starten Sie den Import und fragen Sie seinen Status ab:

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 }));

Ein fehlgeschlagener oder abgebrochener Import wird mit POST /v1/imports/{id}:resume dort fortgesetzt, wo er angehalten hat; POST /v1/imports/{id}:cancel stoppt einen laufenden Import.