microsoft / BotFramework-WebChat

A highly-customizable web-based client for Azure Bot Services.
https://www.botframework.com/
MIT License
1.59k stars 1.54k forks source link

When message sent to bot has multiple lines, each line beginning with a number, Emulator changes the number #3766

Closed mindmodel closed 3 years ago

mindmodel commented 5 years ago

Version 4.3.0.

JSON copied directly from Emulator:

"text": "0) [All Cuisines: Highest Ratings]\n\r\n1) American (New)\r\n2) American (Traditional)\r\n3) Asian Fusion\r\n4) Bakeries\r\n5) Barbeque\r\n6) Bars\r\n7) Beer Bar\r\n8) Brazilian\r\n9) Breakfast & Brunch\r\n10) Breweries\r\n11) Buffets\r\n12) Burgers\r\n13) Caribbean\r\n14) Chinese\r\n15) Cocktail Bars\r\n16) Coffee & Tea\r\n17) Coffee Roasteries\r\n18) Colombian\r\n19) Comfort Food\r\n20) Delis\r\n21) Desserts\r\n22) Dim Sum\r\n23) Diners\r\n24) Fast Food\r\n25) Fondue\r\n26) Food Trucks\r\n27) French\r\n28) Gluten-Free\r\n29) Greek\r\n30) Halal\r\n31) Hot Dogs\r\n32) Indian\r\n33) Italian\r\n34) Japanese\r\n35) Juice Bars & Smoothies\r\n36) Latin American\r\n37) Mediterranean\r\n38) Mexican\r\n39) Middle Eastern\r\n40) Pizza\r\n41) Salad\r\n42) Sandwiches\r\n43) Seafood\r\n44) Soup\r\n45) Sports Bars\r\n46) Steakhouses\r\n47) Sushi Bars\r\n48) Szechuan\r\n49) Vegan\r\n50) Vegetarian\r\n51) Vietnamese\r\n",

The "\r\n" are necessary to produce one item per line in SMS sent by Twilio to iPhone.

Message displays correctly as text message received by phone, one line for each item, numbers starting at zero.

The Emulator renumbers the items, starting at one.

See attached screen shot.

emulator bug

cwhitten commented 5 years ago

@compulim can you comment to any special webchat behavior causing this?

cwhitten commented 3 years ago

Hello @mindmodel - this is by design of the activity renderer as it interprets the text as markdown. Transferring to the Web Chat project.

cwhitten commented 3 years ago

Loading up for discussion/prioritization of an upcoming milestone.

corinagum commented 3 years ago

Feel free to reopen if this issue is persisting. Our recommendation is to use plain text instead of markdown for this scenario.

mindmodel commented 3 years ago

This isn't markdown. As stated in the original question, it's just text with newlines. The text displays correctly on iPhone. The emulator, for some reason, changes the numbers contained in the text to different numbers. Why does the emulator interpret this text as markdown? Does it make sense to change the bot software, which produces correct results on the target device (iPhone) to work around behavior of the emulator?

corinagum commented 3 years ago

By default, the activity is processed as markdown in Web Chat. Based off what I can see from the screencap above, textFormat is not declared. This is legacy behavior from Web Chat v3.

Source: https://github.com/microsoft/BotFramework-WebChat/blob/master/packages/component/src/Utils/textFormatToContentType.js v3: https://github.com/microsoft/BotFramework-WebChat/blob/v3/src/FormattedText.tsx#L15

You're not required to change the bot software, but this is the cause of the behavior.

mindmodel commented 3 years ago

I'll check it out. Thanks!