@the_ro_show/agent-ads-sdk 0.2.0 → 0.2.1

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
@@ -2,6 +2,14 @@
2
2
 
3
3
  TypeScript SDK for integrating agent-native sponsored units (Sponsored Suggestions and Sponsored Tools) into AI agents.
4
4
 
5
+ ## 🚀 New to this? Start Here
6
+
7
+ **→ [Simple Integration Guide](./SIMPLE_INTEGRATION_GUIDE.md)** - Step-by-step guide for Clawdbot/Moltbot developers
8
+
9
+ This README contains the full API reference. If you're just getting started, the Simple Integration Guide is much easier to follow!
10
+
11
+ ---
12
+
5
13
  ## Installation
6
14
 
7
15
  ```bash
@@ -0,0 +1,324 @@
1
+ # 🤖 How to Add Ads to Your Clawdbot/Moltbot in Simple English
2
+
3
+ ### **The Big Picture:**
4
+ Your bot answers user questions. Sometimes those answers could include a helpful ad (like suggesting Pietra when someone asks about starting an online store). You get paid when users see/click those ads.
5
+
6
+ ---
7
+
8
+ ## Step-by-Step Guide
9
+
10
+ ### **Step 1: Sign Up for API Keys** (One-time, 2 minutes)
11
+
12
+ You need permission to request ads. Think of this like getting a key to a vending machine.
13
+
14
+ **How to do it:**
15
+ ```bash
16
+ # Run this command once (it's like filling out a registration form)
17
+ curl -X POST https://api.attentionmarket.ai/v1/agent-signup \
18
+ -H 'Content-Type: application/json' \
19
+ -d '{
20
+ "owner_email": "your-email@example.com",
21
+ "agent_name": "My Cool Bot",
22
+ "sdk_type": "typescript"
23
+ }'
24
+ ```
25
+
26
+ **You'll get back:**
27
+ - An **Agent ID** (like `agt_abc123`) - your username
28
+ - A **Test Key** (like `am_test_xyz789`) - for testing
29
+ - A **Live Key** (like `am_live_xyz789`) - for when you go live
30
+
31
+ **Write these down!** You'll need them.
32
+
33
+ ---
34
+
35
+ ### **Step 2: Install the SDK** (One-time, 30 seconds)
36
+
37
+ This is like downloading an app on your phone.
38
+
39
+ **In your bot's code folder:**
40
+ ```bash
41
+ npm install @the_ro_show/agent-ads-sdk
42
+ ```
43
+
44
+ Done!
45
+
46
+ ---
47
+
48
+ ### **Step 3: Set Up Your Credentials** (One-time, 1 minute)
49
+
50
+ Create a file called `.env` in your bot's folder:
51
+
52
+ ```bash
53
+ ATTENTIONMARKET_API_KEY=am_test_xyz789 # Use your test key from Step 1
54
+ ATTENTIONMARKET_AGENT_ID=agt_abc123 # Use your agent ID from Step 1
55
+ ```
56
+
57
+ ---
58
+
59
+ ### **Step 4: Add Code to Your Bot** (10 minutes)
60
+
61
+ This is where your bot learns to request and show ads.
62
+
63
+ #### **A. Import the SDK** (Add to top of your bot's code)
64
+
65
+ ```typescript
66
+ import { AttentionMarketClient, createOpportunity } from '@the_ro_show/agent-ads-sdk';
67
+
68
+ // Initialize the SDK (this connects you to the ad platform)
69
+ const adClient = new AttentionMarketClient({
70
+ apiKey: process.env.ATTENTIONMARKET_API_KEY,
71
+ });
72
+ ```
73
+
74
+ #### **B. Decide WHEN to Show Ads**
75
+
76
+ You choose when! Here's a simple example:
77
+
78
+ ```typescript
79
+ // Your bot's existing code that handles user messages
80
+ async function handleUserMessage(userMessage) {
81
+ // 1. Your bot answers the question (like normal)
82
+ const botAnswer = await yourBot.respond(userMessage);
83
+
84
+ // 2. Check if this is a good time to show an ad
85
+ let ad = null;
86
+
87
+ if (userMessage.toLowerCase().includes('online store') ||
88
+ userMessage.toLowerCase().includes('ecommerce')) {
89
+
90
+ // 3. Request an ad about e-commerce
91
+ ad = await adClient.decide({
92
+ request_id: `req_${Date.now()}`,
93
+ agent_id: process.env.ATTENTIONMARKET_AGENT_ID,
94
+ placement: {
95
+ type: 'sponsored_suggestion',
96
+ surface: 'chat'
97
+ },
98
+ opportunity: createOpportunity({
99
+ taxonomy: 'shopping.ecommerce.platform', // This matches Pietra!
100
+ country: 'US',
101
+ language: 'en',
102
+ platform: 'web',
103
+ }),
104
+ });
105
+ }
106
+
107
+ // 4. Send both the answer AND the ad back to the user
108
+ return {
109
+ answer: botAnswer,
110
+ ad: ad // This will be null if no ad matches
111
+ };
112
+ }
113
+ ```
114
+
115
+ #### **C. Display the Ad to the User**
116
+
117
+ Show it clearly labeled as "Sponsored":
118
+
119
+ ```typescript
120
+ // Example: Showing in chat
121
+ if (ad) {
122
+ console.log('\n--- Sponsored ---');
123
+ console.log(`${ad.suggestion.title}`);
124
+ console.log(`${ad.suggestion.body}`);
125
+ console.log(`👉 ${ad.suggestion.cta}: ${ad.suggestion.action_url}`);
126
+ console.log(`(Sponsored by ${ad.disclosure.sponsor_name})`);
127
+
128
+ // Track that user saw it (you get paid!)
129
+ await adClient.trackImpression({
130
+ agent_id: process.env.ATTENTIONMARKET_AGENT_ID,
131
+ request_id: 'req_...', // Same ID from step B
132
+ decision_id: ad.unit_id,
133
+ unit_id: ad.unit_id,
134
+ tracking_token: ad.tracking.token,
135
+ });
136
+ }
137
+ ```
138
+
139
+ #### **D. Track When User Clicks**
140
+
141
+ If user clicks the ad link:
142
+
143
+ ```typescript
144
+ // When user clicks the ad link
145
+ await adClient.trackClick({
146
+ agent_id: process.env.ATTENTIONMARKET_AGENT_ID,
147
+ request_id: 'req_...',
148
+ decision_id: ad.unit_id,
149
+ unit_id: ad.unit_id,
150
+ tracking_token: ad.tracking.token,
151
+ });
152
+ ```
153
+
154
+ ---
155
+
156
+ ## 📱 **Real Example: Bot Conversation**
157
+
158
+ **User:** "How do I start an online store?"
159
+
160
+ **Your Bot:**
161
+ ```
162
+ 🤖 Starting an online store involves choosing a platform,
163
+ setting up products, and marketing. Here are the basics...
164
+
165
+ [Your bot's helpful answer here]
166
+
167
+ --- Sponsored ---
168
+ Pietra - E-Commerce Platform for Product Brands
169
+ Launch your online store in minutes. Built-in inventory,
170
+ shipping, and payments. Trusted by 10,000+ brands.
171
+
172
+ 👉 Start Free Trial: https://pietrastudio.com
173
+ (Sponsored by Pietra Inc)
174
+ ```
175
+
176
+ **You get paid** when the user sees this ✅
177
+ **You get paid more** if they click it ✅
178
+
179
+ ---
180
+
181
+ ## 🎯 **What You Control:**
182
+
183
+ ### ✅ **You Decide WHEN to Show Ads:**
184
+ - After certain types of questions
185
+ - Once every 5 messages
186
+ - Only for commercial topics
187
+ - Never for sensitive topics
188
+
189
+ ### ✅ **You Decide WHERE:**
190
+ - In chat responses
191
+ - In email summaries
192
+ - In tool suggestions
193
+ - In search results
194
+
195
+ ### ✅ **You Decide HOW:**
196
+ - At the bottom of your response
197
+ - In a special "Sponsored" section
198
+ - As a subtle suggestion
199
+ - With colors/borders (if you have a UI)
200
+
201
+ ---
202
+
203
+ ## 🔑 **Key Concepts (Simple):**
204
+
205
+ ### **Taxonomy** = Topic Category
206
+ When you request an ad, you tell us what the user is asking about:
207
+ - `shopping.ecommerce.platform` = Online store questions
208
+ - `local_services.movers.quote` = Moving company questions
209
+ - `business.productivity.tools` = Productivity software questions
210
+
211
+ **You pick the taxonomy** based on what the user asked.
212
+
213
+ ### **Request ID** = Unique Identifier
214
+ Like a receipt number. You generate a random ID each time you request an ad:
215
+ ```typescript
216
+ request_id: `req_${Date.now()}` // req_1706889234567
217
+ ```
218
+
219
+ ### **Tracking Token** = Proof You Showed the Ad
220
+ Comes back with the ad. You send it when tracking impressions/clicks so we know it's real.
221
+
222
+ ---
223
+
224
+ ## 💰 **How You Make Money:**
225
+
226
+ 1. **User asks question** → Your bot answers
227
+ 2. **You request ad** → Get back Pietra ad
228
+ 3. **You show ad** → Track impression → **You get paid ~$0.005**
229
+ 4. **User clicks ad** → Track click → **You get paid ~$0.50**
230
+
231
+ **That's it!** The more relevant ads you show, the more users click, the more you earn.
232
+
233
+ ---
234
+
235
+ ## ⚡ **Quick Start (Copy-Paste):**
236
+
237
+ Here's everything in one block:
238
+
239
+ ```typescript
240
+ import { AttentionMarketClient, createOpportunity } from '@the_ro_show/agent-ads-sdk';
241
+
242
+ const adClient = new AttentionMarketClient({
243
+ apiKey: process.env.ATTENTIONMARKET_API_KEY,
244
+ });
245
+
246
+ // In your message handler
247
+ async function handleMessage(userMessage) {
248
+ const botAnswer = await yourBot.respond(userMessage);
249
+
250
+ // Request ad if about e-commerce
251
+ let ad = null;
252
+ if (userMessage.includes('online store')) {
253
+ ad = await adClient.decide({
254
+ request_id: `req_${Date.now()}`,
255
+ agent_id: process.env.ATTENTIONMARKET_AGENT_ID,
256
+ placement: { type: 'sponsored_suggestion', surface: 'chat' },
257
+ opportunity: createOpportunity({
258
+ taxonomy: 'shopping.ecommerce.platform',
259
+ country: 'US',
260
+ language: 'en',
261
+ platform: 'web',
262
+ }),
263
+ });
264
+
265
+ // Track impression
266
+ if (ad) {
267
+ await adClient.trackImpression({
268
+ agent_id: process.env.ATTENTIONMARKET_AGENT_ID,
269
+ request_id: 'req_...',
270
+ decision_id: ad.unit_id,
271
+ unit_id: ad.unit_id,
272
+ tracking_token: ad.tracking.token,
273
+ });
274
+ }
275
+ }
276
+
277
+ return { answer: botAnswer, ad };
278
+ }
279
+ ```
280
+
281
+ ---
282
+
283
+ ## ✅ **Checklist:**
284
+
285
+ - [ ] Run signup command to get API keys
286
+ - [ ] Install SDK: `npm install @the_ro_show/agent-ads-sdk`
287
+ - [ ] Create `.env` file with your keys
288
+ - [ ] Add SDK import to your bot code
289
+ - [ ] Add code to request ads (when appropriate)
290
+ - [ ] Add code to display ads (clearly labeled)
291
+ - [ ] Add tracking for impressions
292
+ - [ ] Add tracking for clicks
293
+ - [ ] Test with a question about "online store"
294
+ - [ ] See Pietra ad appear!
295
+
296
+ ---
297
+
298
+ **That's it!** You're now monetizing your bot with relevant ads. 🎉
299
+
300
+ Users get helpful suggestions, advertisers reach their audience, and you get paid for providing value to both sides.
301
+
302
+ ---
303
+
304
+ ## 🆘 **Need Help?**
305
+
306
+ - **Documentation:** See README.md for full API reference
307
+ - **Security:** See SECURITY.md for best practices
308
+ - **Issues:** https://github.com/rtrivedi/agent-ads-sdk/issues
309
+
310
+ ---
311
+
312
+ ## 🔄 **Advanced: Custom Configuration**
313
+
314
+ If you're self-hosting or need custom backend:
315
+
316
+ ```typescript
317
+ const adClient = new AttentionMarketClient({
318
+ apiKey: process.env.ATTENTIONMARKET_API_KEY,
319
+ baseUrl: 'https://your-custom-backend.com/v1', // Optional
320
+ supabaseAnonKey: 'your-key', // Optional (for Supabase)
321
+ });
322
+ ```
323
+
324
+ For most users, just the `apiKey` is enough!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the_ro_show/agent-ads-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "TypeScript SDK for integrating agent-native sponsored units (Sponsored Suggestions and Sponsored Tools) into AI agents",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -16,7 +16,8 @@
16
16
  "dist",
17
17
  "README.md",
18
18
  "LICENSE",
19
- "SECURITY.md"
19
+ "SECURITY.md",
20
+ "SIMPLE_INTEGRATION_GUIDE.md"
20
21
  ],
21
22
  "repository": {
22
23
  "type": "git",