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
// this callback should handle session token refresh:
70
+
onSessionTokenRequest:async () => {
71
+
constresponse=awaitfetch('new-token-endpoint');
72
+
returnresponse.token;
73
+
}
74
+
});
75
+
```
75
76
76
77
### Launch the messenger
77
78
@@ -83,37 +84,37 @@ To launch and display the messenger, implement the code below:
83
84
84
85
>__Note__: Replace `YOUR_APP_ID` AND `YOUR_AI_AGENT_ID` with your Application ID and AI agent ID which you can obtain from the Sendbird Dashboard. To learn how do to so, refer to the [prerequisites](#prerequisites) section.
85
86
86
-
```javascript
87
-
const messenger = await loadMessenger();
88
-
messenger.initialize({
89
-
appId: 'YOUR_APP_ID',
90
-
aiAgentId: 'YOUR_AI_AGENT_ID',
91
-
});
92
-
```
87
+
```javascript
88
+
constmessenger=awaitloadMessenger();
89
+
messenger.initialize({
90
+
appId:'YOUR_APP_ID',
91
+
aiAgentId:'YOUR_AI_AGENT_ID',
92
+
});
93
+
```
93
94
94
95
The messenger view can be programmatically controlled using the `open()` and `close()` methods:
95
96
96
-
```javascript
97
-
// Open the messenger view automatically after initialized
98
-
messenger.initialize({ appId, aiAgentId });
99
-
messenger.onLoad(() => {
100
-
messenger.open();
101
-
});
97
+
```javascript
98
+
// Open the messenger view automatically after initialized
While it is not required, you can de-authenticate the SDK to clear session data and disconnect when a user logs out.
148
149
149
-
```javascript
150
-
messenger.destroy();
151
-
```
150
+
```javascript
151
+
messenger.destroy();
152
+
```
153
+
154
+
### Passing context object to Agent
155
+
156
+
You can predefine customer-specific information such as country, language, or other custom context data to guide the AI Agent in providing faster and more accurate responses.
157
+
158
+
This allows for a more personalized and context-aware interaction experience.
159
+
160
+
> Once the contexts are set, they will be used throughout the conversation to provide personalized and context-aware responses.
161
+
162
+
163
+
### Passing context object to Agent
164
+
165
+
You can predefine customer-specific information such as country, language, or other custom context data to guide the AI Agent in providing faster and more accurate responses.
166
+
167
+
This allows for a more personalized and context-aware interaction experience.
168
+
169
+
> Once the contexts are set, they will be used throughout the conversation to provide personalized and context-aware responses.
170
+
171
+
```javascript
172
+
// Metadata can be updated incrementally using updateMetadata().
173
+
// Top-level key-value pairs are merged across multiple calls.
0 commit comments