Skip to main content
Question

Zapier code does not run even though it works on vscode

  • February 22, 2021
  • 3 replies
  • 169 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'
              }
          })
      })
  })

Did this topic help you find an answer to your question?
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

Danvers
Forum|alt.badge.img+12
  • Zapier Staff
  • 3731 replies
  • March 1, 2021

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 🙂

 


Metagrate_John4man
Forum|alt.badge.img+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.

 


Danvers
Forum|alt.badge.img+12
  • Zapier Staff
  • 3731 replies
  • May 4, 2021

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: