Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Copy user quickreplies to platform messge object
Browse files Browse the repository at this point in the history
  • Loading branch information
ouadie-lahdioui committed Mar 22, 2018
1 parent 9631fb5 commit d7a2e2a
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions lib/Facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,37 +55,8 @@ function Facebookbot(configuration) {
platform_message.message.sticker_id = message.sticker_id;
}

if (message.quick_replies) {
if (message.quick_replies) platform_message.message.quick_replies = message.quick_replies;

// sanitize the length of the title to maximum of 20 chars
var titleLimit = function(title) {
if (title.length > 20) {
var newTitle = title.substring(0, 16) + '...';
return newTitle;
} else {
return title;
}
};

platform_message.message.quick_replies = message.quick_replies.map(function(item) {
var quick_reply = {};
if (item.content_type === 'text' || !item.content_type) {
quick_reply = {
content_type: 'text',
title: titleLimit(item.title),
payload: item.payload,
image_url: item.image_url,
};
} else if (item.content_type === 'location') {
quick_reply = {
content_type: 'location'
};
} else {
// Future quick replies types
}
return quick_reply;
});
}
} else {
platform_message.sender_action = message.sender_action;
}
Expand Down

0 comments on commit d7a2e2a

Please sign in to comment.