@asgard-js/react 0.2.7-canary.1 → 0.2.7

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.
Files changed (2) hide show
  1. package/README.md +38 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -846,6 +846,44 @@ interface MessageContentRendererProps {
846
846
  }
847
847
  ```
848
848
 
849
+ #### Why MessageContainer?
850
+
851
+ When you use `renderMessageContent` to customize rendering, it completely replaces the default Template. This means **Avatar will not display automatically**, because Avatar is part of the default Template.
852
+
853
+ Use `MessageContainer` to wrap your custom content and automatically get:
854
+
855
+ - **Bot messages**: Avatar + timestamp
856
+ - **User messages**: Proper right-aligned styling
857
+
858
+ #### Understanding payload
859
+
860
+ The `payload` is custom data set by the backend Bot Provider when responding to messages. The SDK passes it directly to `renderMessageContent` without modification.
861
+
862
+ **Backend response example (Bot Provider):**
863
+
864
+ ```json
865
+ {
866
+ "template": { "type": "text", "text": "Here is your order" },
867
+ "payload": {
868
+ "customType": "order_card",
869
+ "orderId": "#ORD-2024-001234",
870
+ "items": [{ "name": "iPhone 15 Pro", "price": 42900 }]
871
+ }
872
+ }
873
+ ```
874
+
875
+ **Frontend renders based on payload:**
876
+
877
+ ```typescript
878
+ const payload = message.message.payload as { customType?: string };
879
+
880
+ if (payload?.customType === 'order_card') {
881
+ return <OrderCard order={payload} />;
882
+ }
883
+ ```
884
+
885
+ > **Note:** `customType` is a convention, not a requirement. You can define your own payload structure - just ensure the frontend and backend use the same format.
886
+
849
887
  #### Basic Usage
850
888
 
851
889
  ```typescript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgard-js/react",
3
- "version": "0.2.7-canary.1",
3
+ "version": "0.2.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -42,7 +42,7 @@
42
42
  "vite-plugin-svgr": "^4.3.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@asgard-js/core": "^0.2.7-canary.1",
45
+ "@asgard-js/core": "^0.2.7",
46
46
  "react": "^18.0.0 || ^19.0.0",
47
47
  "react-dom": "^18.0.0 || ^19.0.0"
48
48
  }