Limit characters of a message payload

Hello,

For a new project I am creating, I receive a message payload that has an unlimited lenght of characters.
E.g: sometimes 20, sometimes 500

This payload will later on be used as a state of a sensor. We all know that a state has a limit of 255 characters.

Can anybody help me with how to limit the payload to 255 characters?
I would preferably do that with a “Change Node” (with Regex) or the “Template Node”, because I have that already in my flow and I can simply add the limitation to that node, but it may also be with a Function Node if there is no other way around it.

Hope somebody can help me, I have been stuck on this for 2 days…

Thanks in advance!