Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1798] fix not rendered content messages in facebook render library #1818

Conversation

AudreyKj
Copy link
Contributor

@AudreyKj AudreyKj commented May 21, 2021

closes #1798

Changes

  • added Media Template:
  • fixed fallback attachment
  • fixed Buttons typings + added more button types
  • created a Buttons component that is reused in all templates and supports all the types of buttons

Screenshots
Media Template: includes video or image (accepts only FB URLs so cannot be embedded) + buttons
Screenshot 2021-05-21 at 11 40 03

@github-actions github-actions bot added the fix label May 21, 2021
buttons: attachment.payload.elements[0].buttons,
};
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

title: attachment.payload.title,
url: attachment.payload.url,
title: attachment.payload?.title ?? attachment.title,
url: attachment.payload?.url ?? attachment.url,
};
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


if (messageJson.attachment || messageJson.attachments) {
return parseAttachment(messageJson.attachment || messageJson.attachments[0]);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message with fallback attachment can include a text (unlike other attachments)

})}
</>
);
};
Copy link
Contributor Author

@AudreyKj AudreyKj May 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FB templates all include a buttons array so I created a reusable Buttons component

{buttons && <Buttons buttons={buttons} mediaTemplate={true} />}
</div>
);
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Media Template component

  • media templates only accept FB URLs or FB ids so we cannot embed them

https://developers.facebook.com/docs/messenger-platform/send-messages/template/media

payload?: string;
game_metadata?: {
player_id?: string;
context_id?: string;
};
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored the typings of the Buttons + added more types

@@ -14,7 +50,7 @@ export interface ButtonAttachment extends Attachment {
payload: {
text: string;
template_type: 'button';
buttons: Button[];
buttons: (URLButton | PostbackButton | CallButton | LoginButton | LogoutButton | GamePlayButton)[];
};
Copy link
Contributor Author

@AudreyKj AudreyKj May 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the typing here: the messages templates include a buttons array that can accept different buttons (and not only web_url buttons)

https://developers.facebook.com/docs/messenger-platform/reference/buttons

Copy link
Contributor

@stayprodio stayprodio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AudreyKj AudreyKj merged commit 4bb28a1 into develop May 25, 2021
@AudreyKj AudreyKj deleted the fix/1798-fix-not-rendered-content-messages-in-Facebook-render-library branch May 25, 2021 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix not rendered content messages in Facebook render library
2 participants