So I decided to let Sheets do the conversion and then I will fetch the result and return it to the requester. However, I remember that Google Sheets could actually call Google Finance within its cell. I did some searching but I could not find any built-in class in order to do the conversion within the code. I could either invoke a curl-like method by calling an external API (which is not related to Google) or just manipulating whatever Google Finance offers. There are at least two possible ways to create a currency converter bot with Telegram and Google Apps Script. Return sendMessage(id, "The word that you key in will be kept for our analysis purpose\nPlease use this format : word, source language code, target language code \nRefer /translate/docs/languages") Return sendMessage(id, "The translation of " item " is " myTranslationOutput) Sheet.appendRow(, item, item, myTranslationOutput]) Var myTranslationOutput = anslate(item, item, item) Var formattedDate = dateNow.getDate() "/" (dateNow.getMonth() 1) Var sheet = SpreadsheetApp.openById(ssId).getSheetByName( "") UrlFetchApp.fetch( '' token '/', data) In addition to fetching the input from the users, I also wanted to store the searched word inside a Google Sheets spreadsheet. The translation capability is invoked with anslate(text, sourceLanguage, targetLanguage). Google Apps Script can be used to manipulate the Google Translate capability by calling the Language.App class. So I found a class that I could use in Apps Script to realize that. Although there are undoubtedly tons of mobile apps out there which do the same thing, I wanted to learn about it by using Telegram. One way to use the Telegram Bot and Google Cloud Services which came to mind was to create a translation bot. After receiving Telegram’s API key we can use it inside our Google Apps Script editor. The initial process of creating a Telegram bot is outlined on Telegram’s website. In this post I will share a bit on how to adapt Mars’s code and use Telegram Bot to get the input from the user and let Google Apps Script call Google’s cloud-based services (translation and finance) to later return the outputs to the user. The Telegram Bot I created from Mars’s code looks like this: Coincidentally, last year I learned a bit about how to use Google Apps Script with Telegram Bot as a personal ledger tool, as outlined in this post by Mars Escobin. In a previous post on this blog, Afif wrote about how to use Google Apps Script with Google Forms.
0 Comments
Leave a Reply. |