Hi everybody,
Here is an example how to sendDocument (attachment) from bot to chat: it is based on a “code” action.
And the code is:
var url = inputs.url;
// I’ve got multiline text from HTTP Get Action on previous step and here is a trick to put it into the variable correctly
var myText = (function () {/{{summary_extraction.result}}
/}).toString().match(/[^]/*([^])*/}$/)[1];
var opts = {
method: ‘POST’,
url: ‘https://api.telegram.org/bot<YOUR_BOT_API_KEY>/sendDocument’,
formData: {
chat_id: {{new_message.channel_id}},
caption: ‘Summary_{{ask_a_question.parsed_answer}}.txt’,
document: {value: myText,
options:{
filename: ‘Summary_{{ask_a_question.parsed_answer}}.txt’,
contentType: ‘text/plain’
}
}
}
};
utils.request(opts, function(err, resp, body) {
if(err) {
return reject(err);
}
resolve(body);
});