How can I execute AT commands received through bluetooth HC-06?

I have the following code in which if I write some AT commands(AT, AT+VERSION etc.) in the Serial Monitor they are being executed. If I send them with my phone through that bluetooth, nothing is executed. I want the board to execute the commands received through bluetooth as well. How can I do that ?

#include <SoftwareSerial.h>
    SoftwareSerial mySerial(4, 2); // RX, TX
    
    String command = ""; // Stores response of the HC-06 Bluetooth device
    
    
    void setup() {
      // Open serial communications:
      Serial.begin(9600);
      Serial.println("Type AT commands!");
      
      // The HC-06 defaults to 9600 according to the datasheet.
      mySerial.begin(9600);
    }
    
    void loop() {
      // Read device output if available.
      if (mySerial.available()) {
        while(mySerial.available()) { // While there is more to be read, keep reading.
          command += (char)mySerial.read();
        }
        
        Serial.println(command);
        command = ""; // No repeats
      }
      
      // Read user input if available.
      if (Serial.available()){
        delay(10); // The delay is necessary to get this working!
        mySerial.write(Serial.read());
      }
    }

iDaniel19:
I want the board to execute the commands received through bluetooth as well. How can I do that ?

Probably not with an HC-06.

The HC-06 is in AT when it isn't connected to anything. Conversely, when it is connected to something, it is not in AT mode and therefore not interested in acting upon AT commands.

You might be able to do what you want with an HC-05 by having the KEY pin permanently connected to a digital pin on Arduino, but I doubt that too as I understand you want the device to be in AT mode and comms mode at the same time, and I don't that is possible. I believe Arduino can do what you want, provided it gets its instructions from somewhere else.

I was trying to change the pairing pin (AT+PIN) using the phone that it's connected to, but from what you said I understand that it is not posssible. Thank you :D.