on 06-17-2021 1:36 PM
Hello experts,
I was trying to connect sap cai with whatsapp. I referred to the blog SAP CAI WITH WHATSAPP. I had to make some minor changes as sap cai has changed the way of authentication and hence default sdk can't be used.
Following is the code I wrote in twilio function and the response of it. How do i send buttons or quick replies to whaatsapp?
//Code in twilio function
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.MessagingResponse();
let superagent = require('superagent');
superagent
.post("https://api.cai.tools.sap/build/v1/dialog")
.send({ message: { content: event.Body, type:"text" }, conversation_id: event.From})
.set("Authorization", "<Bearer using client id and secret>);
.set("X-Token", "<Developer Token>")
.set("Content-type", "application/json")
.then(function(res) {
data = res.text;
//console.log(data);
twiml.message(data);
callback(null, twiml);
});
};
//response
{
"results": {
"nlp": {
"uuid": "38db853d-ee77-4ffb-94c5-6839c86e7bfd154100",
"source": "fdfd",
"intents": [],
"entities": {},
"act": null,
"sentiment": "neutral",
"language": "un",
"processing_language": "en",
"version": "2105.0.0",
"timestamp": "2021-06-16T13:32:46.369068+00:00",
"status": 200,
"type": null,
"logs": []
},
"messages": [
{
"type": "buttons",
"content": {
"title": "Select Language",
"buttons": [
{
"value": "english",
"title": "English",
"type": "postback"
},
{
"value": "hindi",
"title": "हिंदी",
"type": "postback"
},
{
"value": "marathi",
"title": "मराठी",
"type": "postback"
},
{
"value": "kannada",
"title": "ಕನ್ನಡ",
"type": "postback"
}
]
},
"delay": null
}
],
"conversation": {
"id": "whatsapp:+919579xxxxxx",
"language": "en",
"memory": {
"flag_conv_init": 1
},
"skill": "detect-lang",
"skill_occurences": 1,
"skill_id": "431288ed-6cc1-4049-9b23-8d57e240c8a2"
},
"logs": null,
"qna": null,
"fallback": null
},
"message": "Dialog rendered with success"
}
User | Count |
---|---|
70 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.