Nikita Chursin 4e34545c85 fixed docker-compose | 2 years ago | |
---|---|---|
api | 3 years ago | |
config | 3 years ago | |
redis | 3 years ago | |
structs | 2 years ago | |
telegram | 3 years ago | |
.gitignore | 3 years ago | |
Dockerfile | 3 years ago | |
Makefile | 2 years ago | |
README.md | 2 years ago | |
docker-compose.yml | 2 years ago | |
go.mod | 3 years ago | |
go.sum | 3 years ago | |
server.go | 3 years ago |
This is the bot, that converts Salesforce RU Careers from Google Form responses to Telegram posts.
.env
file:
BOT_TOKEN=<yout bot token>
CHANNEL=@<your channel>
const fieldMaps = {
// <question text>: <field name in code>
// e.g.:
"Кого ищете?": "position",
"Компания": "company",
"Город": "city",
"Зарплата": "salary"
} function onSubmit(e) {
const form = FormApp.getActiveForm();
const formId = form.getId();
const allResponses = form.getResponses();
const latestResponse = allResponses[allResponses.length - 1];
const responseId = latestResponse.getId();
const response = latestResponse.getItemResponses();
const payload = {};
for (let i = 0; i < response.length; i++) {
const question = fieldMaps[response[i].getItem().getTitle()];
const answer = response[i].getResponse();
payload[question] = answer;
}
payload.formId = formId;
payload.responseId = String(allResponses.length - 1);
payload.editUrl = latestResponse.getEditResponseUrl();
var options = {
"method": "post",
"contentType": "application/json",
"payload": JSON.stringify(payload)
};
UrlFetchApp.fetch(BOT_URL, options);
}; ```
NB: This instruction is not perfect for sure for multiple reasons. Feel free to contribute to the repo!