sociova 1.1.2 → 1.2.3
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 +127 -0
- package/dist/client.d.ts +13 -1
- package/dist/client.js +60 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Sociova
|
|
2
|
+
|
|
3
|
+
> Powerful Instagram Automation SDK for Node.js
|
|
4
|
+
|
|
5
|
+
Sociova is a developer-first Node.js SDK that simplifies working with
|
|
6
|
+
the Instagram Graph API. No more handling headers, access tokens, or raw
|
|
7
|
+
HTTP requests just install, initialize, and start sending messages.
|
|
8
|
+
|
|
9
|
+
------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- ✅ Simple client initialization
|
|
14
|
+
- ✅ Send text messages
|
|
15
|
+
- ✅ Send generic templates (cards, buttons, links)
|
|
16
|
+
- ✅ Built-in queue support
|
|
17
|
+
- ✅ Optional AI automation (Gemini-powered)
|
|
18
|
+
- ✅ Webhook ready
|
|
19
|
+
- ✅ Secure token-based authentication
|
|
20
|
+
- ✅ Works with Node.js, Express, Next.js
|
|
21
|
+
|
|
22
|
+
------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
``` bash
|
|
27
|
+
npm install sociova
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
## ⚡ Quick Start
|
|
34
|
+
|
|
35
|
+
### 1 Initialize Client
|
|
36
|
+
|
|
37
|
+
``` ts
|
|
38
|
+
import { InstaClient } from "sociova";
|
|
39
|
+
|
|
40
|
+
const client = new InstaClient({
|
|
41
|
+
auth: process.env.AUTH_TOKEN!,
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
### 2️ Send a Text Message
|
|
48
|
+
|
|
49
|
+
``` ts
|
|
50
|
+
await client.sendTextMessage({
|
|
51
|
+
recipientId: "INSTAGRAM_USER_ID",
|
|
52
|
+
message: "Hello from Sociova 🚀",
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
------------------------------------------------------------------------
|
|
57
|
+
|
|
58
|
+
### 3️ Send Generic Template
|
|
59
|
+
|
|
60
|
+
``` ts
|
|
61
|
+
await client.sendGenericTemplate({
|
|
62
|
+
recipientId: "INSTAGRAM_USER_ID",
|
|
63
|
+
elements: [
|
|
64
|
+
{
|
|
65
|
+
title: "Sociova Demo",
|
|
66
|
+
image_url: "https://example.com/image.jpg",
|
|
67
|
+
subtitle: "Instagram Automation Made Easy",
|
|
68
|
+
default_action: {
|
|
69
|
+
type: "web_url",
|
|
70
|
+
url: "https://yourwebsite.com",
|
|
71
|
+
},
|
|
72
|
+
buttons: [
|
|
73
|
+
{
|
|
74
|
+
type: "web_url",
|
|
75
|
+
url: "https://yourwebsite.com",
|
|
76
|
+
title: "Visit Website",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: "postback",
|
|
80
|
+
title: "Get Started",
|
|
81
|
+
payload: "GET_STARTED",
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
------------------------------------------------------------------------
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## Webhook Example (Express)
|
|
94
|
+
|
|
95
|
+
``` ts
|
|
96
|
+
import express from "express";
|
|
97
|
+
|
|
98
|
+
const app = express();
|
|
99
|
+
app.use(express.json());
|
|
100
|
+
|
|
101
|
+
app.post("/webhooks/instagram", (req, res) => {
|
|
102
|
+
res.sendStatus(200);
|
|
103
|
+
console.log("Incoming Event:", req.body);
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
## Roadmap
|
|
110
|
+
|
|
111
|
+
- Advanced campaign builder
|
|
112
|
+
- Analytics dashboard
|
|
113
|
+
- Multi-account support
|
|
114
|
+
- SaaS billing integration
|
|
115
|
+
- Developer dashboard
|
|
116
|
+
|
|
117
|
+
------------------------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT
|
|
122
|
+
|
|
123
|
+
------------------------------------------------------------------------
|
|
124
|
+
|
|
125
|
+
## Author
|
|
126
|
+
|
|
127
|
+
Built with ❤️ by Eklavya
|
package/dist/client.d.ts
CHANGED
|
@@ -113,6 +113,15 @@ export type SendGenericTemplatePayload = {
|
|
|
113
113
|
|
|
114
114
|
export type SendGenericTemplateResponse = Record<string, any>;
|
|
115
115
|
|
|
116
|
+
export interface MediaResponse {
|
|
117
|
+
id: string;
|
|
118
|
+
status?: string;
|
|
119
|
+
[key: string]: any; // in case Instagram returns extra fields
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface PublishPostResumePayload {
|
|
123
|
+
creation_id: string;
|
|
124
|
+
}
|
|
116
125
|
export declare class InstaClient {
|
|
117
126
|
Config: {
|
|
118
127
|
auth: string;
|
|
@@ -133,4 +142,7 @@ export declare class InstaClient {
|
|
|
133
142
|
sendButtonTemplate(payload: SendButtonTemplatePayload): Promise<SendButtonTemplateResponse>;
|
|
134
143
|
sendPublishedPosts(payload: SendMediaPayload): Promise<SendMediaResponse>;
|
|
135
144
|
sendGenericTemplate(payload: SendGenericTemplatePayload): Promise<SendGenericTemplateResponse>;
|
|
136
|
-
|
|
145
|
+
directPublishPost(payload: DirectPublishPayload): Promise<MediaResponse>;
|
|
146
|
+
createMedia(payload: DirectPublishPayload): Promise<MediaResponse>;
|
|
147
|
+
publishPostResume(payload: PublishPostResumePayload): Promise<MediaResponse>;
|
|
148
|
+
}
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AUTHENTICATED_USER, INSTAGRAM_BASE_URL } from "./route";
|
|
1
|
+
import { AUTHENTICATED_USER, INSTAGRAM_BASE_URL } from "./route.js";
|
|
2
2
|
|
|
3
3
|
export class InstaClient{
|
|
4
4
|
constructor({ auth}){
|
|
@@ -187,5 +187,63 @@ async sendGenericTemplate( payload) {
|
|
|
187
187
|
|
|
188
188
|
return await res.json();
|
|
189
189
|
}
|
|
190
|
+
// PUBLISHING POSTS
|
|
191
|
+
async directPublishPost(payload){
|
|
192
|
+
const url = `${INSTAGRAM_BASE_URL}/26338849465738403/media`;
|
|
193
|
+
const res = await fetch(url, {
|
|
194
|
+
method: "POST",
|
|
195
|
+
headers: {
|
|
196
|
+
Authorization: `Bearer ${this.Config.auth}`,
|
|
197
|
+
"Content-Type": "application/json",
|
|
198
|
+
},
|
|
199
|
+
body: JSON.stringify({
|
|
200
|
+
"caption":payload.caption,
|
|
201
|
+
"image_url":payload.image_url
|
|
202
|
+
}),
|
|
203
|
+
});
|
|
204
|
+
const data = await res.json()
|
|
205
|
+
const check = await this.publishPostResume({
|
|
206
|
+
|
|
207
|
+
creation_id: await data.id
|
|
208
|
+
})
|
|
209
|
+
return await check
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Not direct
|
|
213
|
+
async createMedia(payload){
|
|
214
|
+
const url = `${INSTAGRAM_BASE_URL}/26338849465738403/media`;
|
|
215
|
+
const res = await fetch(url, {
|
|
216
|
+
method: "POST",
|
|
217
|
+
headers: {
|
|
218
|
+
Authorization: `Bearer ${this.Config.auth}`,
|
|
219
|
+
"Content-Type": "application/json",
|
|
220
|
+
},
|
|
221
|
+
body: JSON.stringify({
|
|
222
|
+
"caption":payload.caption,
|
|
223
|
+
"image_url":payload.image_url
|
|
224
|
+
}),
|
|
225
|
+
});
|
|
226
|
+
const data = await res.json()
|
|
227
|
+
return data
|
|
228
|
+
}
|
|
229
|
+
async publishPostResume(payload){
|
|
230
|
+
const url = `${INSTAGRAM_BASE_URL}/26338849465738403/media_publish`;
|
|
231
|
+
const res = await fetch(url, {
|
|
232
|
+
method: "POST",
|
|
233
|
+
headers: {
|
|
234
|
+
Authorization: `Bearer ${this.Config.auth}`,
|
|
235
|
+
"Content-Type": "application/json",
|
|
236
|
+
},
|
|
237
|
+
body: JSON.stringify({
|
|
238
|
+
"creation_id":payload.creation_id
|
|
239
|
+
}),
|
|
240
|
+
});
|
|
241
|
+
return await res.json()
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
|
|
190
249
|
|
|
191
|
-
}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./client"
|
|
1
|
+
export * from "./client"
|