@nextxai/sdk 0.2.0 → 0.3.0-beta.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  Theo [Semantic Versioning](https://semver.org/lang/vi/). Chính sách phiên bản: [VERSIONING.md](VERSIONING.md).
4
4
 
5
+ ## 0.3.0 (2026-10-31)
6
+
7
+ ### Thêm mới
8
+
9
+ - Kiểm chữ ký webhook theo chuẩn Standard Webhooks: Node `@nextxai/sdk/webhooks` (`verifyWebhook`, `signWebhook`, kiểu sự kiện `call.*` · `agent.status_changed`), Python `nextx_sdk.webhooks` (`verify_webhook`, `sign_webhook`).
10
+ - `NextXPhone.answer()`: nhấc cuộc đang đổ chuông từ phần mềm của bạn (ví dụ nút "Nghe" trên màn khách hàng khi nhận sự kiện `incoming`). Chuyển máy dùng REST `POST /api/v1/call/partner/calls/{id}/transfer`.
11
+ - `GET /api/v1/call/calls/{id}/transcript`: Transcript STT
12
+ - `GET /api/v1/call/calls/{id}/summary`: AI summary + sentiment
13
+ - `POST /api/v1/call/partner/calls`: Bấm gọi thay tổng đài viên (click-to-call)
14
+ - `GET /api/v1/call/partner/calls/{id}`: Chi tiết một cuộc gọi
15
+ - `POST /api/v1/call/partner/calls/{id}/hangup`: Gác máy
16
+ - `POST /api/v1/call/partner/calls/{id}/transfer`: Chuyển máy
17
+ - `GET /api/v1/call/partner/calls/{id}/recording`: Link tải ghi âm (15 phút)
18
+ - `GET /api/v1/call/partner/active-calls`: Cuộc gọi đang diễn ra
19
+ - `GET /api/v1/call/partner/agents/status`: Trạng thái tổng đài viên
20
+ - `PUT /api/v1/call/partner/agents/status`: Đặt trạng thái tổng đài viên
21
+ - `#/ContractSummaryDto`: Thêm trường autoRenewStatus
22
+ - `#/PartnerSetAgentStatusRequest`: Thêm kiểu
23
+ - `#/PartnerAgentStatusDto`: Thêm kiểu
24
+ - `#/PartnerAgentDto`: Thêm kiểu
25
+ - `#/PartnerRecordingLinkDto`: Thêm kiểu
26
+ - `#/PartnerTransferRequest`: Thêm kiểu
27
+ - `#/PartnerAgentRefRequest`: Thêm kiểu
28
+ - `#/PartnerCallDto`: Thêm kiểu
29
+ - `#/PartnerOriginateRequest`: Thêm kiểu
30
+ - `#/CallSummaryAiDto`: Thêm kiểu
31
+ - `#/ActionItemDto`: Thêm kiểu
32
+ - `#/CallTranscriptDto`: Thêm kiểu
33
+ - `#/TranscriptSegmentDto`: Thêm kiểu
34
+
5
35
  ## 0.2.0 (2026-10-30)
6
36
 
7
37
  ### Thêm mới
package/README.md CHANGED
@@ -31,6 +31,32 @@ for (const c of data.items ?? []) console.log(c.fullName);
31
31
  const nx = createNextXClient({ accessToken: () => tokenStore.current() });
32
32
  ```
33
33
 
34
+ ## Nhận webhook
35
+
36
+ Kiểm chữ ký theo chuẩn [Standard Webhooks](https://www.standardwebhooks.com) (chỉ chạy trên máy chủ). Truyền thân gốc, không phải JSON đã parse:
37
+
38
+ ```ts
39
+ import { verifyWebhook } from "@nextxai/sdk/webhooks";
40
+
41
+ app.post("/nextx/webhook", express.raw({ type: "application/json" }), (req, res) => {
42
+ const event = verifyWebhook(req.body, req.headers, process.env.NEXTX_WEBHOOK_SECRET!);
43
+ if (event.type === "call.completed") console.log(event.data.object.talkSec, event.data.object.contactRef);
44
+ res.sendStatus(204);
45
+ });
46
+ ```
47
+
48
+ Sai chữ ký hoặc lệch giờ quá 5 phút thì ném `WebhookVerificationError`. Dùng `event.id` để bỏ qua lần giao trùng.
49
+
50
+ ## Softphone nhúng (trình duyệt)
51
+
52
+ ```ts
53
+ import { NextXPhone } from "@nextxai/sdk/phone";
54
+
55
+ const phone = NextXPhone.init({ clientId: "nxa_…" });
56
+ phone.on("incoming", (c) => openCustomer(c.from));
57
+ phone.call("0901234567"); // phone.answer() · phone.hangup()
58
+ ```
59
+
34
60
  ## Ghi chú
35
61
 
36
62
  - Mặc định client gọi môi trường production. Khi thử nghiệm, dùng `SANDBOX_URL` với khoá sandbox.
@@ -73,6 +73,8 @@ export declare class NextXPhone {
73
73
  call(number: string, opts?: {
74
74
  contactRef?: string;
75
75
  }): void;
76
+ /** Nhấc cuộc đang đổ chuông (sự kiện `incoming`) — y như tổng đài viên bấm "Nghe" trong khung. */
77
+ answer(): void;
76
78
  /** Gác cuộc gọi đang diễn ra. */
77
79
  hangup(): void;
78
80
  /** Đăng xuất NextX trong khung softphone. */
package/dist/cjs/phone.js CHANGED
@@ -100,6 +100,10 @@ class NextXPhone {
100
100
  call(number, opts = {}) {
101
101
  this.send({ type: "call", number: String(number), contactRef: opts.contactRef });
102
102
  }
103
+ /** Nhấc cuộc đang đổ chuông (sự kiện `incoming`) — y như tổng đài viên bấm "Nghe" trong khung. */
104
+ answer() {
105
+ this.send({ type: "answer" });
106
+ }
103
107
  /** Gác cuộc gọi đang diễn ra. */
104
108
  hangup() {
105
109
  this.send({ type: "hangup" });