Robot framework Browser library with BrowserStack

With the following init.robot file:

*** Settings ***
Force Tags       test
Documentation    Test Suite
Suite Setup      Setup Browserstack
Resource         ../Variables/variables.robot
Library          Browser

*** Variables ***
&{desiredCapabilities}      os=Windows
...                         os_version=10
...                         browser=chrome
...                         name=TestInit
...                         browserstack.username=${BROWSERSTACK_USERNAME}
...                         browserstack.accessKey=${BROWSERSTACK_ACCESSKEY}
...                         client.playwrightVersion=1.17.2

*** Keywords ***
Setup Browserstack
    ${BSENCODEDCAPS}            Evaluate    urllib.parse.quote( json.dumps(${desiredCapabilities}) )
    Connect To Browser          wss://cdp.browserstack.com/playwright?caps=${BSENCODEDCAPS}

It took some time, but with the help of a great colleague I was able to get this.