Help with integrating Blynk code into sketch

I’m a bit of a blynk noob here, but here it goes…

I have built an electronic gate opener with an arduino and can open the gate via wireless keypad nicely. I have installed the blynk libraries and have been able to connect to the arduino to the blynk server.

My question is how do I incorporate my existing sketch into the GSM communication sketch? From what I have read I cannot place it in the void loop?

Any help is appreciated.

int gateOpen = 4;
int gateClose = 5;
int keypad = 12; //regular keypad
int exitOpener = 13; //exit sensor



void setup() {
  // put your setup code here, to run once:
  pinMode(gateOpen, OUTPUT);
  pinMode(gateClose, OUTPUT);
  pinMode(keypad, INPUT_PULLUP);
  pinMode(exitOpener, INPUT_PULLUP);
}

void loop() {
  // put your main code here, to run repeatedly:

  if (digitalRead (keypad) == LOW || digitalRead (exitOpener) == LOW)
  {
    digitalWrite(gateOpen, HIGH);
    delay(8000);
    digitalWrite(gateOpen, LOW);
    delay(10000);
    digitalWrite(gateClose, HIGH);
    delay(10000);
    digitalWrite(gateClose, LOW);
  }



}

Would something like this work?


// Select your modem:
#define TINY_GSM_MODEM_SIM800
//#define TINY_GSM_MODEM_SIM900
//#define TINY_GSM_MODEM_M590
//#define TINY_GSM_MODEM_A6
//#define TINY_GSM_MODEM_A7
//#define TINY_GSM_MODEM_BG96
//#define TINY_GSM_MODEM_XBEE

// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30

#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "authcode";

// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[]  = "hologram";
char user[] = "";
char pass[] = "";

// Hardware Serial on Mega, Leonardo, Micro
//#define SerialAT Serial1

// or Software Serial on Uno, Nano
#include <SoftwareSerial.h>
SoftwareSerial SerialAT(2, 3); // RX, TX

TinyGsm modem(SerialAT);


int gateOpen = 4;
int gateClose = 5;
int keypad = 12; //regular keypad
int exitOpener = 13; //exit sensor

void setup()
{
  // Debug console
  Serial.begin(9600);

  delay(10);

  // Set GSM module baud rate
  SerialAT.begin(115200);
  delay(3000);

  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  Serial.println("Initializing modem...");
  modem.restart();

  // Unlock your SIM card with a PIN
  //modem.simUnlock("1234");

  Blynk.begin(auth, modem, apn, user, pass);

   pinMode(gateOpen, OUTPUT);
  pinMode(gateClose, OUTPUT);
  pinMode(keypad, INPUT_PULLUP);
  pinMode(exitOpener, INPUT_PULLUP);
}

void loop()
{
  Blynk.run();
  
 if (digitalRead (keypad) == LOW || digitalRead (exitOpener) == LOW)
  {
    digitalWrite(gateOpen, HIGH);
    delay(8000);
    digitalWrite(gateOpen, LOW);
    delay(10000);
    digitalWrite(gateClose, HIGH);
    delay(10000);
    digitalWrite(gateClose, LOW);
  }

  
}