if (credentials) {
Object.assign(payload, credentials)
} else {
this.props.createConversation(channelId, token).then(({
id,
chatId
}) => {
storeCredentialsInCookie(chatId, id, preferences.conversationTimeToLive, channelId)
initChat(chatId)
updateMemory(chatId)
})
}
function initChat(conversationId) {
var dev_token = "DEVELOPER TOKEN";
var url_post = "https://api.cai.tools.sap/build/v1/dialog";
$.ajax({
url: url_post,
type: 'post',
headers: {
"Authorization": "Token " + dev_token
},
data: {
"message": {
"content": "Hello SAP Conversational AI",
"type": "text"
},
"conversation_id": conversationId
},
success: function(data) {
console.log(data);
},
error: function() {
alert("Error");
}
});
}
function updateMemory(conversationId) {
var url = "PUT https://api.cai.tools.sap/core/v1/users/${USER_SLUG}/bots/${BOT_SLUG}/versions/v1/builder/conversation_states/" + conversationId;
$.ajax({
url: url,
type: 'PUT',
headers: {
"Authorization": "Token DEVELOPER TOKEN"
},
data: {
"language": "pt",
"merge_memory": true,
"memory": {
"user": {
"id": "12345",
"name": "Iron Man"
}
}
},
success: function(data) {
console.log(data);
window.tokenLoad = true;
},
error: function() {
alert("Error");
}
});
}
<script src="webchat.js"
channelId="XXXXXX-XXX-XXXX-XXXX-XXXXXXXXXXX"
token="XXXXXXXXXXXXXXXXXXXXXX"
id="cai-webchat"
></script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
11 | |
11 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 |