You should look at
Tutorial: How To Write Block Libraries
How to write a rule template
Telegram: Process Answer