الانتقال إلى المحتوى الرئيسي
استخدم الرسائل لكتابة دردشة العملاء وتحديثات الدعم وإشعارات الطلب والردود بمساعدة Connect360 على Connect360.

إرسال كمساحة عمل

بشكل افتراضي، يتم إرسال الرسائل كعضو مساحة العمل المرفق بالمفتاح API.
const message = await plato.v1.connect.send.mutate({
  conversationId: "conversation_id",
  content: {
    en: "Hello from the support team.",
  },
});

إرسال كعميل

استخدم sender: "customer" عندما تأتي الرسالة من زائر موقع الويب أو عميل خارجي.
const message = await plato.v1.connect.send.mutate({
  conversationId: "conversation_id",
  sender: "customer",
  customer: {
    externalId: "website_user_123",
    name: "Jane Customer",
    email: "[email protected]",
  },
  content: {
    en: "I need help with my order.",
  },
  channelIdentifier: "example.com",
});

مدخل

{
  conversationId: string;
  content?: Partial<Record<"en" | "ar" | "tr", unknown>> | null;
  attachmentIds?: string[] | null;
  flags?: string[] | null;
  parentId?: string | null;
  templateId?: string | null;
  templateContext?: unknown;
  channelId?: string | null;
  channelIdentifier?: string | null;
  sender?: "workspace" | "customer";
  customerId?: string | null;
  customer?: {
    id?: string | null;
    externalId?: string | null;
    name?: string | null;
    email?: string | null;
    phone?: string | null;
    image?: string | null;
    metadata?: Record<string, unknown> | null;
  } | null;
  ai?: {
    agentId: string;
    channelId?: string | null;
  } | null;
}

الردود

استخدم parentId عند الرد على رسالة معينة.
await plato.v1.connect.send.mutate({
  conversationId: "conversation_id",
  parentId: "message_id",
  content: {
    en: "Following up on this message.",
  },
});

المرفقات

قم بتحميل الملفات ذات نقطة نهاية المرفقات Connect360، ثم قم بتمرير معرفات الملفات التي تم إرجاعها:
await plato.v1.connect.send.mutate({
  conversationId: "conversation_id",
  content: {
    en: "Attached is the document.",
  },
  attachmentIds: ["file_id_1"],
});
انظر المرفقات.

قم بتشغيل AI بعد الإرسال

قم بتمرير معرف وكيل AI لطلب رد AI بعد تخزين الرسالة.
await plato.v1.connect.send.mutate({
  conversationId: "conversation_id",
  content: {
    en: "Can you help this customer?",
  },
  ai: {
    agentId: "ai_agent_id",
  },
});
تعمل ردود AI بشكل غير متزامن.

قائمة الرسائل

const page = await plato.v1.connect.listMessages.query({
  conversationId: "conversation_id",
  limit: 50,
});
إجابة:
{
  items: [
    {
      id: "message_id",
      content: {
        en: "Hello"
      },
      conversationId: "conversation_id",
      attachments: [],
      sender: {}
    }
  ],
  nextCursor: "message_id_for_next_page"
}
يتم إرجاع الرسائل من الأقدم إلى الأحدث داخل كل صفحة. لجلب الصفحة التالية:
const nextPage = await plato.v1.connect.listMessages.query({
  conversationId: "conversation_id",
  cursor: page.nextCursor,
  limit: 50,
});