



if (event.message && event.message.attachments) {
if (event.message.attachments[0].type === "image") {
let imageURL = event.message.attachments[0].payload.url;
console.log(imageURL);
let options = {
host: host,
path: '/img?url=' + imageURL,
headers: {
'Authorization': 'Basic ' + new Buffer(uid + ':' + pwd).toString('base64')
}
};
https.get(options, function(res) {
let body = "";
res.on('data', function(data) {
body += data;
});
res.on('end', function() {
let result = JSON.parse(body);
ArrayData = [];
for (let k = 0; k < result.result.distances.length; k++) {
let image_url = result.result.img_path[k];
image_url = image_url.split('\\')[1];
image_url = 'https://xxxxtrial.dispatcher.hanatrial.ondemand.com/img/' + image_url;
console.log(image_url);
ArrayData.push({
'title': 'Product',
'subtitle': 'Sub Title',
'image_url': image_url,
"buttons": [{
"type": "web_url",
"url": 'https://dummy.com',
"title": 'Detail Product'
}]
});
}
if (ArrayData.length > 0) {
sendTextMessage(sender, 'Showing the result...', function(returnValue) {
groups = ArrayData.map(function(e, i) {
return i % chunk_size === 0 ? ArrayData.slice(i, i + chunk_size) : null;
})
.filter(function(e) {
return e;
});
for (let p = 0; p < groups.length; p++) {
sendMsg(groups[p], sender, function(returnValue) {});
}
});
} else
sendTextMessages(sender, aritem, false, 0);
})
res.on('error', function(e) {
console.log("Got error: " + e.message);
});
});
}
}


You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 29 | |
| 26 | |
| 21 | |
| 21 | |
| 19 | |
| 14 | |
| 14 | |
| 14 | |
| 14 | |
| 10 |