Skip to content

Commit de38821

Browse files
authored
update PLuG docs for Wedge launch (#57)
* upgrade for local preview * added search methods; changed tables to lists
1 parent c7dee6a commit de38821

File tree

2 files changed

+49
-18
lines changed

2 files changed

+49
-18
lines changed

fern/docs/pages/plug-sdk/methods.mdx

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
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.
22

3-
| Method | Description |
4-
| ------------------------ | --------------------------------------------------------------------------------- |
5-
| `plugSDK.init()` | Initialize the PLuG widget. |
6-
| `plugSDK.shutdown()` | End the user session which is currently initialized in PLuG widget. |
7-
| `plugSDK.toggleWidget()` | Open/close the widget. |
8-
| `plugSDK.onEvent()` | Perform specific actions based on the payload type received from the PLuG widget. |
9-
| `plugSDK.toggleTheme('light/dark')` | Toggle PLuG widget theme. |
10-
| `plugSDK.toggleWidget(true, 'create_conversation', {startConversationContent: 'Hi',});` | Start a conversation. |
3+
## Methods
114

5+
- `plugSDK.init()` Initialize the PLuG chat widget.
126

13-
## Initialize the widget
7+
- `plugSDK.initSearchAgent()` Initialize PLuG search agent.
148

15-
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.
16+
17+
- `plugSDK.toggleTheme('light/dark')` Toggle PLuG widget theme.
18+
19+
- `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.
1626

1727
```jsx
1828
useEffect(() => {
@@ -26,6 +36,25 @@ useEffect(() => {
2636
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.
2737
</Callout>
2838

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+
2958
## Shutdown the widget
3059

3160
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
4978

5079
## Open or close the widget
5180

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.
5382

5483
```jsx
5584
window.plugSDK.toggleWidget(true);
85+
window.plugSDK.toggleSearchAgent(true);
5686
```
5787

5888
<iframe src="https://codesandbox.io/embed/toggle-plug-with-button-nnkmk3?fontsize=14&hidenavigation=1&module=%2Fsrc%2FTogglePlug.js&theme=dark&view=preview&hidedevtools=1"
@@ -66,12 +96,13 @@ window.plugSDK.toggleWidget(true);
6696

6797
This method can be used to listen to events coming from the PLuG widget. The following are the different `PAYLOAD_TYPES`.
6898

69-
| Event | Meaning |
70-
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------- |
71-
| `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.
75106

76107
```jsx
77108
useEffect(() => {

fern/fern.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"organization": "devrev",
3-
"version": "0.28.0"
3+
"version": "0.30.0"
44
}

0 commit comments

Comments
 (0)