That's where you should assign the action. You also have there the option to execute the script every X seconds. Don't forget to name it.
You can use this, works fine for me:
{
"BTTWidgetName" : "Battery Percentage",
"BTTTriggerType" : 639,
"BTTTriggerTypeDescription" : "Apple Script Widget",
"BTTTriggerClass" : "BTTTriggerTypeTouchBar",
"BTTPredefinedActionType" : -1,
"BTTPredefinedActionName" : "No Action",
"BTTEnabled2" : 1,
"BTTUUID" : "6A30B5CB-A8FA-4541-BD70-41E0D917AC13",
"BTTEnabled" : 1,
"BTTModifierMode" : 0,
"BTTOrder" : 59,
"BTTDisplayOrder" : 0,
"BTTMergeIntoTouchBarGroups" : 0,
"BTTTriggerConfig" : {
"BTTScriptType" : 0,
"BTTTouchBarButtonColor" : "75.323769, 75.323769, 75.323769, 255.000000",
"BTTTouchBarItemIconWidth" : 22,
"BTTTouchBarButtonFontSize" : 16,
"BTTTouchBarItemPlacement" : 1,
"BTTTouchBarAlternateBackgroundColor" : "75.323769, 75.323769, 75.323769, 255.000000",
"BTTTouchBarButtonCornerRadius" : 6,
"BTTTouchBarScriptUpdateInterval" : 20,
"BTTTouchBarAppleScriptString" : "set batteryPercent to word 6 of paragraph 2 of (do shell script \"pmset -g batt\")\r\rif batteryPercent < 10 then\r\treturn \"{\\\"text\\\":\\\"\" & (batteryPercent as string) & \"\\\", \\\"font_color\\\": \\\"255,0,0,255\\\"}\"\relse\r\treturn \"{\\\"text\\\":\\\"\" & (batteryPercent as string) & \"\\\", \\\"font_color\\\": \\\"255,255,255,255\\\"}\"\rend if",
"BTTTouchBarAppleScriptStringRunOnInit" : false,
"BTTTouchBarButtonName" : "Battery Percentage",
"BTTTouchBarAppleScriptUsePath" : 0,
"BTTTouchBarFreeSpaceAfterButton" : 5,
"BTTTouchBarItemIconHeight" : 22,
"BTTTouchBarItemPadding" : 0
}
}