@blumessage/react-chat 1.5.2 → 1.8.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 CHANGED
@@ -122,6 +122,7 @@ function App() {
122
122
  | `emptyStateText` | `string` | `"Start a conversation!"` | Text shown when no messages are present |
123
123
  | `markdown` | `boolean` | `true` | Enable markdown rendering for messages |
124
124
  | `disableAutoScroll` | `boolean` | `false` | Disable automatic scrolling to bottom when new messages arrive |
125
+ | `context` | `Record<string, any>` | - | Arbitrary user context data (name, email, etc.) passed to the AI agent for personalized responses |
125
126
  | **Event Callbacks** |
126
127
  | `onUserMessage` | `(message: Message) => void` | - | Called when user sends message |
127
128
  | `onAssistantMessage` | `(message: Message) => void` | - | Called when assistant responds |
@@ -132,6 +133,25 @@ function App() {
132
133
 
133
134
  ## Advanced Usage Examples
134
135
 
136
+ ### Providing User Context
137
+
138
+ Pass user data to help the AI agent personalize responses:
139
+
140
+ ```tsx
141
+ <BlumessageChat
142
+ apiKey="your-api-key"
143
+ context={{
144
+ name: "John Doe",
145
+ email: "john@example.com",
146
+ plan: "premium",
147
+ userId: 12345,
148
+ tags: ["vip", "early-adopter"],
149
+ }}
150
+ />
151
+ ```
152
+
153
+ The `context` prop accepts any key-value pairs (`Record<string, any>`). Values can be strings, numbers, booleans, arrays, or objects. The context is sent with every message and merged on the server, so you can update it dynamically across the conversation.
154
+
135
155
  ### Dark Theme with Callbacks
136
156
 
137
157
  ```tsx
@@ -237,7 +237,7 @@ primaryColor = "linear-gradient(to right, #3b82f6,rgb(8, 98, 242))",
237
237
  // Help bubble props
238
238
  showHelpBubble = true, helpBubbleMessage = "Have a question? We're here to help!", helpBubbleIcon = 'message-circle-question-mark', helpBubbleIconName, helpBubbleShowAfter = 1, // 1 second
239
239
  helpBubbleHideAfter = 5, // 5 seconds
240
- helpBubbleBackgroundColor = "#000000", }, ref) => {
240
+ helpBubbleBackgroundColor = "#000000", context, }, ref) => {
241
241
  const [isInitialized, setIsInitialized] = (0, react_1.useState)(false);
242
242
  const [error, setError] = (0, react_1.useState)(null);
243
243
  const [messages, setMessages] = (0, react_1.useState)(initialMessages);
@@ -496,6 +496,10 @@ helpBubbleBackgroundColor = "#000000", }, ref) => {
496
496
  if (token) {
497
497
  requestBody.token = token;
498
498
  }
499
+ // Include user context if provided
500
+ if (context && Object.keys(context).length > 0) {
501
+ requestBody.context = context;
502
+ }
499
503
  const response = await fetch('https://api.blumessage.com/api/v1/conversations', {
500
504
  method: 'POST',
501
505
  headers: {
@@ -711,6 +715,10 @@ helpBubbleBackgroundColor = "#000000", }, ref) => {
711
715
  if (token) {
712
716
  requestBody.token = token;
713
717
  }
718
+ // Include user context if provided
719
+ if (context && Object.keys(context).length > 0) {
720
+ requestBody.context = context;
721
+ }
714
722
  const response = await fetch('https://api.blumessage.com/api/v1/conversations', {
715
723
  method: 'POST',
716
724
  headers: {