My First 2 Workflows Were Working, Then Stopped... Clockify > Discord

Hey everyone,

I am new here, and still learning. But I had 2 Workflows set up for Clockify Time Tracking App to Discord. So that when someone Clocks In or Out, it would send a message to Discord. And they were working just fine for a few hours, and I was just testing out every type of output, to see what each one truly does. After some hours of doing that, I found all the ones I wanted, tested it, and it worked.

Then I just re ordered them in the the message that gets posted to Discord, just to look neater, and all of a sudden they stopped working?

But then I got a Test to work, but still won’t work again when I run an actual Clock In or Clock Out.

Can anyone take a look at it or help in any way?

I provided a Screenshot

@info-96a03d Could you do me a favor and:

  1. Visit your workflow’s Settings and share the workflow with Pipedream support?
  2. Send an email to support@pipedream.com with the URL of your workflow, and a link to this post so we can reference the issue?

We can take a look at your workflow’s configuration and help you figure it out.

Thanks for the share. The issue is that you’re referencing some fields that don’t exist on all of your events. For example, if you examine the event data on those failed events, Clockify doesn’t appear to send all the fields. So you’re trying to reference variables like {{steps.trigger.event.body.project.name}} and {{steps.trigger.event.body.task.name}} when neither steps.trigger.event.body.project or steps.trigger.event.body.task exists.

I’d recommend either:

  1. Filter the events. This lets you exit the workflow early when events don’t contain all the information you want.
  2. If you still want to send events in these cases, but just want to fill in default values for the missing fields, you can using the optional chaining and nullish coalescing operators. For example, this code will return “No project” and “No task” in the message when those fields are missing:
Project Name: {{steps.trigger.event.body?.project?.name ?? "No project" }}
Task: {{steps.trigger.event.body?.task?.name ?? "No task" }}

You’ll need to set that logic for any fields that might be missing in the incoming Clockify events.

Let us know if that helps!

Thank you so much for the swift replies!

I will give that a try, but the thing is, that it was working for a bit? I attached Screenshots

Any way that we could just get it to work fully? Thanks!

That’s right, it would work for events that had project / task data included. But not all of the incoming events contain that data. Try inspecting the incoming event data in your trigger step for the events that work and don’t work. You’ll see that the events that fail to send to Discord don’t contain steps.trigger.event.body.project or steps.trigger.event.body.task.

This is quite common when developing workflows. In many of the workflows we build internally, we receive many events that might be missing required data. You’ll want to either filter the events or handle the absence of the data with the example code I shared above. I’m not sure exactly how you’d like to handle this case, so take a look at those two options and see what might work best for your use case!

I also noticed that Clockify webhooks support sending different types of events to the destination URL in Pipedream. Is it possible you’re sending different types of events to Pipedream? That would explain why some contain the fields you expect, and others don’t.

I have 1 Webhook set up for Click In and one for Clock Out.

But they use 2 different URLs so that shouldn’t effect it right?

That’s correct, that should not. If it’s unexpected that you’re not getting the data you need on those events, you may want to reach out to the Clockify team and show them the sample events. They may be able to tell you why the events don’t contain the project / task data.

Hmm I got them firing every time now, but its only using my information when my employees Clock In & Out?

Also, finally got my profile info filled out on here, and I sent ya an Linked In invite

Hi Tim,

I believe I see the issue.

The extra Clockify - Get User action you have in your workflow is retrieving user details from the account associated with the API key you shared to Pipedream - which happens to be your account.

Instead, you can remove that action and use the event data from the webhook itself.

For example steps.trigger.event.body.user.name contains the name of the person clocking in or out (depending on the event).

If you need to look up more details, be sure to modify the Clockify action to retrieve the details of that specific person, and not your own account.

I hope this helps!

1 Like

You are a Legend Pierce!

But also why is it always showing MY IP Address, rather than theirs? Even though I am using “steps.trigger.event.client_ip” and not “steps.clockify…”

And is there a way to use their Discord (or Clockify) Profile Picture rather than mine or the PipeDream logo?

Also is there a way so that when it spits out…

“START Time: 2022-07-26T21:07:48Z
END Time: 2022-07-26T23:10:39Z
Duration: PT2H2M51S”

I could clean it up a bit? Such as change it to a 12 hour day rather than 24, and just remove the Seconds all together, to make it look more like…

“START Time: 2022-07-26 9:07 pm
END Time: 2022-07-26 11:10 pm
Duration: 2 Hours 2 Min”

And also how do I get it synced to be on a set time zone that I actual choose?

Right now its not on my time zone, nor the businesses, nor my employees lol

Hi Tim,

Lots of good questions, thanks. Let me try to answer them!

But also why is it always showing MY IP Address, rather than theirs? Even though I am using “steps.trigger.event.client_ip” and not “steps.clockify…”

I can see how that’s confusing - but remember the end user isn’t calling your Pipedream HTTP endpoint directly from their browser, it’s Clockify that’s performing the webhook.

The steps.trigger.event.client_ip is Clockify’s server IP address that’s performing the webhook. That’s why it’s not changing from event to event.

And is there a way to use their Discord (or Clockify) Profile Picture rather than mine or the PipeDream logo?

I assume you’re referring to the last step in your workflow, which is to send a message to Discord. Have you tried passing a URL to the Avatar URL prop in the Send Message pre-built action?

The Clockify action should include a photo photo URL under the profilePicture export. Full path would be steps.clockify.$return_value.profilePicture.

Also is there a way so that when it spits out…

“START Time: 2022-07-26T21:07:48Z
END Time: 2022-07-26T23:10:39Z
Duration: PT2H2M51S”

I could clean it up a bit? Such as change it to a 12 hour day rather than 24, and just remove the Seconds all together, to make it look more like…

“START Time: 2022-07-26 9:07 pm
END Time: 2022-07-26 11:10 pm
Duration: 2 Hours 2 Min”

And also how do I get it synced to be on a set time zone that I actual choose?

Good question! When it comes to time formatting, I’m a big fan of date-fns

We covered how to use date-fns in a Node.js code step in this video in our University series:

Follow that video as an example to format your timestamps into an easier to read format and to convert it to your own timezone instead of UTC.

So is there anything that I can use instead of the “steps.trigger.event.client_ip” to gather the IP then?

And as for the Photo, I actually do have what you recommend in that field, but that’s what doesn’t seem to be working? “steps.clockify.$return_value.profilePicture”
Is there something else I should be using there?

And I’m going to watch those videos later, so thank you! But mainly the photo thing is what Im most worried about fixing, if you know what’s wrong there?

Thanks!

Hi Tim,

So is there anything that I can use instead of the “steps.trigger.event.client_ip” to gather the IP then?

All depends on if Clockify can pass this information forward in their webhook. I encourage you to read their webhook documentation or ask their support if this is possible.

They control what data is shared in these webhooks, but their might be a way.

And as for the Photo, I actually do have what you recommend in that field, but that’s what doesn’t seem to be working? “steps.clockify.$return_value.profilePicture”
Is there something else I should be using there?

From the shared workflow, it seems that the Avatar URL property isn’t populated in the Discord - Send Message action.

Can you try populating it and seeing if that works?

So I have populated both of them now (it seems that it was just 1 of the 2 clock ins and clock outs, that wasn’t populated) However, it is just sending MY default picture each time, now the actual Clockify User that is Clocking In or Out…

Kind of the same problem I was having before with using Clockify’s Codes rather than Discords. Do you know which one I should be using instead?

Hi @info-96a03d

I just recommend experimenting and reading the API documentation for both Clockify or Discord!

If you need further support, please consider upgrading to a Team or Enterprise plan for dedicated Slack support.

Or contacting a Pipedream Partner to help you with this request.