Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Update suggestions-response.js #243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/rich-responses/suggestions-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Suggestion extends RichResponse {
super();
this.platform = undefined;
this.replies = [];
this.title = "Choose an item:"
if (
suggestion === undefined ||
(typeof suggestion === 'object' && !suggestion.title)
Expand All @@ -58,6 +59,7 @@ class Suggestion extends RichResponse {
this.replies.push(suggestion);
} else if (typeof suggestion === 'object') {
this.replies.push(suggestion.title);
this.title = suggestion.title
if (
typeof suggestion.platform !== 'undefined' &&
suggestion.platform !== PLATFORMS.UNSPECIFIED
Expand Down Expand Up @@ -184,7 +186,15 @@ class Suggestion extends RichResponse {
this.replies.forEach((reply) => {
response.suggestions.suggestions.push({title: reply});
});
} else {
} else if (platform === PLATFORMS.FACEBOOK) {
response = {
quickReplies: {
title: this.title,
quickReplies: this.replies
}
}
}
else {
response = {quickReplies: {quickReplies: this.replies}};
// Response is the same for generic responses without the platform attribute
// If the platform is not undefined or the platform is not unspecified
Expand Down