Question

Zapier code does not run even though it works on vscode

  • 22 February 2021
  • 3 replies
  • 134 views

Hi, I am creating a zap that will broadcast to all subscribed users on telegram. it worked on my vscode but the zap does not produce anything, is there anything wrong with my codes?

 

let token = TOKEN;

await fetch(`https://stickybot-server.glitch.me/user/getAllUsers`)
  .then(res => res.json())
  .then(json => 
      {
      json.forEach(async user => {
          let data = {
              chat_id : user.userId.toString(), 
              text : "text"
          }
          await fetch(`https://api.telegram.org/bot${token}/sendMessage`,
              {
              method: 'POST',
              body: JSON.stringify(data),
              headers: {
                  'Content-Type': 'application/json'
              }
          })
      })
  })


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 7
Badge +12

Hi @yeqmxplc!

 

Did @Metagrate_John4man suggestion help here? We’d love to know if sending your credentials to the url did the trick :slight_smile:

Userlevel 4
Badge +1

Hi @yeqmxplc --

Is this a complete snippet of your code? If so, I presume you need credentials for your call to https://stickybot-server.glitch.me/user/getAllUsers. Return those results to Zapier and confirm you’re getting the expected response before making the remaining calls.

 

Userlevel 7
Badge +12

Hi @yeqmxplc! When you say that the Zap doesn’t produce anything, could you elaborate?

Is the hook not being sent to Telegram? Does it go but then hit an error message (if so, what’s the error?), or is it being received ok, but nothing is being sent? Thanks for helping us to understand the issue 🙂