2
0

🚸 (whatsapp) Improve how the whatsapp preview behaves (#873)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
### Summary by CodeRabbit

- New Feature: Updated WhatsApp logo with a new design and color scheme.
- New Feature: Added a help button in the UI linking to documentation,
enhancing user guidance.
- New Feature: Introduced an alert message indicating that the WhatsApp
integration is in beta testing.
- New Feature: Implemented a button to open WhatsApp Web directly from
the application, improving user convenience.
- Refactor: Adjusted the retrieval of `contactPhoneNumber` in
`receiveMessagePreview` function for better data structure
compatibility.
- Refactor: Optimized the initialization and management of the WhatsApp
session in `startWhatsAppPreview`.
- Refactor: Improved the `parseButtonsReply` function by refining
condition checks.
- Refactor: Enhanced the readability of serialized rich text in
`convertRichTextToWhatsAppText` by introducing newline characters.
- Bug Fix: Ensured preservation of `contact` information when resuming
the WhatsApp flow in `resumeWhatsAppFlow`.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Baptiste Arnaud
2023-09-29 17:47:10 +02:00
committed by GitHub
parent 59cd79a4b8
commit f016072e3e
8 changed files with 56 additions and 88 deletions

View File

@ -63,21 +63,14 @@ export const parseButtonsReply =
reply: matchedItems.map((item) => item.content).join(', '),
}
}
if (state.whatsApp) {
const matchedItem = displayedItems.find((item) => item.id === inputValue)
if (!matchedItem) return { status: 'fail' }
return {
status: 'success',
reply: matchedItem.content ?? '',
}
}
const longestItemsFirst = [...displayedItems].sort(
(a, b) => (b.content?.length ?? 0) - (a.content?.length ?? 0)
)
const matchedItem = longestItemsFirst.find(
(item) =>
item.content &&
inputValue.toLowerCase().trim() === item.content.toLowerCase().trim()
item.id === inputValue ||
(item.content &&
inputValue.toLowerCase().trim() === item.content.toLowerCase().trim())
)
if (!matchedItem) return { status: 'fail' }
return {

View File

@ -6,4 +6,4 @@ export const convertRichTextToWhatsAppText = (richText: TElement[]): string =>
.map((chunk) =>
serialize(chunk)?.replaceAll('**', '*').replaceAll('&amp;#39;', "'")
)
.join('')
.join('\n')

View File

@ -67,7 +67,7 @@ export const resumeWhatsAppFlow = async ({
session && !isSessionExpired
? session.state.currentBlock
? await continueBotFlow(session.state)(messageContent)
: await startBotFlow(session.state)
: await startBotFlow({ ...session.state, whatsApp: { contact } })
: workspaceId
? await startWhatsAppSession({
incomingMessage: messageContent,