You would think this would be easy to do, but it just isn’t with this simple approach. It is possible to format the text using the “rich text” option in the “Set text to” droplist, but the formatting is lost at every updated chat input because the text widget is set to its current text plus the new chat text, and unfortunately, the text formatting isn’t carried in the local variable, [[LVAR1]]. Perhaps this has been improved in RP9 though?
Here is another approach, using repeaters to represent the chat thread. Every chat input is a new row, and each row in the repeater has a dynamic panel with two states: “user” and “admin”. In this way, the two “agent” types can have completely different styling and positioning. The drawback is that each repeater row will be the same height and width. So, the “chat bubbles” in each row will always be the same height regardless of the length of the text content. In this demo it looks fine for one or two lines of text, but more than that overflows poorly.
Chatbot Demo 2.rp (128.5 KB)
Hopefully, this might be good enough for your purposes. If not, you can try some rudimentary sizing of the chatInputUser and chatInputAdmin widgets in the OnItemLoad event, based on the length of the text in the Input column (this would be represented as [[ Item.Input.length ]]
, but would be pretty inaccurate with proportional fonts. So, err on the liberal side–in other words, add more height than you think you might need. You can use some javascript injection to vary the width of the chat bubble widgets but I haven’t found a way to set the height by determining how many rows the text would take when rendered in the browser.