@contenify/chatbot 2.0.0 → 3.0.0
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 +202 -48
- package/dist/index.js +527 -354
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +533 -360
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +110 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
# @contenify/chatbot
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
It helps visitors understand your product, navigate pages, and get answers instantly — directly inside your interface.
|
|
6
|
-
The widget integrates in minutes and works as a 24/7 automated guide for your users.
|
|
3
|
+
AI-powered news chatbot widget for React applications. Embed an intelligent content creation assistant that rewrites news, generates articles, and creates social content — directly inside your app.
|
|
7
4
|
|
|
8
5
|
---
|
|
9
6
|
|
|
@@ -13,102 +10,259 @@ The widget integrates in minutes and works as a 24/7 automated guide for your us
|
|
|
13
10
|
npm install @contenify/chatbot
|
|
14
11
|
```
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Create or update your `.env.local` file:
|
|
13
|
+
```bash
|
|
14
|
+
yarn add @contenify/chatbot
|
|
15
|
+
```
|
|
21
16
|
|
|
22
|
-
```
|
|
23
|
-
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @contenify/chatbot
|
|
24
19
|
```
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
> **Peer dependencies:** Requires `react >= 18` and `react-dom >= 18`.
|
|
27
22
|
|
|
28
23
|
---
|
|
29
24
|
|
|
30
|
-
##
|
|
25
|
+
## Quick Start
|
|
31
26
|
|
|
32
|
-
### 1. Import the component and
|
|
27
|
+
### 1. Import the component and styles
|
|
33
28
|
|
|
34
29
|
```tsx
|
|
35
30
|
import { ContenifyChatBot } from '@contenify/chatbot'
|
|
36
31
|
import '@contenify/chatbot/styles.css'
|
|
37
32
|
```
|
|
38
33
|
|
|
39
|
-
### 2. Add the
|
|
34
|
+
### 2. Add the chatbot to your app
|
|
40
35
|
|
|
41
36
|
```tsx
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
export default function App() {
|
|
38
|
+
return (
|
|
39
|
+
<ContenifyChatBot
|
|
40
|
+
apiUrl="https://your-api.example.com/api"
|
|
41
|
+
apiKey="YOUR_API_KEY"
|
|
42
|
+
/>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
47
45
|
```
|
|
48
46
|
|
|
49
|
-
The chatbot
|
|
47
|
+
That's it. The chatbot renders a full-featured AI news assistant with trending news, article rewriting, and content creation built in.
|
|
50
48
|
|
|
51
49
|
---
|
|
52
50
|
|
|
53
51
|
## Props
|
|
54
52
|
|
|
55
|
-
| Prop
|
|
56
|
-
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
53
|
+
| Prop | Type | Required | Description |
|
|
54
|
+
|------|------|----------|-------------|
|
|
55
|
+
| `apiUrl` | `string` | Yes | Base URL of your Contenify backend API (e.g. `https://api.example.com/api`) |
|
|
56
|
+
| `apiKey` | `string` | Yes | Your licence API key |
|
|
57
|
+
| `domain` | `string` | No | Domain identifier for multi-tenant setups |
|
|
58
|
+
| `onPost` | `(content: string, keywords: string[]) => void` | No | Callback fired when the user clicks **Post** on a generated article. Receives the HTML content and meta keywords. |
|
|
59
59
|
|
|
60
60
|
---
|
|
61
61
|
|
|
62
|
-
##
|
|
62
|
+
## Usage Examples
|
|
63
|
+
|
|
64
|
+
### Basic embed
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { ContenifyChatBot } from '@contenify/chatbot'
|
|
68
|
+
import '@contenify/chatbot/styles.css'
|
|
69
|
+
|
|
70
|
+
export default function Page() {
|
|
71
|
+
return (
|
|
72
|
+
<div style={{ height: '100vh' }}>
|
|
73
|
+
<ContenifyChatBot
|
|
74
|
+
apiUrl="https://api.example.com/api"
|
|
75
|
+
apiKey="LIC-XXXXXX-XXXXXX"
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### With `onPost` callback
|
|
83
|
+
|
|
84
|
+
Handle articles when the user clicks **Post** — publish to your CMS, save to a database, or trigger any workflow:
|
|
63
85
|
|
|
64
|
-
|
|
86
|
+
```tsx
|
|
87
|
+
import { ContenifyChatBot } from '@contenify/chatbot'
|
|
88
|
+
import '@contenify/chatbot/styles.css'
|
|
65
89
|
|
|
66
|
-
|
|
67
|
-
|
|
90
|
+
export default function Page() {
|
|
91
|
+
const handlePost = (content: string, keywords: string[]) => {
|
|
92
|
+
// content is an HTML string, keywords is string[]
|
|
93
|
+
console.log('Article HTML:', content)
|
|
94
|
+
console.log('Keywords:', keywords)
|
|
68
95
|
|
|
69
|
-
|
|
96
|
+
// Example: POST to your CMS
|
|
97
|
+
fetch('/api/articles', {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers: { 'Content-Type': 'application/json' },
|
|
100
|
+
body: JSON.stringify({ content, keywords }),
|
|
101
|
+
})
|
|
102
|
+
}
|
|
70
103
|
|
|
71
|
-
|
|
104
|
+
return (
|
|
105
|
+
<ContenifyChatBot
|
|
106
|
+
apiUrl="https://api.example.com/api"
|
|
107
|
+
apiKey="LIC-XXXXXX-XXXXXX"
|
|
108
|
+
onPost={handlePost}
|
|
109
|
+
/>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
```
|
|
72
113
|
|
|
73
|
-
|
|
114
|
+
### Next.js App Router
|
|
115
|
+
|
|
116
|
+
Because the chatbot uses client-side hooks, wrap it in a client component:
|
|
74
117
|
|
|
75
118
|
```tsx
|
|
119
|
+
// components/ChatbotWrapper.tsx
|
|
76
120
|
'use client'
|
|
77
121
|
|
|
78
|
-
import { useRouter } from 'next/navigation'
|
|
79
122
|
import { ContenifyChatBot } from '@contenify/chatbot'
|
|
80
123
|
import '@contenify/chatbot/styles.css'
|
|
81
124
|
|
|
82
|
-
export default function
|
|
83
|
-
const router = useRouter()
|
|
84
|
-
|
|
125
|
+
export default function ChatbotWrapper() {
|
|
85
126
|
return (
|
|
86
127
|
<ContenifyChatBot
|
|
87
|
-
|
|
88
|
-
|
|
128
|
+
apiUrl={process.env.NEXT_PUBLIC_API_URL!}
|
|
129
|
+
apiKey={process.env.NEXT_PUBLIC_API_KEY!}
|
|
130
|
+
onPost={(content, keywords) => {
|
|
131
|
+
console.log('Post triggered', { content, keywords })
|
|
132
|
+
}}
|
|
89
133
|
/>
|
|
90
134
|
)
|
|
91
135
|
}
|
|
92
136
|
```
|
|
93
137
|
|
|
138
|
+
```tsx
|
|
139
|
+
// app/layout.tsx (or app/page.tsx)
|
|
140
|
+
import ChatbotWrapper from '@/components/ChatbotWrapper'
|
|
141
|
+
|
|
142
|
+
export default function Layout({ children }: { children: React.ReactNode }) {
|
|
143
|
+
return (
|
|
144
|
+
<html>
|
|
145
|
+
<body>
|
|
146
|
+
{children}
|
|
147
|
+
<ChatbotWrapper />
|
|
148
|
+
</body>
|
|
149
|
+
</html>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Using `setConfig` (configure once at startup)
|
|
155
|
+
|
|
156
|
+
If you prefer to configure the package once at app startup instead of passing props each time:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
// app/providers.tsx (or _app.tsx)
|
|
160
|
+
'use client'
|
|
161
|
+
|
|
162
|
+
import { setConfig, ContenifyChatBot } from '@contenify/chatbot'
|
|
163
|
+
import '@contenify/chatbot/styles.css'
|
|
164
|
+
|
|
165
|
+
setConfig({
|
|
166
|
+
apiUrl: 'https://api.example.com/api',
|
|
167
|
+
apiKey: 'LIC-XXXXXX-XXXXXX',
|
|
168
|
+
domain: 'my-site',
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
export default function ChatProvider() {
|
|
172
|
+
return <ContenifyChatBot />
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
94
176
|
---
|
|
95
177
|
|
|
96
|
-
##
|
|
178
|
+
## Features
|
|
97
179
|
|
|
98
|
-
|
|
99
|
-
|
|
180
|
+
| Feature | Description |
|
|
181
|
+
|---------|-------------|
|
|
182
|
+
| **AI Article Rewriting** | Paste or type a news story — the AI rewrites it in your preferred tone, style, and language |
|
|
183
|
+
| **Trending News Panel** | Browse and recreate trending news articles from multiple sources |
|
|
184
|
+
| **Multi-language Support** | Generate content in English, Hindi, and more via preferences |
|
|
185
|
+
| **Edit Before Posting** | Built-in rich text editor with separate Title, Subtitle, Slug, Meta Description, and Keywords fields |
|
|
186
|
+
| **Streaming Output** | Articles stream token-by-token for a fast, real-time writing experience |
|
|
187
|
+
| **URL Analysis** | Paste any article URL — the chatbot scrapes and offers actions: recreate, summarise, create social posts, newsletter, blog post, and more |
|
|
188
|
+
| **Preferences** | Tone, style, word count, target audience, include quotes/FAQ — all configurable per user |
|
|
100
189
|
|
|
101
190
|
---
|
|
102
191
|
|
|
103
|
-
##
|
|
192
|
+
## TypeScript
|
|
193
|
+
|
|
194
|
+
All props and types are exported:
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
import type {
|
|
198
|
+
ContenifyChatBotProps,
|
|
199
|
+
Preferences,
|
|
200
|
+
ChatbotPreferences,
|
|
201
|
+
LocalizationPreferences,
|
|
202
|
+
AppearancePreferences,
|
|
203
|
+
ContentPreferences,
|
|
204
|
+
ContentOption,
|
|
205
|
+
AnalyzeInputResponse,
|
|
206
|
+
CreateContentPayload,
|
|
207
|
+
RecreateSettings,
|
|
208
|
+
} from '@contenify/chatbot'
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Key types
|
|
104
212
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
213
|
+
```ts
|
|
214
|
+
interface ContenifyChatBotProps {
|
|
215
|
+
apiUrl?: string
|
|
216
|
+
apiKey?: string
|
|
217
|
+
domain?: string
|
|
218
|
+
onPost?: (content: string, keywords: string[]) => void
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
interface ContentPreferences {
|
|
222
|
+
tone: 'formal' | 'casual' | 'engaging' | 'professional'
|
|
223
|
+
style: 'news' | 'blog' | 'editorial' | 'summary'
|
|
224
|
+
wordCount: 'short' | 'medium' | 'long'
|
|
225
|
+
includeQuotes: boolean
|
|
226
|
+
includeFAQ: boolean
|
|
227
|
+
targetAudience: string
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
interface LocalizationPreferences {
|
|
231
|
+
country: string
|
|
232
|
+
state: string
|
|
233
|
+
cities: string[]
|
|
234
|
+
language: string // e.g. 'en', 'hi'
|
|
235
|
+
locale: string
|
|
236
|
+
timezone: string
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
interface ChatbotPreferences {
|
|
240
|
+
name: string
|
|
241
|
+
logoUrl?: string
|
|
242
|
+
primaryColor: string // hex, e.g. '#6366f1'
|
|
243
|
+
secondaryColor: string
|
|
244
|
+
theme: 'light' | 'dark' | 'system'
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Environment Variables
|
|
251
|
+
|
|
252
|
+
When running the development app locally, create a `.env.local` file:
|
|
253
|
+
|
|
254
|
+
```env
|
|
255
|
+
NEXT_PUBLIC_CONTENIFY_API_URL=http://localhost:8080/api
|
|
256
|
+
NEXT_PUBLIC_API_KEY=YOUR_API_KEY
|
|
257
|
+
NEXT_PUBLIC_DOMAIN=
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Requirements
|
|
110
263
|
|
|
111
|
-
|
|
264
|
+
- React 18+
|
|
265
|
+
- A running Contenify backend with a valid API key
|
|
112
266
|
|
|
113
267
|
---
|
|
114
268
|
|