You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/docs/pages/plug-sdk/methods.mdx
+48-17Lines changed: 48 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,28 @@
1
1
Our PLuG widget SDK is a powerful tool designed to further enhance our widget on your website or application. With our SDK, you can seamlessly integrate our feature-rich widget by empowering you to create a dynamic and personalized user experience. Let's get started.
Calling the `init()` method initializes the PLuG widget on your website. Initializing the PLuG widget is necessary for you to perform any other actions on the PLuG widget SDK.
9
+
-`plugSDK.shutdown()` End the user session which is currently initialized in PLuG widget.
10
+
11
+
-`plugSDK.toggleWidget()` Open/close the chat widget.
12
+
13
+
-`plugSDK.toggleSearchAgent()` Open/close the search agent.
14
+
15
+
-`plugSDK.onEvent()` Perform specific actions based on the payload type received from the PLuG widget.
-`plugSDK.toggleWidget(true, 'create_conversation', {startConversationContent: 'Hi',});` Start a conversation.
20
+
21
+
-`plugSDK.prefillSearchQuery(query:"string")` Prefill the search input of the search agent.
22
+
23
+
## Initialize chat
24
+
25
+
Calling the `init()` method initializes the PLuG chat widget on your website. Initializing the PLuG widget is necessary for you to perform any other actions on the PLuG widget SDK.
16
26
17
27
```jsx
18
28
useEffect(() => {
@@ -26,6 +36,25 @@ useEffect(() => {
26
36
When React is using `Strict` mode, you might get a warning message from `window.plugSDK.init()` being called multiple times. These errors won't impact the installation and functioning of the widget.
27
37
</Callout>
28
38
39
+
## Initialize search
40
+
41
+
Calling the `initSearchAgent()` method initializes the PLuG Search Agent on your website. Initializing search is necessary for you to perform any other actions on the PLuG widget SDK.
42
+
43
+
```jsx
44
+
useEffect(() => {
45
+
window.plugSDK.init({
46
+
app_id:'<your_unique_app_id>',
47
+
disable_plug_chat_window:true,
48
+
});
49
+
50
+
window.plugSDK.onEvent((payload) => {
51
+
if (payload.type==='ON_PLUG_WIDGET_READY') {
52
+
window.plugSDK.initSearchAgent();
53
+
}
54
+
});
55
+
}, []);
56
+
```
57
+
29
58
## Shutdown the widget
30
59
31
60
The `shutdown()` method is helpful when you want to end the user session which is currently initialized in the PLuG widget. You can use this method to clear your users' conversations and tickets when they log out of your application.
@@ -49,10 +78,11 @@ Once the `shutdown()` method is called, all the other functionality in the widge
49
78
50
79
## Open or close the widget
51
80
52
-
To control whether the PLuG widget launcher screen is open, you can use the `togglewidget()` method with a boolean value. Your code needs to listen to the event `ON_PLUG_WIDGET_READY` to call this method. If the widget isn't ready then this method won’t make any action.
81
+
To control whether the PLuG widget launcher screen is open, you should use either the `togglewidget()` method with a boolean value or the `toggleSearchAgent()`method, depending on which PLuG instance you are using.
|`ON_PLUG_WIDGET_CLOSED`| The PLuG widget is closed. |
72
-
|`ON_PLUG_WIDGET_OPENED`| The PLuG widget is opened. |
73
-
|`ON_PLUG_WIDGET_READY`| The PLuG widget is ready. |
74
-
|`ON_PLUG_WIDGET_UNREAD_COUNT_CHANGE`| The user receives a new message to their PLuG. You can also listen to the number of unread messages and display that to your user. |
99
+
-`ON_PLUG_WIDGET_CLOSED` The PLuG widget is closed.
100
+
101
+
-`ON_PLUG_WIDGET_OPENED` The PLuG widget is opened.
102
+
103
+
-`ON_PLUG_WIDGET_READY` The PLuG widget is ready.
104
+
-
105
+
-`ON_PLUG_WIDGET_UNREAD_COUNT_CHANGE` The user receives a new message to their PLuG. You can also listen to the number of unread messages and display that to your user.
0 commit comments