Google Slides in Gsuite Integration

I have a script that connects ERPNEXT with Google DOCS. The problem is that when I create a word document it does replace the variables, but when it is a Slide it does not replace the text that is in a text box.

I already tried various combinations in replaceAllText but they don’t work for me.

Someone will know what I’m doing wrong

Thanks in advance

// ERPNEXT GSuite integration
//

 function doGet(e){
   return ContentService.createTextOutput('ok');
}

function doPost(e) {
  var p = JSON.parse(e.postData.contents);

  switch(p.exec){
    case 'new':
      var url = createDoc(p);
      result = { 'url': url };
      break;
    case 'test':
      result = { 'test':'ping' , 'version':'1.0'}
  }
  return ContentService.createTextOutput(JSON.stringify(result)).setMimeType(ContentService.MimeType.JSON);
}

function replaceVars(body,p){
  for (key in p) {
    if (p.hasOwnProperty(key)) {
      if (p[key] != null) {
        body.replaceText('{{'+key+'}}', p[key]);
      }
    }
  }    
}



function createDoc(p) {
  if(p.destination){
    var folder = DriveApp.getFolderById(p.destination);
  } else {
    var folder = DriveApp.getRootFolder();
  }
  var template = DriveApp.getFileById( p.template )
  var newfile = template.makeCopy( p.filename , folder );

  switch(newfile.getMimeType()){
    case MimeType.GOOGLE_DOCS:
      var body = DocumentApp.openById(newfile.getId()).getBody();
      replaceVars(body,p.vars);
     break;
  
    case MimeType.GOOGLE_SHEETS:
      //TBD
    case MimeType.GOOGLE_SLIDES:
     var presentation = SlidesApp.openById(newfile.getId())
      for (key in p) {
        if (p.hasOwnProperty(key)) {
          if (p[key] != null) {
            presentation.replaceAllText('{{'+key+'}}', p[key], true)
          }
        }
      }
      break;
  }
  return newfile.getUrl()
}