curl -H "Authorization: Token d54cc18944a6cc60ca94852d2fc8d8ce" -H "Content-Type: application/json" -d '{"message": {"content":"I want flowers for my mom, an offer?","type":"text"}, "conversation_id": "CONVERSATION_ID"}' -X POST "https://api.cai.tools.sap/build/v1/dialog"
{
"results": {
"nlp": {
"uuid": "6631abdd-73a8-4de2-ab98-249e3f0abee5",
"intents": [
{
"slug": "buy",
"confidence": 0.99,
"description": null
}
],
"entities": {
"pronoun": [
{
"person": 1,
"number": "singular",
"gender": "unknown",
"raw": "I",
"confidence": 0.99
}
],
"number": [
{
"scalar": 1,
"raw": "an",
"confidence": 0.99
}
]
},
"language": "en",
"processing_language": "en",
"version": "1902.2.0",
"timestamp": "2019-02-26T08:10:54.924465+00:00",
"status": 200,
"source": "I want flowers for my mom, an offer?",
"act": "assert",
"type": null,
"sentiment": "neutral"
},
"qna": {
},
"messages": [
{
"type": "text",
"content": "Rose, Tulip and Daisy, which one you like?",
"delay": null
}
],
"conversation": {
"id": "CONVERSATION_ID",
"language": "en",
"memory": {
},
"skill": "greetings",
"skill_occurences": 2
}
},
"message": "Dialog rendered with success"
}
{"message": {"content":"I want flowers for my mom, an offer?","type":"text"}, "conversation_id": "CONVERSATION_ID"}
curl -X POST "https://api.openconnectors.ext.hanatrial.ondemand.com/elements/api-v2/" -H "accept: application/json" -H "Authorization: User CnRqeTAM/0Gam0mn0FC8THg41b1BfZhpNPUCGCd8pns=, Organization 7c864423133b0be7aa25ce19cbbc7aaf, Element w/8rxilrE8xEjCzWAmLSd1nVEZddmSQyycqzXpFkF08=" -H "Content-Type: application/json" -d "{\"message\": {\"content\":\"I want flowers for my mom, an offer?\",\"type\":\"text\"}, \"conversation_id\": \"CONVERSATION_ID\"}"
Authorization: User CnRqeTAM/0Gam0mn0FC8THg41b1BfZhpNPUCGCd8pns=, Organization 7c864423133b0be7aa25ce19cbbc7aaf, Element w/8rxilrE8xEjCzWAmLSd1nVEZddmSQyycqzXpFkF08=
onSendPressed: function(oEvent) {
var chatbot = this.getView().byId("botchat");
var question = oEvent.getParameter("text");
console.log(question);
var data = '{"message": {"content":"' + question + '","type":"text"}, "conversation_id": "CONVERSATION_ID"}';
var _id = localStorage.getItem("chatId");
if (_id != undefined) {
//payload.id = _id;
}
jQuery.ajax({
url: "https://api.openconnectors.ext.hanatrial.ondemand.com/elements/api-v2/",
cache: false,
type: "POST",
headers: {
'Authorization': 'User CnRqeTAM/0Gam0mn0FC8THg41b1BfZhpNPUCGCd8pns=, Organization 7c864423133b0be7aa25ce19cbbc7aaf, Element w/8rxilrE8xEjCzWAmLSd1nVEZddmSQyycqzXpFkF08=',
'Content-Type': 'application/json'
},
data: data,
async: true,
success: function(sData) {
console.log('[POST] /discover-dialog', sData);
chatbot.addChatItem(sData.results.messages[0].content, false);
chatbot.botFinishTyping();
localStorage.setItem("chatId", sData.id);
},
error: function(sError) {
chatbot.addChatItem("Something error!", false);
}
});
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |