Last active
January 28, 2025 06:08
-
-
Save HirbodBehnam/324437df2a295298fa7ec39ac547b5d7 to your computer and use it in GitHub Desktop.
A google script to send submitted form results to a telegram bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inspired by https://github.com/Iku/Google-Forms-to-Discord | |
const BOT_API = "YOUT_BOT_API"; | |
const CHAT_ID = "CHAT_ID"; | |
function onSubmit(e) { | |
var form = FormApp.getActiveForm(); | |
var allResponses = form.getResponses(); | |
var latestResponse = allResponses[allResponses.length - 1]; | |
var response = latestResponse.getItemResponses(); | |
var result = ""; | |
for (var i = 0; i < response.length; i++) | |
result += response[i].getItem().getTitle() + " : " + response[i].getResponse() + "\n"; | |
var options = { | |
"method": "post", | |
"payload": { | |
'chat_id': CHAT_ID, | |
'text': result | |
} | |
}; | |
UrlFetchApp.fetch("https://api.telegram.org/bot" + BOT_API + "/sendMessage", options); | |
}; |
Works like a charm.
cool! thanks
Thank you bro!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello, I appreciate your work. Its really work fine on me. But when my respondenr upload some media like photo or video over G-form. The bot could read the media. Can you fix it? thanks