Definitely. As mentioned above, the functions triggered by clicking the "OK" and "Cancel" buttons are not executed by the computer. You'll have to implement a check to determine if the hero belongs to the AI, and if so, immediately direct them to the function associated with the "OK" button.
Added 10 minutes later
Or a special function for the AI.
Of course, if you are processing the bot's interaction, then checks are definitely needed.
Будь яростней пред ночью всех ночей,
Не дай погаснуть свету своему!
Хоть мудрый знает – не осилишь тьму
Во мгле словами не зажжёшь лучей –
Не уходи безропотно во тьму.