Just came across this question when looking for answers myself.
In case you failed to get it working, the only error is because the input to on run is a list. You want the first item in that list, so your truncating line should be:
set outputString to text 1 thru 500 of item 1 of input