title: What apps script function do I need to make my chatbot capable of reading and writing to sheets for the whole domain
body: <p>I got a bit stuck.</p>
  <p><strong>Goal:</strong>
  To have a chatbot that domain users can use to confirm shoppinglist that is kept in a google spreadsheets.</p>
  <p>The sheet that holds the data is generated based on forms input and manual input.
  I am looking for a chatbot because I wanted an interface that shows some basic in/output without sharing the whole spreadsheet.</p>
  <p><strong>What have I done:</strong></p>
  <p>I looked into service accounts and I am able to read data. I wanted a sheet object but I read that this is not possible. I get a JSON object. I will manage I think.</p>
  <p><strong>How do I write data to the sheet?</strong>
  The code under here only reads it. What function sends the data to sheets?</p>
  <pre><code>/**
   * Configures the spreadsheet service.
   */
  function getSpreasheetService() {
   return OAuth2.createService(&quot;spreadsheet&quot;)
   // Set the endpoint URL.
   .setTokenUrl(&quot;https://accounts.google.com/o/oauth2/token&quot;)
  // Set the private key and issuer.
   .setPrivateKey(SERVICE_ACCOUNT_PRIVATE_KEY)
   .setIssuer(SERVICE_ACCOUNT_EMAIL)
  // Set the property store where authorized tokens should be persisted.
   .setPropertyStore(PropertiesService.getScriptProperties())
  // Set the scope.
   .setScope(&quot;https://www.googleapis.com/auth/spreadsheets&quot;);
  }
  
  function readSheet(){
    var service = getSpreasheetService();
    var ssId = 'sheetsid' ;
    var range = 'Voorraad!A1:50';
    var url = 'https://sheets.googleapis.com/v4/spreadsheets/' + ssId +'/values/' + range;
    var response = UrlFetchApp.fetch(url, { headers: {Authorization: 'Bearer ' + service.getAccessToken() } }); //json data
    var rep = JSON.parse(response.getContentText());
    var values =  rep.values;
  
  console.log(response);
  console.log(rep);
   
  
  
  
  
    //  Logger.log(values);
    //now i can use these data to reply back to end user as message
  }
  </code></pre>