@contenify/chatbot 4.0.1 → 4.0.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 +232 -69
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,121 +1,163 @@
|
|
|
1
1
|
# @contenify/chatbot
|
|
2
|
+
# The package is currently under development. Full release coming soon.
|
|
2
3
|
|
|
3
|
-
AI-powered
|
|
4
|
+
An AI-powered content creation widget. Drop it into any React app and your users can paste a news URL or topic, get a fully rewritten article, run SEO analysis, and export or publish — all from one chat interface.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
1. [Prerequisites](#1-prerequisites)
|
|
11
|
+
2. [Installation](#2-installation)
|
|
12
|
+
3. [Get Your API Key](#3-get-your-api-key)
|
|
13
|
+
4. [Set Up Environment Variables](#4-set-up-environment-variables)
|
|
14
|
+
5. [Add the Component](#5-add-the-component)
|
|
15
|
+
6. [Next.js Setup](#6-nextjs-setup)
|
|
16
|
+
7. [Receive Published Articles](#7-receive-published-articles)
|
|
17
|
+
8. [Props Reference](#8-props-reference)
|
|
18
|
+
9. [Update Config at Runtime](#9-update-config-at-runtime)
|
|
19
|
+
10. [What the Widget Can Do](#10-what-the-widget-can-do)
|
|
20
|
+
11. [Troubleshooting](#11-troubleshooting)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 1. Prerequisites
|
|
25
|
+
|
|
26
|
+
- React **18** or higher
|
|
27
|
+
- A Contenify API key (see [Step 3](#3-get-your-api-key))
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 2. Installation
|
|
6
32
|
|
|
7
33
|
```bash
|
|
8
34
|
npm install @contenify/chatbot
|
|
9
35
|
# or
|
|
10
36
|
yarn add @contenify/chatbot
|
|
37
|
+
# or
|
|
38
|
+
pnpm add @contenify/chatbot
|
|
11
39
|
```
|
|
12
40
|
|
|
13
|
-
|
|
41
|
+
---
|
|
14
42
|
|
|
15
|
-
|
|
16
|
-
import { ContenifyChatBot } from '@contenify/chatbot'
|
|
17
|
-
import '@contenify/chatbot/styles.css'
|
|
43
|
+
## 3. Get Your API Key
|
|
18
44
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
apiUrl="https://your-backend.com/api"
|
|
23
|
-
apiKey="your-api-key"
|
|
24
|
-
/>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
```
|
|
45
|
+
1. Go to [contenifyai.com/api-docs(https://contenifyai.com/api-docs)
|
|
46
|
+
2. Create a new API key
|
|
47
|
+
3. Copy the key — you will need it in the next step
|
|
28
48
|
|
|
29
|
-
|
|
49
|
+
---
|
|
30
50
|
|
|
31
|
-
|
|
32
|
-
|------|------|----------|-------------|
|
|
33
|
-
| `apiUrl` | `string` | No | Base URL of your Contenify backend API. Defaults to `NEXT_PUBLIC_CONTENIFY_API_URL` env var. |
|
|
34
|
-
| `apiKey` | `string` | No | Your subscription API key. Defaults to `NEXT_PUBLIC_API_KEY` env var. |
|
|
35
|
-
| `domain` | `string` | No | Your site domain, used for source filtering. |
|
|
36
|
-
| `onPost` | `(article: string, keywords: string[]) => void` | No | Called when the user clicks **Post** in the editor. Receives the article HTML and meta keywords. |
|
|
51
|
+
## 4. Set Up Environment Variables
|
|
37
52
|
|
|
38
|
-
|
|
53
|
+
Create a `.env` file in the root of your project (or add to your existing one):
|
|
39
54
|
|
|
40
55
|
```env
|
|
41
|
-
NEXT_PUBLIC_CONTENIFY_API_URL=https://
|
|
42
|
-
NEXT_PUBLIC_API_KEY=your-api-key
|
|
56
|
+
NEXT_PUBLIC_CONTENIFY_API_URL=https://api.contenifyai.cloud/api
|
|
57
|
+
NEXT_PUBLIC_API_KEY=your-api-key-here
|
|
43
58
|
NEXT_PUBLIC_CONTENIFY_DOMAIN=yourdomain.com
|
|
44
59
|
```
|
|
45
60
|
|
|
46
|
-
|
|
61
|
+
| Variable | Required | Description |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| `NEXT_PUBLIC_CONTENIFY_API_URL` | Yes | The Contenify backend URL |
|
|
64
|
+
| `NEXT_PUBLIC_API_KEY` | Yes | Your API key from Step 3 |
|
|
65
|
+
| `NEXT_PUBLIC_CONTENIFY_DOMAIN` | No | Your site domain, used for news source filtering |
|
|
66
|
+
|
|
67
|
+
> The widget reads these variables automatically. You do not need to pass them as props unless you want to override them per instance.
|
|
47
68
|
|
|
48
|
-
|
|
69
|
+
---
|
|
49
70
|
|
|
50
|
-
|
|
71
|
+
## 5. Add the Component
|
|
72
|
+
|
|
73
|
+
Import the component and its styles, then place it anywhere in your app:
|
|
51
74
|
|
|
52
75
|
```tsx
|
|
76
|
+
import { ContenifyChatBot } from '@contenify/chatbot'
|
|
53
77
|
import '@contenify/chatbot/styles.css'
|
|
78
|
+
|
|
79
|
+
export default function App() {
|
|
80
|
+
return <ContenifyChatBot />
|
|
81
|
+
}
|
|
54
82
|
```
|
|
55
83
|
|
|
56
|
-
|
|
84
|
+
That's it. The widget picks up `NEXT_PUBLIC_CONTENIFY_API_URL` and `NEXT_PUBLIC_API_KEY` from your environment automatically.
|
|
57
85
|
|
|
58
|
-
|
|
86
|
+
---
|
|
59
87
|
|
|
60
|
-
|
|
61
|
-
window.addEventListener('contenify-post-article', (e: Event) => {
|
|
62
|
-
const { title, subtitle, article, metaDescription, slug, keywords, featuredImage } = (e as CustomEvent).detail
|
|
88
|
+
## 6. Next.js Setup
|
|
63
89
|
|
|
64
|
-
|
|
65
|
-
await myApi.publish({ title, article, keywords })
|
|
66
|
-
})
|
|
67
|
-
```
|
|
90
|
+
### App Router (recommended)
|
|
68
91
|
|
|
69
|
-
|
|
92
|
+
The widget uses React hooks internally so it must run on the client. Create a wrapper component:
|
|
70
93
|
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
subtitle: string
|
|
75
|
-
article: string // Rich HTML content
|
|
76
|
-
metaDescription: string
|
|
77
|
-
slug: string // Auto-generated from title, user-editable
|
|
78
|
-
keywords: string[] // Meta keywords array
|
|
79
|
-
featuredImage?: string // URL of featured image (if present)
|
|
80
|
-
}
|
|
81
|
-
```
|
|
94
|
+
```tsx
|
|
95
|
+
// app/components/ContentEditor.tsx
|
|
96
|
+
'use client'
|
|
82
97
|
|
|
83
|
-
|
|
98
|
+
import { ContenifyChatBot } from '@contenify/chatbot'
|
|
99
|
+
import '@contenify/chatbot/styles.css'
|
|
84
100
|
|
|
85
|
-
|
|
101
|
+
export default function ContentEditor() {
|
|
102
|
+
return <ContenifyChatBot />
|
|
103
|
+
}
|
|
104
|
+
```
|
|
86
105
|
|
|
87
|
-
|
|
106
|
+
Then use it in any Server Component or page:
|
|
88
107
|
|
|
89
|
-
```
|
|
90
|
-
|
|
108
|
+
```tsx
|
|
109
|
+
// app/page.tsx
|
|
110
|
+
import ContentEditor from './components/ContentEditor'
|
|
91
111
|
|
|
92
|
-
|
|
112
|
+
export default function Page() {
|
|
113
|
+
return (
|
|
114
|
+
<main>
|
|
115
|
+
<ContentEditor />
|
|
116
|
+
</main>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
93
119
|
```
|
|
94
120
|
|
|
95
|
-
|
|
121
|
+
### Pages Router
|
|
96
122
|
|
|
97
|
-
|
|
123
|
+
No wrapper needed — just import and use directly:
|
|
98
124
|
|
|
99
125
|
```tsx
|
|
100
|
-
//
|
|
101
|
-
'use client'
|
|
126
|
+
// pages/editor.tsx
|
|
102
127
|
import { ContenifyChatBot } from '@contenify/chatbot'
|
|
103
128
|
import '@contenify/chatbot/styles.css'
|
|
104
129
|
|
|
105
|
-
export default function
|
|
106
|
-
return <ContenifyChatBot
|
|
130
|
+
export default function EditorPage() {
|
|
131
|
+
return <ContenifyChatBot />
|
|
107
132
|
}
|
|
108
133
|
```
|
|
109
134
|
|
|
110
|
-
|
|
135
|
+
### Import styles globally (optional)
|
|
136
|
+
|
|
137
|
+
Instead of importing styles in every file, add it once to `app/layout.tsx` or `pages/_app.tsx`:
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
// app/layout.tsx
|
|
141
|
+
import '@contenify/chatbot/styles.css'
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 7. Receive Published Articles
|
|
147
|
+
|
|
148
|
+
When a user clicks **Post** inside the editor, you can receive the article data in two ways:
|
|
149
|
+
|
|
150
|
+
### Option A — `onPost` prop
|
|
111
151
|
|
|
112
152
|
```tsx
|
|
113
153
|
'use client'
|
|
154
|
+
|
|
114
155
|
import { ContenifyChatBot } from '@contenify/chatbot'
|
|
115
156
|
import '@contenify/chatbot/styles.css'
|
|
116
157
|
|
|
117
158
|
export default function Editor() {
|
|
118
159
|
const handlePost = async (article: string, keywords: string[]) => {
|
|
160
|
+
// Send the article to your own API or CMS
|
|
119
161
|
await fetch('/api/publish', {
|
|
120
162
|
method: 'POST',
|
|
121
163
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -123,16 +165,137 @@ export default function Editor() {
|
|
|
123
165
|
})
|
|
124
166
|
}
|
|
125
167
|
|
|
126
|
-
return
|
|
127
|
-
<ContenifyChatBot
|
|
128
|
-
apiUrl={process.env.NEXT_PUBLIC_CONTENIFY_API_URL}
|
|
129
|
-
apiKey={process.env.NEXT_PUBLIC_API_KEY}
|
|
130
|
-
onPost={handlePost}
|
|
131
|
-
/>
|
|
132
|
-
)
|
|
168
|
+
return <ContenifyChatBot onPost={handlePost} />
|
|
133
169
|
}
|
|
134
170
|
```
|
|
135
171
|
|
|
172
|
+
### Option B — DOM event listener
|
|
173
|
+
|
|
174
|
+
Listen for the `contenify-post-article` event on `window`. This is useful when you need to handle publishing outside of the React component tree:
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
window.addEventListener('contenify-post-article', (e: Event) => {
|
|
178
|
+
const detail = (e as CustomEvent).detail
|
|
179
|
+
|
|
180
|
+
console.log(detail.title) // Article title
|
|
181
|
+
console.log(detail.subtitle) // Subtitle
|
|
182
|
+
console.log(detail.article) // Full HTML content
|
|
183
|
+
console.log(detail.metaDescription) // Meta description
|
|
184
|
+
console.log(detail.slug) // URL slug (auto-generated, user-editable)
|
|
185
|
+
console.log(detail.keywords) // string[] of meta keywords
|
|
186
|
+
console.log(detail.featuredImage) // Image URL (if present)
|
|
187
|
+
})
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## 8. Props Reference
|
|
193
|
+
|
|
194
|
+
All props are optional. The widget works out of the box using environment variables.
|
|
195
|
+
|
|
196
|
+
| Prop | Type | Description |
|
|
197
|
+
|---|---|---|
|
|
198
|
+
| `apiUrl` | `string` | Override the API base URL. Defaults to `NEXT_PUBLIC_CONTENIFY_API_URL`. |
|
|
199
|
+
| `apiKey` | `string` | Override the API key. Defaults to `NEXT_PUBLIC_API_KEY`. |
|
|
200
|
+
| `domain` | `string` | Override the domain. Defaults to `NEXT_PUBLIC_CONTENIFY_DOMAIN`. |
|
|
201
|
+
| `onPost` | `(article: string, keywords: string[]) => void` | Called when the user posts an article from the editor. |
|
|
202
|
+
|
|
203
|
+
### Passing props explicitly
|
|
204
|
+
|
|
205
|
+
If you prefer to pass values as props instead of using env vars:
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
<ContenifyChatBot
|
|
209
|
+
apiUrl="https://api.contenifyai.cloud/api"
|
|
210
|
+
apiKey="your-api-key"
|
|
211
|
+
domain="yourdomain.com"
|
|
212
|
+
onPost={(article, keywords) => console.log(article, keywords)}
|
|
213
|
+
/>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Priority order:** explicit prop > environment variable > built-in default.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## 9. Update Config at Runtime
|
|
221
|
+
|
|
222
|
+
Use `setConfig` to update the API URL, key, or domain at any point — for example, after a user logs in:
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
import { setConfig } from '@contenify/chatbot'
|
|
226
|
+
|
|
227
|
+
// After login
|
|
228
|
+
setConfig({ apiKey: 'user-specific-api-key' })
|
|
229
|
+
|
|
230
|
+
// Change environment dynamically
|
|
231
|
+
setConfig({
|
|
232
|
+
apiUrl: 'https://api.contenifyai.cloud/api',
|
|
233
|
+
apiKey: 'new-key',
|
|
234
|
+
domain: 'newdomain.com',
|
|
235
|
+
})
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## 10. What the Widget Can Do
|
|
241
|
+
|
|
242
|
+
**Paste a URL**
|
|
243
|
+
Paste any news article URL into the chat. The widget fetches the content and presents action options.
|
|
244
|
+
|
|
245
|
+
**Available actions on a URL:**
|
|
246
|
+
- Recreate the article
|
|
247
|
+
- Write a blog post
|
|
248
|
+
- Create a summary
|
|
249
|
+
- Generate social media posts
|
|
250
|
+
- Write a newsletter
|
|
251
|
+
- Extract key points
|
|
252
|
+
|
|
253
|
+
**Type a topic**
|
|
254
|
+
Type any topic or text directly and the widget generates an article from scratch.
|
|
255
|
+
|
|
256
|
+
**Article editor features:**
|
|
257
|
+
- Rich text editor with live formatting
|
|
258
|
+
- SEO score with grade (A–F) and recommendations
|
|
259
|
+
- Auto-fix SEO issues with one click
|
|
260
|
+
- Edit title, subtitle, meta description, slug, and keywords
|
|
261
|
+
- Copy to clipboard
|
|
262
|
+
- Download as PDF or DOCX
|
|
263
|
+
- Post directly to your platform via `onPost`
|
|
264
|
+
|
|
265
|
+
**History panel**
|
|
266
|
+
Previously generated articles are saved locally and accessible from the history panel.
|
|
267
|
+
|
|
268
|
+
**News panel**
|
|
269
|
+
Browse trending news and news by source to use as inspiration.
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## 11. Troubleshooting
|
|
274
|
+
|
|
275
|
+
**Widget shows an "Invalid API Key" modal**
|
|
276
|
+
|
|
277
|
+
- Check that `NEXT_PUBLIC_API_KEY` is set in your `.env` file
|
|
278
|
+
- Make sure you restarted your dev server after adding env vars
|
|
279
|
+
- Verify the key is active at [contenify.in/dashboard/api-keys](https://contenify.in/dashboard/api-keys)
|
|
280
|
+
|
|
281
|
+
**Styles are not loading**
|
|
282
|
+
|
|
283
|
+
Make sure you import the stylesheet:
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
import '@contenify/chatbot/styles.css'
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
**"use client" error in Next.js App Router**
|
|
290
|
+
|
|
291
|
+
Wrap the component in a client component as shown in [Step 6](#6-nextjs-setup).
|
|
292
|
+
|
|
293
|
+
**API requests failing (CORS or network errors)**
|
|
294
|
+
|
|
295
|
+
Confirm `NEXT_PUBLIC_CONTENIFY_API_URL` points to the correct backend URL and that the server allows requests from your domain.
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
136
299
|
## License
|
|
137
300
|
|
|
138
301
|
MIT
|
package/dist/index.d.mts
CHANGED
|
@@ -42,6 +42,6 @@ interface ContenifyChatBotProps {
|
|
|
42
42
|
domain?: string;
|
|
43
43
|
onPost?: (content: string, keywords: string[]) => void;
|
|
44
44
|
}
|
|
45
|
-
declare function ContenifyChatBot({ apiUrl, apiKey, domain, onPost }: ContenifyChatBotProps): react_jsx_runtime.JSX.Element;
|
|
45
|
+
declare function ContenifyChatBot({ apiUrl, apiKey, domain, onPost, }: ContenifyChatBotProps): react_jsx_runtime.JSX.Element;
|
|
46
46
|
|
|
47
47
|
export { type AnalyzeInputResponse, ContenifyChatBot, type ContenifyChatBotProps, type ContentOption, type CreateContentPayload, type RecreateSettings, ContenifyChatBot as default, setConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,6 @@ interface ContenifyChatBotProps {
|
|
|
42
42
|
domain?: string;
|
|
43
43
|
onPost?: (content: string, keywords: string[]) => void;
|
|
44
44
|
}
|
|
45
|
-
declare function ContenifyChatBot({ apiUrl, apiKey, domain, onPost }: ContenifyChatBotProps): react_jsx_runtime.JSX.Element;
|
|
45
|
+
declare function ContenifyChatBot({ apiUrl, apiKey, domain, onPost, }: ContenifyChatBotProps): react_jsx_runtime.JSX.Element;
|
|
46
46
|
|
|
47
47
|
export { type AnalyzeInputResponse, ContenifyChatBot, type ContenifyChatBotProps, type ContentOption, type CreateContentPayload, type RecreateSettings, ContenifyChatBot as default, setConfig };
|
package/dist/index.js
CHANGED
|
@@ -2897,7 +2897,12 @@ ${optionsList}` }) : m
|
|
|
2897
2897
|
|
|
2898
2898
|
// src/index.tsx
|
|
2899
2899
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2900
|
-
function ContenifyChatBot({
|
|
2900
|
+
function ContenifyChatBot({
|
|
2901
|
+
apiUrl = process.env.NEXT_PUBLIC_CONTENIFY_API_URL,
|
|
2902
|
+
apiKey = process.env.NEXT_PUBLIC_API_KEY,
|
|
2903
|
+
domain = process.env.NEXT_PUBLIC_CONTENIFY_DOMAIN,
|
|
2904
|
+
onPost
|
|
2905
|
+
}) {
|
|
2901
2906
|
(0, import_react10.useEffect)(() => {
|
|
2902
2907
|
setConfig({ apiUrl, apiKey, domain });
|
|
2903
2908
|
}, [apiUrl, apiKey, domain]);
|