Functions are used when there is a need in order to answer the user’s question. They are typically used for getting knowledge or taking real world action on behalf of the user.
A chatbot not being a chatbot will take high-quality rules about the need for the function right in the main function description itself.
It doesn’t take any special trigger. The AI decides when they are useful.