@@ -36,7 +36,7 @@ Add the AI Agent SDK to your web page by importing it as a module.
36
36
37
37
``` html
38
38
<script type =" module" >
39
- import { loadMessenger } from " https://aiagent.sendbird.com/orgs/<org_name> /index.js" ;
39
+ import { loadMessenger } from " https://aiagent.sendbird.com/orgs/default /index.js" ;
40
40
</script >
41
41
```
42
42
@@ -62,7 +62,7 @@ For proper user session management, you can update the session information using
62
62
63
63
```javascript
64
64
// Update entire session configuration
65
- await messenger.updateUserSession({
65
+ messenger.updateUserSession({
66
66
userId: 'new_user_id',
67
67
authToken: 'new_auth_token',
68
68
// this callback should handle session token refresh:
@@ -85,7 +85,7 @@ To launch and display the messenger, implement the code below:
85
85
86
86
```javascript
87
87
const messenger = await loadMessenger();
88
- await messenger.initialize({
88
+ messenger.initialize({
89
89
appId: 'YOUR_APP_ID',
90
90
aiAgentId: 'YOUR_AI_AGENT_ID',
91
91
});
@@ -94,11 +94,11 @@ To launch and display the messenger, implement the code below:
94
94
The messenger view can be programmatically controlled using the ` open() ` and ` close() ` methods:
95
95
96
96
```javascript
97
- // Open the messenger view automatically after 1 second after initialized
98
- await messenger.initialize({ appId, aiAgentId });
99
- setTimeout (() => {
97
+ // Open the messenger view automatically after initialized
98
+ messenger.initialize({ appId, aiAgentId });
99
+ messenger.onLoad (() => {
100
100
messenger.open();
101
- }, 1000 );
101
+ });
102
102
103
103
// Close the messenger view by clicking a button
104
104
<button onClick={() => messenger.close()}>Close</button>
@@ -108,7 +108,7 @@ To update the configurations:
108
108
109
109
```javascript
110
110
// Update configuration
111
- await messenger.updateConfig({
111
+ messenger.updateConfig({
112
112
appId: 'NEW_APP_ID',
113
113
aiAgentId: 'NEW_BOT_ID',
114
114
// ... other config options
@@ -126,16 +126,19 @@ The following are available advanced features.
126
126
![ Image] ( https://github.com/user-attachments/assets/348ccad1-ec9a-4851-9324-084eaf569e34 )
127
127
128
128
```javascript
129
- const messenger = await loadMessenger();
130
- await messenger.initialize({
129
+ const messenger = await loadMessenger({
130
+ // Use Conversation component to display only the messenger without the launcher
131
+ customMainComponent: ({ messenger, react }) => {
132
+ return (props) => {
133
+ return react.createElement(messenger.AgentProviderContainer, props, [
134
+ react.createElement(messenger.Conversation),
135
+ ]);
136
+ };
137
+ }
138
+ });
139
+ messenger.initialize({
131
140
appId: 'APP_ID',
132
141
aiAgentId: 'AI_AGENT_ID',
133
- // Use Conversation component to display only the messenger without the launcher
134
- customMainComponent: (coreModule) => (props) => (
135
- <coreModule.AgentProviderContainer {...props}>
136
- <coreModule.Conversation />
137
- </coreModule.AgentProviderContainer>
138
- ),
139
142
});
140
143
```
141
144
0 commit comments