You should likely read and try examples in Dev Guide specifically focusing on executeActions() of the Widget Prontoscript Object extension. There are also other posts in this forum discussing limitations and other points.
Search executeActions and you'll find quite a few hits