-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwordpress_plugin_update.js
More file actions
37 lines (33 loc) · 1.04 KB
/
Copy pathwordpress_plugin_update.js
File metadata and controls
37 lines (33 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// WordPress Plugin JavaScript Update
// Add this to your existing WordPress plugin's chat function
// Example of how to modify your existing chat request
function sendChatMessage(sessionId, userMessage, userToken) {
const chatRequest = {
session_id: sessionId,
message: userMessage,
user_token: userToken,
domain: window.location.hostname // Add this line
};
// Your existing fetch logic here
fetch('/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(chatRequest)
})
.then(response => response.json())
.then(data => {
// Handle response
});
}
// For streaming endpoint, update similarly:
function sendStreamingChatMessage(sessionId, userMessage, userToken) {
const chatRequest = {
session_id: sessionId,
message: userMessage,
user_token: userToken,
domain: window.location.hostname // Add this line
};
// Your existing streaming logic here
}