Hi all.
Perhaps someone can help me.
I need help from someone who understands the Telegram API.
Below is the code of a script which should work under certain conditions in Automations and send a message to a Telegram user via bot in an open chat with some data from the table.
At the moment the script sends an error
error_code: 400
description: "Bad Request: message text is empty"
The script works fine in the sandbox and sends messages. Not in Airtable.
Perhaps the problem is related to Airtable and its specific variables?
How do you think it is possible to solve this problem.
On Stack Owerflow people occasionally write about this problem, but their solutions have not helped me.
I would be grateful for an answer.
const token = 'ххх';
let inputConfig = input.config();
let message = `${inputConfig.first_name}, документ готов по заказу №${inputConfig.order}.<br>Вы можете скачать его <a href = "${inputConfig.doc_link}"по ссылке</a>.<br>Ждем Вас снова.<br>Ваш, RealEstate DocuService`;
console.log(`${message}`);
const options = {
method: 'POST',
Host: 'api.telegram.org:443',
headers: {
Accept: 'application/json',
'User-Agent': 'Airtable',
'Content-Type': 'application/json',
},
body: JSON.stringify({
text: `${message}`,
parse_mode: 'HTML',
disable_web_page_preview: true,
disable_notification: true,
reply_to_message_id: 0,
chat_id: `${inputConfig.chat_id}`
})
};
fetch(`https://api.telegram.org/bot${token}/sendMessage?chat_id=${inputConfig.chat_id}`)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));