No It does not work that way, transactions are included in blocks and if your bot detects the address has already sent the transaction, meaning it has received at least 1 confirmation, then even if you prompt your system to send some bitcoin to the address at the time of notification, the network delay would have its effect and every new block has a delay of approximately 10 minutes before it is mined and it may be longer if there is higher network difficulty in finding the valid hash to confirm the transactions in the new block.
It depends on how the bot detects the transaction. If the bot is checking the blockchain it would be too late, but usually you'd monitor the mempool for a case like this.
Even if he monitors the mempool, he gets notification when the transaction has received at least one confirmation because before then the transaction has not been confirmed and from his explanation, he wants to send the second transaction as soon as the first one reaches its destination, meaning it must be confirmed first and in the mempool you use the transaction ID to track transactions that has been confirmed and not those that has been included in a block. to do this he would have access to the transaction ID, meaning the transaction have been created earlier and would only be broadcasted at a specified time.
something like this using mempool.space API
async function checkTxConfirmed(txid) {
const res = await fetch(`https://mempool.space/api/tx/${txid}`);
const confirmTX = await res.json();
return confirmTX.status.confirmed; // this would be true if transaction has been confirmed
}
He can monitor an address through the meempool, so when there is an unconfirmed transaction it is detected, it does not need any confirmation for this, and to try to make the transaction made by him go to the next block, he only has to include it with higher fees, although this does not guarantee success it will increase the chances of them being included together in the same block, achieving his goal of not knowing which tx was transmitted first because on paper, both will be in the same block.