Skip to content

Instantly share code, notes, and snippets.

@juvoni
Last active March 8, 2022 23:14
Show Gist options
  • Save juvoni/7daa2d00716b0334b142262a3585be5e to your computer and use it in GitHub Desktop.
Save juvoni/7daa2d00716b0334b142262a3585be5e to your computer and use it in GitHub Desktop.
Burning Man Zapier to Telegram Bot
  1. Create an account on https://botfather.io/accounts/login/
  2. Message @BotFather in telegram
  3. Go through the bot creation process with /start. At the end you will receive a token, which you will need later on.
  4. Add the bot to your channel of choosing as an admin.
  5. Write a message so their is message history.
  6. Go to https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates and copy the id from the chat response.
  7. You send fetch post requests that have the token in the url and a chat id in the request body, as shown in the example below.
  8. You can use Code By Zapier, with a Javascript input to run a similar snippet.
const template = `
❤️ <b>${inputData.name}</b> has been <b>Approved</b> to join Camp.
`;

await fetch(`https://api.telegram.org/bot${inputData.token}/sendMessage`, {
  method: 'POST',
  cache: 'no-cache',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    chat_id: inputData.chatId,
    text: template,
    parse_mode: 'HTML',
    disable_web_page_preview: true,
  })
}).then(res => res.json()).then(json => callback(null, json)).catch(callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment