The existing target attribute can be used to make the button either open the link in a new tab (the default), or open in the current tab (specifically, it reflects the target attribute of the HTML anchor).
For some use cases, notably authentication flows, it can be helpful to instead open a popup window that will then close automatically. Currently, such a popup-opening button has to be implemented through a widget, but this requires copying existing behaviour from various frontend components.
Proposed solution
We could add a parameter to UrlButton which would enable the popup behaviour. In line with the existing target parameter, this new parameter could be a simple string matching the spec of windowFeatures. When this windowFeatures parameter gets specified, the tock-vue-kit and tock-react-kit would add a JS handler that cancels the default browser behaviour and opens the link in a new window. The implementation of this handler could be as simple as calling window.open(button.url, button.target, button.windowFeatures).
The web connector offers the ability to send a link to an arbitrary URL through an
UrlButton
: https://github.com/theopenconversationkit/tock/blob/903e3c242dd1e43d46ae0499733e6818a2958ffc/bot/connector-web-model/src/main/kotlin/ai/tock/bot/connector/web/send/UrlButton.kt#L22-L29The existing
target
attribute can be used to make the button either open the link in a new tab (the default), or open in the current tab (specifically, it reflects thetarget
attribute of the HTML anchor).For some use cases, notably authentication flows, it can be helpful to instead open a popup window that will then close automatically. Currently, such a popup-opening button has to be implemented through a widget, but this requires copying existing behaviour from various frontend components.
Proposed solution
We could add a parameter to
UrlButton
which would enable the popup behaviour. In line with the existingtarget
parameter, this new parameter could be a simple string matching the spec ofwindowFeatures
. When thiswindowFeatures
parameter gets specified, the tock-vue-kit and tock-react-kit would add a JS handler that cancels the default browser behaviour and opens the link in a new window. The implementation of this handler could be as simple as callingwindow.open(button.url, button.target, button.windowFeatures)
.Thoughts @rkuffer @Benvii @assouktim?