Webhook firing twice in a row

Hi all. First time working with Webhooks and had a question. My device checks for a value every X minutes. When that happens it then checks a sensor. If the sensor value is higher than expected, it sends a text via SendGrid then an email via MailGun. The text message is always firing twice. Looking at the logs it shows the Webhook firing twice, despite me calling it once. I even changed to code to update the ‘tick’ variable in case it was some code synchronous thing. The code (slightly modified) is below. Anything standing out?

int tick = 0;
void loop() {
  // Check every 5 minutes
  if((int)Time.now() >= tick+300) {
    if(functionName() >= (float)threshold) {
      // call webhook for texting
      tick = (int)Time.now();
      Particle.publish("txt-webhook-name", String(functionName(), 2), PRIVATE);
      // call webhook for email
      Particle.publish("email-webhook-name", String(functionName(), 2), PRIVATE);
    tick = (int)Time.now();


Instead of checking the integration log, check the Events log when it fires. It’s possible that there is only a single event being generated by the device, but multiple webhooks are firing. Some common reasons:

  1. Non-unique prefix. The event name is a prefix, so if you have two webhooks, “test” and “test2”, the event “test2” will trigger both webhooks because “test” will prefix match “test2”.

  2. Duplicate webhook. When you create one via the CLI, it creates a new one, leaving any old one in place and both will trigger.

  3. Same webhook prefix in both the device owner account and a product. Both will fire.

Wow, thanks, I bet it’s the prefix. I updated the names and flashed the device. Someone else has the device, so I need for them to get back to me if this fixed it. I’ll report back.

Edit: That worked, thanks so much! Not sure how I missed that.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.