WhatsApp Dropdown not showing + Question repeats
# 🤝help
a
Hey team, I am facing some issues when it comes to the WhatsApp integration. ---------- Case 1: I have used a single choice field to capture information from the user (screen shot attached). However, once 3 options have been displayed, the question repeats (which is not convenient especially when you have 6+ choices). Screenshot attached as well. So, question 1: Do you have a better solution for that? (Question should not repeat) ------------ Case 2: I have to add that there was a better solution with a menu 1 or 2 weeks ago. In this case, the user can click on the menu and see all the options in a list. The issue in that case was that there was an empty row below each option. As a result, when the user selects submits an option, the response won't be recognised (because there is an empty row). Screenshots attached as well. So, question 2: Do you have a fix for that? A way in which there is no empty row? ------------ Notes: In both cases, I have used a single choice node to ask a question / grasp information. When I setup a bot today, WhatsApp will act like in case 1. When I deploy by bot that I have setup 2 weeks ago, WhatsApp will act like in case 2. So, I'm not able to replicate case 2 with a new bot. So, question 3: Please tell me how to display the menu properly (without empty rows). ------------ Furthermore, I'm having issues with the permanent token for WhatsApp: I have followed your tutorial to setup WhatsApp with a temporary token (everything works). Then I have generated a permanent token, replaced it with the temporary token, and it stopped working... (I have followed your tutorial/guide). And yes, the system user has full access to the app... Please get back on the issues soon. Thanks. Kind regards Silas

https://cdn.discordapp.com/attachments/1131622608912273564/1131622609113579610/Screenshot_2023-07-20_at_6.09.03_pm.png

https://cdn.discordapp.com/attachments/1131622608912273564/1131622609369436180/Screenshot_2023-07-20_at_6.14.36_pm.png

https://cdn.discordapp.com/attachments/1131622608912273564/1131622609965043802/Screenshot_2023-07-20_at_6.18.05_pm.png

https://cdn.discordapp.com/attachments/1131622608912273564/1131622610283790426/Screenshot_2023-07-20_at_6.18.24_pm.png

If one of the choices surpasses a certain length, the menu version will show (case 2). Does anybody have an idea for a fix?
Just found out
a
@famous-zoo-73118 do you know if we've changed anythign with the WhatsApp integration for choice skills in the last two weeks?
a
Hey, any updates?
f
@acceptable-kangaroo-64719 No, nothing has changed recently related to the Whatsapp integration at all.
a
So, can you fix this?
Quite frustrating that it does not work
Any updates @famous-zoo-73118 or @acceptable-kangaroo-64719?
f
Hi @aloof-art-3372, thanks for your patience, I've investigated this and it's because there's a limit in the number of choices (3 max) that Whatsapp allows per message, so the Whatsapp integration has to split the choices in groups of 3, and Whatsapp requires each group to have a message so the integration simply reuses the same original message for each group. We have added some enhanced logging for Whatsapp which will appear in the Logs section of the bot, which will indicate when this happens.
a
Thank you for getting back on this! You are right, but there is also an option which shows a "menu" – this one still does not work, right?

https://cdn.discordapp.com/attachments/1131622608912273564/1138177281341259868/Screenshot_2023-08-07_at_8.29.27_pm.png

f
I checked this and it's because the Studio favors single-choice fields for all channels/integrations in general due to their higher usability (it's quicker to click a button than to open a dropdown and select an item)
At the moment, a dropdown field will be used only if the choices are 5 or more AND if the total character length of the choice labels is greater than 140 characters
However, we're planning to improve this in the future so that the Studio considers the specific limitations for each channel when decididing whether to use a dropdown or button choices.
a
Yes, I know and that is exactly what I want. The issue in that case is that there are empty rows below each choice (you can see that the label is aligned to the top). Therefore, it does not work

https://cdn.discordapp.com/attachments/1131622608912273564/1138191710871101542/Screenshot_2023-08-07_at_9.26.56_pm.png

So your logic is exactly what I want but there is that issue which make that menu-variant unusable
f
Sorry for the initial confusion. I just finished checking and there's nothing specific in the Whatsapp integration or the bots themselves that would append a new line character at the end of the dropdown options. However, to double check, could you go into the Logs section in your bot in the BP Cloud dashbord and check for a log line that starts with
[whatsapp] Received list reply from Whatsapp:
and let me know if the
value
property in that log line shows a new line character at the end?
BTW, if this is affecting your bot's logic, in the meantime you could use the
.trim()
function from Javascript to remove the new line char at the end, e.g.
{{ event.preview.trim() }}
a
I don't think it is caused by Botpress/caused by the choices in Botpress. Instead, it looks like WhatsApp expects another value when it shows the menu variant. Here is the log from the new test: [whatsapp] Handler received request from Whatsapp with payload: undefined [whatsapp] Handler received request from Whatsapp with payload: {"object":"whatsapp_business_account","entry":[{"id":"117734321371799","changes":[{"value":{"messaging_product":"whatsapp","metadata":{"display_phone_number":"15550065196","phone_number_id":"108437355642778"},"statuses":[{"id":"wamid.HBgNNDkxNTEyMTA5Mzc5ORUCABEYEkI0QzhBMzlEQjdBMENDQzE1OQA=","status":"read","timestamp":"1691471723","recipient_id":"4915121093799"}]},"field":"messages"}]}]} [whatsapp] Handler received request from Whatsapp with payload: {"object":"whatsapp_business_account","entry":[{"id":"117734321371799","changes":[{"value":{"messaging_product":"whatsapp","metadata":{"display_phone_number":"15550065196","phone_number_id":"108437355642778"},"contacts":[{"profile":{"name":"Silas"},"wa_id":"4915121093799"}],"messages":[{"from":"4915121093799","id":"wamid.HBgNNDkxNTEyMTA5Mzc5ORUCABIYFjNFQjBEMjk5MzQzN0ZGMkRDODVBMEMA","timestamp":"1691471724","text":{"body":"test"},"type":"text"}]},"field":"messages"}]}]} [whatsapp] Received text message from Whatsapp: test

https://cdn.discordapp.com/attachments/1131622608912273564/1138341305408299079/Screenshot_2023-08-08_at_7.19.36_am.png

https://cdn.discordapp.com/attachments/1131622608912273564/1138341305643188315/Screenshot_2023-08-08_at_7.21.41_am.png

f
Good catch, yes, it looks like it's definitely Whatsapp adding that new line at the end. As mentioned earlier, you could try using
.trim()
if the bot is receiving this new line char, so that your bot's logic isn't affected.
a
Where exactly should I add the trim function? Also, that wouldn't resolve the issue that Whatsapp is displaying an empty line, right?
f
For example, if you're using the
event.preview
variable to get the user's input from the dropdown selection, you'd do
event.preview.trim()
instead. And no, that wouldn't resolve the issue with Whatsapp doing this, as from what I've looked at it's something completely on their end.
a
Sorry for not mentioning but I'm in the studio so I'm not sure where to add the .trim()
However, I think it is an issue on your end @famous-zoo-73118 Please check the file: https://github.com/botpress/botpress/blob/master/integrations/whatsapp/src/message-types/dropdown.ts As you can see in row 13, you are setting it to an empty string. Can you please fix that? I have manually updated the HTML code and found that the "empty row" is actually an empty description which is set on your end.

https://cdn.discordapp.com/attachments/1131622608912273564/1138501047476826152/183554814_504218921028568_8013384280208209094_n.png

https://cdn.discordapp.com/attachments/1131622608912273564/1138501048026284093/Screenshot_2023-08-08_at_5.54.51_pm.png

https://cdn.discordapp.com/attachments/1131622608912273564/1138501048391180408/Screenshot_2023-08-08_at_5.56.15_pm.png

f
Interesting. In theory that's only a description which shouldn't be used by Whatsapp, as the
value
is what contains the full string value of the choice. I'll check with the dev that added that empty description to get more context about this. I'll get back to you once I've more info.
a
Ok, thanks! Looking forward to getting this fixed 🙂
f
BTW, revising my previous statement about using trim(), if you're storing the result of the choice in a variable, you can simply use
workflow.variableName.trim()
where "variableName" is the name you chose for your variable.
I finished testing some changes to the whatsapp integration, and it looks like not passing a value for the description breaks the message pipeline. We're doing some changes to our logging system so will need to wait until that is done so I can check exactly what in the pipeline is breaking under this condition. Will get back to you soon once I can do this.
a
Thank you for the update!
f
Hi @aloof-art-3372 as a follow up, I did some additional tests and the empty description isn't really affecting the value sent from Whatsapp to the bot, as even with the empty description the bot does receive the original value without any line breaks, so this doesn't seem to be affecting bot functionality/reliability and is more of UX fine tuning of the Whatsapp experience. I'll be working on removing the empty description in the coming weeks once the issue I described earlier with the message pipeline is first resolved, but I'll be sure to get back to you once it's done.
a
Hey @famous-zoo-73118, thanks for getting back on this. That's quite unfortunate as my clients are already complaining about this "malfunction" (so it's a very high prior issue from my side). Can we pay a fee to fix that issue or at least speed up the process? The first time I reported this issue was more than one month ago via your live chat...
f
I'll do my best to prioritize this internally, mentioning your case. As soon as the other issue I mentioned is resolved (which is being worked on as we speak) I'll try jumping into this as soon as possible.
a
Hey @famous-zoo-73118 – got another question regarding the Whatsapp integration. When I chat with the bot, quit for a day and want to continue the conversation, the bot starts from the beginning again. Can I setup something up so that the bot does not quit automatically?
f
Try increasing the Inactivity Timeout of the bot, it's in the Chatbot Settings under the BP logo in the top left corner of the Studio:

https://cdn.discordapp.com/attachments/1131622608912273564/1139222151241678898/image.png

a
Thanks!
Hey @famous-zoo-73118 any updates before the weekend starts?
f
Hi @aloof-art-3372 what kind of updates?
a
Hey, regarding the whatsapp issue
f
The Inactivity Timeout option didn’t work?
If not, could you please report this in a separate post in this help channel?
a
Hey @famous-zoo-73118, the inactivity issue is fixed - thanks! However, I was referring to the Whatsapp dropdown/menu issue with the empty description (you've got an eta?)
f
Oh ok, sorry for the confusion, yes, I expect to have an update on this by next week. We're still sorting out the other issues which is blocking this one but that's almost wrapped up.
Hi @aloof-art-3372, so I was able to finally get to the bottom of this, and unfortunately Whatsapp has a bug where they actually enforce the description of a dropdown item to be a non-empty string contrary to what they say in their documentation which indicates that it's supposedly optional. For reference, this is the exact message Whatsapp is responding with when trying to send either an empty string as description or no description at all for a given dropdown item:
"errorMessage":"Row description must be 72 characters or less","stack":["Error: Row description must be 72 characters or less"
On a positive note, I'm working on make the changes to the Whatsapp integration so that choices with more than 3 options (which is the limit imposed by Whatsapp) are always/consistently shown as a dropdown list, while choices with 3 options or less will show as buttons, to fix all the confusion we had around choices with more than 3 options sometimes getting shown as multiple groups of buttons with the question repeated and sometimes as a dropdown list.
I'll report back here when this change is deployed so you can test this from your end. Thanks for your patience!
@aloof-art-3372 The fix has been deployed. Choices with more than 3 options will now always display as a dropdown in Whatsapp.
a
Many thanks @famous-zoo-73118 – just checked it and looks way better than previously, thanks! The best case would be to remove the "empty" description so that the options are centred. Everything else is fine
One more thing: Can you add multi-language support? The "menu" button is always "Choose...". However, my client needs it in German ("Auswahl..."). Can you add that functionality anyhow?
f
Yes, but as mentioned unfortunately Whatsapp has a bug and they actually reject options with no description.
Right now it's not possible, and unfortunately Whatsapp requires a label for the dropdown button. Previously the integration just repeated the message (truncated) for the dropdown label. Would that be okay for the time being?
c
Hey @famous-zoo-73118 ! I have the same problem, and I actually saw a Dentistry that built a bot using Botpress, and whoever built it changed the "Choose" to a custom "Pick one of these options" in a foreign language. Any idea how he did it?
3 Views