import { createPodiumClient } from '@podium-sdk/node-sdk';
const client = createPodiumClient({ apiKey: process.env.PODIUM_API_KEY });
async function agentLoop(userId: string) {
let profile = await client.companion.listProfile({ userId }).catch(() => null);
if (!profile) {
profile = await client.companion.createProfile({
userId,
requestBody: {
skinType: 'combination',
concerns: ['hydration'],
priceRange: { min: 10, max: 40 },
brands: [],
avoidances: ['fragrance'],
},
});
}
const recs = await client.companion.listRecommendations({
userId,
count: 5,
});
// Present to user, collect feedback
for (const rec of recs.recommendations) {
const userAction = await getUserFeedback(rec); // your UI layer
await client.companion.createInteractions({
requestBody: {
userId,
productId: rec.productId,
action: userAction, // 'RANK_UP', 'SKIP', etc.
},
});
if (userAction === 'PURCHASE_INTENT') {
const order = await client.companion.createOrders({
requestBody: {
userId,
productId: rec.productId,
shippingAddress: await getShippingAddress(userId),
email: await getUserEmail(userId),
},
});
console.log(`Order created: ${order.id}`);
}
}
await client.companion.createProfilePoints({
userId,
requestBody: { amount: 25, details: { reason: 'session_complete' } },
});
}