Pango AI MascotPango Chatbot AI
Chatbot ServiceTích hợp GraphQL (Mẫu)
API Gateway

Đóng Phiên Chat Mẫu (ExampleCloseSession)

MUTATION Yêu cầu Bearer Token

🛡️ Lưu Ý An Toàn: Cấu trúc Schema, tên Mutation và các tham số dưới đây được cung cấp ở dạng mẫu minh họa (Example/Mock). Không sử dụng trực tiếp làm hợp đồng sản xuất khi chưa được Pango AI Team cấp thông số môi trường chính thức.

Đóng phiên chat hiện tại khi người dùng bấm "Bắt đầu cuộc trò chuyện mới", "Làm mới hội thoại" hoặc khi vấn đề hỗ trợ đã được giải quyết trọn vẹn. Sau khi đóng, các câu hỏi tiếp theo sẽ được coi là thuộc phiên chat mới (session_id: null).

💻 Chi Tiết Truy Vấn & Mã Nguồn Mẫu

GraphQL Mutation & Payload:

GraphQL Mutation

ExampleCloseSession.gql
mutation ExampleCloseSession($session_id: String!) {
  exampleCloseSession(session_id: $session_id) {
    is_closed
    session_id
    ended_at
  }
}

Variables (JSON)

Variables
{
  "session_id": "sess_89f1a23b4c5d6e7f"
}

Phản Hồi Thành Công (JSON Response Mẫu)

Response 200 OK
{
  "data": {
    "exampleCloseSession": {
      "is_closed": true,
      "session_id": "sess_89f1a23b4c5d6e7f",
      "ended_at": "2026-10-07T10:00:00Z"
    }
  }
}

TypeScript / Axios:

exampleCloseSession.ts
import axios from 'axios';

/**
 * Đóng phiên chat hiện tại (Mẫu)
 * @param apiUrl Endpoint GraphQL Gateway
 * @param token JWT Access Token
 * @param sessionId ID phiên chat cần đóng
 */
export async function exampleCloseSession(
  apiUrl: string = process.env.VITE_API_URL!,
  token: string,
  sessionId: string
): Promise<boolean> {
  const query = `
    mutation ExampleCloseSession($session_id: String!) {
      exampleCloseSession(session_id: $session_id) {
        is_closed
        session_id
      }
    }
  `;

  const response = await axios.post(
    apiUrl,
    {
      query,
      variables: { session_id: sessionId },
      operationName: 'ExampleCloseSession',
    },
    {
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${token}`,
        'x-org-id': process.env.VITE_ORG_ID || 'org_sample_demo',
        'x-client-type': 'app',
        'x-external-private-key': process.env.VITE_EXTERNAL_PRIVATE_KEY || 'your_secret_key',
      },
    }
  );

  return !!response.data?.data?.exampleCloseSession?.is_closed;
}
Pango AI Mascot© 2026 Pango Chatbot AI • Phát triển bởi Pango AI Team
v1.0 Enterprise