If I understand the question correctly, you can configure the API endpoint that triggers the sending of the message and hit that endpoint in the success callback "MessengerExtensions.requestCloseBrowser ().
An example of using the jQuery module and node express:
Webview:
window.extAsyncInit = function () {
Server:
app.post('/sendOnWebviewClose', (req, res) => { let psid = req.body.psid; sendMessage(psid); })
source share