Bots.Business - Help
  • Welcome
  • Getting started
  • Create bot from Google Table
  • App
    • Reset or Update Your Password
  • Commands
    • Answer
    • Aliases
    • Keyboard
    • Groups
    • Wait for answer
    • Auto Retry (AR)
  • Coding: BJS
    • Variables
    • Bot functions
    • Message broadcasting and editing
    • User functions
    • Properties
    • Always running commands
    • Error command: "!"
    • Lists
      • Migration from properties to list
    • Api functions
    • BB Admin functions
    • Admin Panel
    • Send HTTP request
    • Web App
    • Caching
    • Inline Bot
    • BJS Security
    • Good coding practices
    • Top errors
  • Git
    • Import bot from Git repository
    • Export bot to Git repository
    • Repository structure
    • File: bot.json
    • Automatic importing on Git push
  • Iterations. How to reduce theys?
  • Limitations
  • Cloud
  • Reports
  • Deep Linking - pass any params on Bot starting
  • How to link chat account with BB account?
  • BB Inspection
  • Protected bot
  • VS Code
  • How to...
  • Smart Bot
    • Overview
    • Lang File
    • SmartBot
    • SmartTasker
    • Amount Dialog
  • Libs
    • What it is - Libs?
    • Libs development
    • RefferalLib
    • ResourcesLib
    • Random
    • MembershipChecker (MCL)
    • Cooldown Lib
    • CurrencyConverter
    • Lang
    • TopBoardLib
    • QiwiPayments
    • Coinbase (CB)
    • CoinPayments (CP)
    • OxaPay
    • CryptoJS
    • CurrencyQuote
    • GoogleApp
    • GoogleTableSync
    • Guard
    • Webhooks lib
    • DateTimeFormat Lib
  • Store
    • BB Point Bot
    • Welcome bot
    • Help bot
    • SRB Demo Keyboard Tools
Powered by GitBook
On this page
  • Setup
  • Demo bot
  • Write or update data
  • Read data
  • Command /onSync

Was this helpful?

  1. Libs

GoogleTableSync

PreviousGoogleAppNextGuard

Last updated 3 years ago

Was this helpful?

You can post, update and read data from GoogleSpreadSheet with this lib.

Setup

2. Create blank Google table. You don't need any headers. Headers will be added automatically.

3. Also you need to run code too:

Libs.GoogleApp.setUrl("https://script.google.com/*************/exec");

Demo bot

Write or update data

Use index for magic!

With index key exist row will be updated!

You need tableID. You can get it from table url. It is selected here:

Bot.sendMessage("Saving...");

var syncOptions = {
  tableID: "1_NldI2**********ank1B9c",
  sheetName: "Users",
  // this column will be used as index for updates or reading
  index: "id",
  // store data
  datas: [],
  // this command will be runned after sync
  onRun: "/onSync",

  // for debug. Comment this lines
  // email: "hello@bots.business",
  // debug: true
}

user.balance = User.getProperty("balance");

syncOptions.datas[0] = user;

// you can add more records with index 
// syncOptions.datas[1] and etc 

Libs.GoogleTableSync.sync(syncOptions);

You can store any data like users, chats, products, resources and etc

Bot.sendMessage("Saving...");

var syncOptions = {
  tableID: "1_NldI2**********ank1B9c",
  sheetName: "Orders",
  // this column will be used as index for updates or reading
  index: "orderId",
  datas: [],
  // this command will be runned after sync
  onRun: "/onSync"
}

var order = {
   orderId: 10,
   title: "Order - " + String(user.id),
   amount: 15
}

syncOptions.datas.push(order);
Libs.GoogleTableSync.sync(syncOptions);

Read data

Bot.sendMessage("Reading...");

var syncOptions = {
  tableID: "1_NldI2**********ank1B9c",
  sheetName: "Users",
  // this column will be used as index for updates or reading
  index: "id",
  // reading data
  datas: [],
  // this command will be runned after sync
  onRun: "/onSync",

  // for debug. Comment this lines
  // email: "hello@bots.business",
  // debug: true
}

syncOptions.datas[0] = user;
// also you can use something like:
// syncOptions.datas[0] = { id: any_user_id }

// you can add more records with index 
// syncOptions.datas[1] and etc 


Libs.GoogleTableSync.read(syncOptions)

Command /onSync

Bot.inspect(options)

1. Please see setup for . This lib requires GoogleApp lib.

If you have any problems with this lib - use help from .

GoogleApp lib
GoogleApp lib
BB Google Spreadsheet DemoTelegram
Logo