@contenify/chatbot 4.0.1 → 4.0.2

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