@askdialog/dialog-vue 1.0.2 → 1.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 +5 -53
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,9 +31,7 @@ pnpm add @askdialog/dialog-vue
|
|
|
31
31
|
yarn add @askdialog/dialog-vue
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
###
|
|
35
|
-
|
|
36
|
-
#### Instantiate the client
|
|
34
|
+
### Instantiate the client
|
|
37
35
|
|
|
38
36
|
```typescript
|
|
39
37
|
import { Dialog } from '@dialog/dialog-sdk';
|
|
@@ -48,59 +46,13 @@ const client = new Dialog({
|
|
|
48
46
|
});
|
|
49
47
|
```
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
### Use DialogProductBlock component
|
|
52
50
|
|
|
53
|
-
|
|
51
|
+
```html
|
|
54
52
|
<DialogProductBlock
|
|
55
53
|
:client="client"
|
|
56
|
-
product-id="
|
|
54
|
+
product-id="Product identifier"
|
|
57
55
|
product-title="Product Title"
|
|
58
|
-
selected-variant-id="
|
|
56
|
+
selected-variant-id="Variant identifier"
|
|
59
57
|
/>
|
|
60
|
-
``` ### Features - Send a message with context ```typescript
|
|
61
|
-
client.sendProductMessage({ question: 'YOUR_QUESTION', // required productId:
|
|
62
|
-
'PRODUCT_ID', // required productTitle: 'PRODUCT_TITLE', // required answer: '',
|
|
63
|
-
// Optional selectedVariantId: 'CURRENT_VARIANT_ID', // Optional });
|
|
64
|
-
````
|
|
65
|
-
|
|
66
|
-
- Send message without context
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
client.sendGenericMessage({
|
|
70
|
-
question: 'YOUR_QUESTION', // required
|
|
71
|
-
});
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
- Handler for fetch product
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
const client = new Dialog({
|
|
78
|
-
...,
|
|
79
|
-
callbacks: {
|
|
80
|
-
getProduct: () => {
|
|
81
|
-
// Call your api to retrieve product information
|
|
82
|
-
const response = await fetch('....');
|
|
83
|
-
const data = await response.json();
|
|
84
|
-
// To define
|
|
85
|
-
return {};
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
- Handler for add to cart
|
|
92
|
-
|
|
93
|
-
```typescript
|
|
94
|
-
const client = new Dialog({
|
|
95
|
-
...,
|
|
96
|
-
callbacks: {
|
|
97
|
-
addToCart: () => {
|
|
98
|
-
// Call your api to trigger addToCart
|
|
99
|
-
const response = await fetch('....');
|
|
100
|
-
|
|
101
|
-
// Trigger other stuff like confirmation modal
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
58
|
```
|