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

feat(react): Display <Button> components as normal buttons in whatsapp #1699

Merged
merged 11 commits into from
Jul 8, 2021

Conversation

asastre
Copy link
Contributor

@asastre asastre commented Jul 6, 2021

Description

Added new attributes (buttonsAsText and buttonsTextSeparator) in text prop for Multichannel component in order to decide to display <Button> components as text or as buttons in whatsapp.

Also, allow to display buttons pointing to webviews alongside other buttons (now webview buttons needed to be alone within a <Text> component)

Context

Allow @botonic/react Multichannel component to be able to display real buttons in whatsapp.

Approach taken / Explain the design

Since only 3 buttons (postback buttons) per message are allowed in whatsapp, if we detect more than 3 buttons within a message we're splitting the message in multiple messages in order to ensure all buttons will be displayed.

Since buttons pointing to URLs are not allowed in whatsapp, they will be displayed as text (the same way it's done right now).

To document / Usage example

Here are some examples of how messages containing buttons will be displayed in whatsapp:
Having this piece of code:
Captura de pantalla de 2021-07-06 10-54-50

This is what will be displayed in whatsapp:
Captura de pantalla de 2021-07-06 10-42-00

If we change the value of the buttonAsText attribute to true, in order to display the buttons as text as we do now, this is what will be displayed in whatsapp:
Captura de pantalla de 2021-07-06 10-43-33

Testing

The pull request has unit tests.

Copy link
Contributor

@vanbasten17 vanbasten17 left a comment

Choose a reason for hiding this comment

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

looking really good! do you need to support this for carousels also (which can also contain buttons)?

Copy link

@marcpdw marcpdw left a comment

Choose a reason for hiding this comment

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

Looks good overall. I've added a few comments of things that can be simplified in my opinion

@asastre
Copy link
Contributor Author

asastre commented Jul 7, 2021

looking really good! do you need to support this for carousels also (which can also contain buttons)?

Yes, you're right! Added support for whatsapp buttons in Carousels in this commit. Thanks for the observation!!

@asastre asastre requested a review from vanbasten17 July 7, 2021 14:32
@asastre asastre requested a review from marcpdw July 7, 2021 14:58
Copy link

@marcpdw marcpdw left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Contributor

@ericmarcos ericmarcos left a comment

Choose a reason for hiding this comment

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

LGTM

@asastre asastre merged commit 138ca15 into master Jul 8, 2021
@asastre asastre deleted the react/whatsapp-buttons branch July 8, 2021 15:13
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.

4 participants