1import { createOxinion } from 'oxinion';
2
3const oxinion = createOxinion({ apiKey: process.env.OXINION_API_KEY! });
4
5// Add a push notification node
6await oxinion.nodes.create({
7 pipelineId: "pipe_abc",
8 type: "notify",
9 orderIndex: 0,
10 config: {
11 userId: "{{userId}}",
12 title: "You're near our store!",
13 body: "Get 20% off today only.",
14 data: { deepLink: "myapp://offer/SAVE20" },
15 },
16});
17
18// Add an email node after it
19await oxinion.nodes.create({
20 pipelineId: "pipe_abc",
21 type: "mail",
22 orderIndex: 1,
23 config: {
24 to: "{{userEmail}}",
25 subject: "Your exclusive in-store offer",
26 html: "<p>Thanks for visiting! Here's your coupon: <strong>SAVE20</strong></p>",
27 },
28});
29
30// Add a webhook / invoke node last
31await oxinion.nodes.create({
32 pipelineId: "pipe_abc",
33 type: "invoke",
34 orderIndex: 2,
35 config: {
36 target: "https://yourcrm.com/api/log-visit",
37 method: "POST",
38 body: { source: "oxinion" },
39 },
40});
41
42// List all nodes in the pipeline
43const { nodes } = await oxinion.nodes.list("pipe_abc");
44console.log(`${nodes.length} nodes configured`);