@noti-bot/sdk 0.9.0 → 0.10.0

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/README.md CHANGED
@@ -54,6 +54,23 @@ await kakao.sendMessage({
54
54
  });
55
55
  ```
56
56
 
57
+ ## 답장
58
+
59
+ 받은 웹훅의 `messageId`(카톡이 붙인 메시지 ID)를 `replyTo`에 넣으면 그 메시지를 인용한 답장으로 나갑니다. 같은 방의 메시지만 인용할 수 있고, 없는 ID면 발송 결과가 `failed` + `reply_target_not_found`입니다. Iris 전송에서만 인용되며 그 밖에서는 인용 없이 본문만 나갑니다.
60
+
61
+ ```ts
62
+ await kakao.sendMessage({
63
+ roomId: process.env.KAKAO_ROOM_ID!,
64
+ text: '확인했어요',
65
+ replyTo: event.messageId,
66
+ requestId: `ack:${event.event_id}`,
67
+ });
68
+ ```
69
+
70
+ 웹훅 응답으로 바로 답할 때는 `{"reply": "확인했어요", "reply_to": "<messageId>"}`를 돌려주면 됩니다.
71
+
72
+ ## 이름으로 태그
73
+
57
74
  이름만 알면 `mentions`로 태그할 수 있습니다. 그 방 참여자 한 명으로 정해져야 보내고, 없거나 여럿이면 `NotiBotApiError`(`mention_name_unknown` / `mention_name_ambiguous`, `body.candidates`)로 거절됩니다.
58
75
 
59
76
  ```ts
package/dist/index.d.ts CHANGED
@@ -37,6 +37,11 @@ export type SendMessageInput = ({
37
37
  * reject with `mention_name_unknown` / `mention_name_ambiguous` (and `candidates`), unsent.
38
38
  */
39
39
  mentions?: string[];
40
+ /**
41
+ * Quote a message of the same room: pass `InboundWebhookEvent.messageId`. Iris transport only;
42
+ * elsewhere the text goes out unquoted. An unknown ID fails with `reply_target_not_found`.
43
+ */
44
+ replyTo?: string;
40
45
  };
41
46
  export interface SendMessageResult {
42
47
  ok: true;
@@ -98,6 +103,8 @@ export interface InboundWebhookEvent {
98
103
  roomExternalId?: string;
99
104
  sender: string;
100
105
  senderId?: string;
106
+ /** KakaoTalk's ID of this message (Iris transport only). Pass it as `replyTo` to quote it. */
107
+ messageId?: string;
101
108
  msg: string;
102
109
  command: string;
103
110
  isMention: boolean;
package/dist/index.js CHANGED
@@ -49,6 +49,8 @@ export class NotiBot {
49
49
  const requestId = input.requestId ?? globalThis.crypto.randomUUID();
50
50
  if (!requestId.trim() || requestId.length > 128)
51
51
  throw new TypeError("requestId must contain 1 to 128 characters.");
52
+ if (input.replyTo !== undefined && !/^\d{1,20}$/.test(input.replyTo))
53
+ throw new TypeError("replyTo must be a Kakao message ID (digits only).");
52
54
  const data = await this.request(input.roomId !== undefined
53
55
  ? `/v1/rooms/id/${encodeURIComponent(input.roomId)}/messages`
54
56
  : input.roomSlug !== undefined
@@ -58,6 +60,7 @@ export class NotiBot {
58
60
  msg: input.text,
59
61
  request_id: requestId,
60
62
  ...(input.mentions ? { mentions: input.mentions } : {}),
63
+ ...(input.replyTo ? { reply_to: input.replyTo } : {}),
61
64
  }, options.signal, requestId);
62
65
  if (!object(data) ||
63
66
  data.ok !== true ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noti-bot/sdk",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Typed server-side client for the NotiBot API",
5
5
  "license": "MIT",
6
6
  "author": "Jeongmin Lee",