@advertising-chat/sdk 0.17.3 → 0.18.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 +17 -9
- package/bin/client.js +5 -2
- package/bin/client.js.map +1 -1
- package/bin/render/webchat.d.ts +1 -1
- package/bin/render/webchat.js +1 -1
- package/bin/render/whatsapp.d.ts +1 -1
- package/bin/render/whatsapp.js +1 -1
- package/bin/types.d.ts +23 -14
- package/bin/types.js.map +1 -1
- package/package.json +30 -4
package/README.md
CHANGED
|
@@ -36,6 +36,14 @@ if (ad) {
|
|
|
36
36
|
|
|
37
37
|
Always present ads clearly labeled as **Sponsored**.
|
|
38
38
|
|
|
39
|
+
## Wire names in transition
|
|
40
|
+
|
|
41
|
+
Two response values are being renamed. The universal card's `format` is
|
|
42
|
+
`direqt` today and becomes `universal`, and message IDs start `direqt-` today
|
|
43
|
+
and will start `ad-`. Requests may already ask for `format: 'universal'`.
|
|
44
|
+
Treat `messageId` as opaque, and if you check either value, accept both;
|
|
45
|
+
`isAdPostbackData()` does.
|
|
46
|
+
|
|
39
47
|
## Your key is a fetch key
|
|
40
48
|
|
|
41
49
|
The key you pass is a **dataplane fetch key** — a per-Application API key
|
|
@@ -62,11 +70,11 @@ its fetch key's is rejected with `ApplicationMismatch`.
|
|
|
62
70
|
|
|
63
71
|
## Ad units are optional
|
|
64
72
|
|
|
65
|
-
Most publishers never set `adUnit`.
|
|
66
|
-
|
|
67
|
-
one. Omit it and the fetch fills against the application's
|
|
68
|
-
unit** (created on first use).
|
|
69
|
-
pin one by code; codes are unique within an application:
|
|
73
|
+
Most publishers never set `adUnit`. An ad unit names one placement in your
|
|
74
|
+
agent, a label that reporting groups by; a plain in-chat-ads integration
|
|
75
|
+
doesn't need one. Omit it and the fetch fills against the application's
|
|
76
|
+
**default ad unit** (created on first use). Publishers with several
|
|
77
|
+
placements can pin one by code; codes are unique within an application:
|
|
70
78
|
|
|
71
79
|
```ts
|
|
72
80
|
const ad = await adchat.fetchAd({ adUnit: 'trip-planner-sidebar' });
|
|
@@ -141,8 +149,8 @@ key, unsupported format).
|
|
|
141
149
|
An ad's reply actions (RCS suggested replies, Messenger quick replies,
|
|
142
150
|
WhatsApp reply buttons, webchat reply buttons) come back to your agent as an ordinary message that
|
|
143
151
|
carries the action's postback data. Report the tap so it counts as an
|
|
144
|
-
interaction and, for an accept or decline reply, records the
|
|
145
|
-
response
|
|
152
|
+
interaction and, for an accept or decline reply, records the person's
|
|
153
|
+
response, which frequency caps and reporting use:
|
|
146
154
|
|
|
147
155
|
```ts
|
|
148
156
|
import { messengerPostbackData } from '@advertising-chat/sdk';
|
|
@@ -205,5 +213,5 @@ const url = adchat.clickUrl({
|
|
|
205
213
|
```
|
|
206
214
|
|
|
207
215
|
Full quickstarts: [docs.advertising.chat](https://docs.advertising.chat).
|
|
208
|
-
Part of
|
|
209
|
-
|
|
216
|
+
Part of AdKit — see also `@advertising-chat/mcp` (MCP server) and the
|
|
217
|
+
[Ad Skill](https://docs.advertising.chat/network/ad-skill/).
|
package/bin/client.js
CHANGED
|
@@ -329,8 +329,11 @@ function conversationFromContext(context, subscriber) {
|
|
|
329
329
|
})),
|
|
330
330
|
};
|
|
331
331
|
}
|
|
332
|
-
/**
|
|
333
|
-
|
|
332
|
+
/**
|
|
333
|
+
* Ad message ids are `direqt-<uuid>` today and `ad-<uuid>` once the server
|
|
334
|
+
* switches to its new wire names; postback data appends `_<actionId>`.
|
|
335
|
+
*/
|
|
336
|
+
const AD_POSTBACK = /^(?:direqt|ad)-[^_]+_.+$/;
|
|
334
337
|
/**
|
|
335
338
|
* True for postback data that belongs to an ad action. Your agent's own
|
|
336
339
|
* replies carry their own payloads; report only the ad's to
|
package/bin/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AA0WA,0CAgBC;AAWD,0DAgBC;
|
|
1
|
+
{"version":3,"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CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,OAAO;QACL,cAAc,EAAE,SAAS,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;QAC3C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,IAAsB,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC;YAC5D,SAAS,EAAE,SAAS,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;YAC3C,QAAQ,EAAE,IAAI,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,IAAI,MAAM;YAClE,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE;SACvC,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAE/C;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,IAAa;IAC5C,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CAAC,KAErC;IACC,MAAM,OAAO,GAAG,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC;IACrD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC"}
|
package/bin/render/webchat.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface WebchatButton {
|
|
|
32
32
|
id: string;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* Render a universal
|
|
35
|
+
* Render a universal-format ad payload as a webchat message.
|
|
36
36
|
*
|
|
37
37
|
* ```ts
|
|
38
38
|
* const ad = await adchat.fetchAd<UniversalAdPayload>({ adUnit: 'chat-footer' });
|
package/bin/render/webchat.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.renderWebchat = renderWebchat;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
/**
|
|
6
|
-
* Render a universal
|
|
6
|
+
* Render a universal-format ad payload as a webchat message.
|
|
7
7
|
*
|
|
8
8
|
* ```ts
|
|
9
9
|
* const ad = await adchat.fetchAd<UniversalAdPayload>({ adUnit: 'chat-footer' });
|
package/bin/render/whatsapp.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type WhatsAppMessage = {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
|
-
* Render a universal
|
|
25
|
+
* Render a universal-format ad payload as a WhatsApp Cloud API
|
|
26
26
|
* message object.
|
|
27
27
|
*
|
|
28
28
|
* Mapping (faithful to the platform's channel renderers):
|
package/bin/render/whatsapp.js
CHANGED
|
@@ -10,7 +10,7 @@ const MAX_BUTTON_TITLE = 20;
|
|
|
10
10
|
const MAX_BUTTON_ID = 256;
|
|
11
11
|
const MAX_BODY = 1024;
|
|
12
12
|
/**
|
|
13
|
-
* Render a universal
|
|
13
|
+
* Render a universal-format ad payload as a WhatsApp Cloud API
|
|
14
14
|
* message object.
|
|
15
15
|
*
|
|
16
16
|
* Mapping (faithful to the platform's channel renderers):
|
package/bin/types.d.ts
CHANGED
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
* These mirror the server's fetch v2 / event v2 contracts. Ground truth:
|
|
5
5
|
* the `ads` service (`src/ads-api/v1`) and `ads/ads-api/src/v1/fetch.ts`.
|
|
6
6
|
*/
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Render formats supported by fetch v2 (`format` parameter). `universal` is
|
|
9
|
+
* the universal card's new name; `direqt` is its former name, which the
|
|
10
|
+
* server still reports in responses until it switches. Both are accepted.
|
|
11
|
+
*/
|
|
12
|
+
export type RenderFormat = 'universal' | 'direqt' | 'sms' | 'fbm' | 'html' | 'rcs-google' | 'rcs-gsma' | 'slack' | 'dialogflow';
|
|
9
13
|
/**
|
|
10
14
|
* One turn of conversation context.
|
|
11
15
|
*
|
|
@@ -61,14 +65,15 @@ export interface FetchAdParams {
|
|
|
61
65
|
*/
|
|
62
66
|
application?: string;
|
|
63
67
|
/**
|
|
64
|
-
* **Optional — most publishers can omit this.**
|
|
65
|
-
*
|
|
66
|
-
* integration doesn't need one. When omitted, the fetch fills
|
|
67
|
-
* application's default ad unit (created on first use).
|
|
68
|
-
*
|
|
68
|
+
* **Optional — most publishers can omit this.** An ad unit names one
|
|
69
|
+
* placement in your agent, a label your reporting groups by; a plain
|
|
70
|
+
* in-chat-ads integration doesn't need one. When omitted, the fetch fills
|
|
71
|
+
* against the application's default ad unit (created on first use).
|
|
72
|
+
* Publishers with several placements pin one by code; codes are unique
|
|
73
|
+
* within an application.
|
|
69
74
|
*/
|
|
70
75
|
adUnit?: string;
|
|
71
|
-
/** Render format for the payload. Defaults to
|
|
76
|
+
/** Render format for the payload. Defaults to the universal card (JSON). */
|
|
72
77
|
format?: RenderFormat;
|
|
73
78
|
/**
|
|
74
79
|
* Opaque, org-specific subscriber identifier. Used for frequency caps
|
|
@@ -122,8 +127,8 @@ export interface AdAction {
|
|
|
122
127
|
actionId: string;
|
|
123
128
|
}
|
|
124
129
|
/**
|
|
125
|
-
* The universal
|
|
126
|
-
* subtitle, image, and actions.
|
|
130
|
+
* The universal-format ad payload (`universal`, formerly `direqt`): a card
|
|
131
|
+
* with title, subtitle, image, and actions.
|
|
127
132
|
*/
|
|
128
133
|
export interface UniversalAdPayload {
|
|
129
134
|
title: string;
|
|
@@ -148,16 +153,20 @@ export interface AdMedia {
|
|
|
148
153
|
*/
|
|
149
154
|
export interface Ad<P = unknown> {
|
|
150
155
|
/**
|
|
151
|
-
* Fetch id for this served ad (
|
|
156
|
+
* Fetch id for this served ad (`direqt-<uuid>` today, `ad-<uuid>` once
|
|
157
|
+
* the server switches; treat it as opaque). Pass it to
|
|
152
158
|
* recordEvent()/recordConversion() to attribute events to this ad.
|
|
153
159
|
*/
|
|
154
160
|
messageId: string;
|
|
155
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* Render format of `payload`. The universal card reports `direqt` today
|
|
163
|
+
* and `universal` once the server switches; accept both.
|
|
164
|
+
*/
|
|
156
165
|
format?: string;
|
|
157
166
|
/**
|
|
158
167
|
* The rendered ad. Shape depends on the requested format:
|
|
159
|
-
* UniversalAdPayload for
|
|
160
|
-
* JSON for the gateway formats.
|
|
168
|
+
* UniversalAdPayload for the universal card, SmsAdPayload for 'sms',
|
|
169
|
+
* channel-native JSON for the gateway formats.
|
|
161
170
|
*/
|
|
162
171
|
payload: P;
|
|
163
172
|
properties?: Record<string, string>;
|
package/bin/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA+GH,8CAA8C;AAC9C,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,6BAAa,CAAA;IACb,wEAAwE;IACxE,6BAAa,CAAA;AACf,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAuED;;;;;GAKG;AACU,QAAA,eAAe,GAAG,aAAa,CAAC;AA2F7C;;;;;GAKG;AACH,MAAa,cAAe,SAAQ,KAAK;IAGrB;IAKA;IAPlB;IACE,uCAAuC;IACvB,MAAc;IAC9B;;;OAGG;IACa,MAAe,EAC/B,OAAgB;QAEhB,KAAK,CAAC,OAAO,IAAI,8BAA8B,MAAM,IAAI,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;QARzD,WAAM,GAAN,MAAM,CAAQ;QAKd,WAAM,GAAN,MAAM,CAAS;QAI/B,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAdD,wCAcC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@advertising-chat/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Typed client for the Advertising.chat ads API — fetch, click, and event tracking plus per-channel render helpers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Advertising.chat",
|
|
7
7
|
"homepage": "https://docs.advertising.chat/",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/advertising-chat/
|
|
11
|
-
"directory": "
|
|
10
|
+
"url": "git+https://github.com/advertising-chat/platform.git",
|
|
11
|
+
"directory": "tools/sdk"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"advertising",
|
|
@@ -28,9 +28,35 @@
|
|
|
28
28
|
"build": "tsc -p .",
|
|
29
29
|
"clean": "rm -rf ./bin",
|
|
30
30
|
"prepack": "npm run clean && npm run build",
|
|
31
|
-
"test": "mocha"
|
|
31
|
+
"test": "mocha",
|
|
32
|
+
"lint": "eslint .",
|
|
33
|
+
"lint-fix": "eslint . --fix",
|
|
34
|
+
"prettier": "prettier --list-different \"{src,test}/**/*.ts\" \"*.{json,mjs}\"",
|
|
35
|
+
"prettier-fix": "prettier --write \"{src,test}/**/*.ts\" \"*.{json,mjs}\"",
|
|
36
|
+
"check": "npm run build && npm run lint && npm run prettier && npm test"
|
|
32
37
|
},
|
|
33
38
|
"engines": {
|
|
34
39
|
"node": ">=18"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@eslint/eslintrc": "^3.3.7",
|
|
43
|
+
"@eslint/js": "^9.39.5",
|
|
44
|
+
"@types/chai": "^4.3.20",
|
|
45
|
+
"@types/mocha": "^10.0.10",
|
|
46
|
+
"@types/node": "^24.19.2",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.72.1",
|
|
48
|
+
"@typescript-eslint/parser": "^8.72.1",
|
|
49
|
+
"chai": "^4.5.0",
|
|
50
|
+
"eslint": "^9.39.5",
|
|
51
|
+
"eslint-config-prettier": "^10.1.8",
|
|
52
|
+
"globals": "^17.13.0",
|
|
53
|
+
"mocha": "^11.8.0",
|
|
54
|
+
"prettier": "^3.9.10",
|
|
55
|
+
"source-map-support": "^0.5.21",
|
|
56
|
+
"ts-node": "^10.9.2",
|
|
57
|
+
"typescript": "^5.9.3"
|
|
58
|
+
},
|
|
59
|
+
"adchat": {
|
|
60
|
+
"runtime": "universal"
|
|
35
61
|
}
|
|
36
62
|
}
|