-
Notifications
You must be signed in to change notification settings - Fork 75
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
Conversation
…y whatsapp buttons
…button and multichannel text components
…of new line in buttons
There was a problem hiding this 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)?
packages/botonic-react/tests/components/multichannel/multichannel-button.test.jsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
packages/botonic-react/src/components/multichannel/multichannel-button.jsx
Outdated
Show resolved
Hide resolved
packages/botonic-react/src/components/multichannel/multichannel-button.jsx
Outdated
Show resolved
Hide resolved
packages/botonic-react/src/components/multichannel/multichannel-text.jsx
Outdated
Show resolved
Hide resolved
packages/botonic-react/src/components/multichannel/multichannel-text.jsx
Show resolved
Hide resolved
packages/botonic-react/src/components/multichannel/multichannel-text.jsx
Outdated
Show resolved
Hide resolved
…egenerateMultichannelButtons
Yes, you're right! Added support for whatsapp buttons in Carousels in this commit. Thanks for the observation!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Added new attributes (
buttonsAsText
andbuttonsTextSeparator
) intext
prop forMultichannel
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:
This is what will be displayed in whatsapp:
If we change the value of the
buttonAsText
attribute totrue
, in order to display the buttons as text as we do now, this is what will be displayed in whatsapp:Testing
The pull request has unit tests.