A person intends it specifically, whether it is an obligatory act or a voluntary one, for indeed actions are only by intention, and indeed a person will have only what he intended, according to the ruling of the chosen Prophet, peace and blessings be upon him.
Alqamah bin Waqas Laithi narrates that I heard Sayyiduna Umar bin Khattab (may Allah be pleased with him), he was saying that I heard the Messenger of Allah (peace and blessings be upon him) say that the acceptance of deeds depends upon the intention. Yahya bin Habib has added these words, "And indeed every person will get only that which he intended."