Some things I can see immediately are:
Any API interact() call will return a boolean. This will be true when the interaction successfully occurred and false if it failed, combine this with if statements to make sure you're not sleeping when the interaction call failed.
Don't use random sleeps, you can definitely use a conditional sleep when waiting for a widget to appear.
You don't want to use static IDs to grab widgets as these can change a lot, instead use the widget debugger to find something to filter the widget on, for example the text the widget contains.