This option is not compatible with the new, collaborative actions feature. For more information on collaborative actions, see here.

iAuditor users often want to perform an action for each failed response in an inspection. For example, you may want an email to be sent for each failed response, which results in a new order being created in a work order management system. To execute one task per response, assuming the response meets a certain condition, you need to create a 2-Zap workflow using Zapier.

Step 1: Zapier trigger on inspection completion

  1. We’ll assume we want to send an email for every failed response in an inspection (audit), for every inspection conducted from a specific template.
  2. Register for a free or paid Zapier account.
  3. Log in and select “Make A Zap!”.
  4. You’ll be taken to a blank Zap template to select a trigger app. Your trigger app is iAuditor.
  5. Type “iAuditor” in the search box, and select to complete
  6. Test step, and proceed
  7. We want to set this Zap to trigger only from a specific inspection template, on inspection (audit) completion
  8. Select “Audit Completion” as the trigger.
  9. Note: If we wanted this Zap to trigger at any time, for any inspection (audit) that is conducted, we would select “Any Audit Completion” instead.
  10. Click “Save + Continue.”
  11. Now associate your iAuditor account with Zapier
  12. Click “Connect a New Account.”
  13. A separate window will pop-up prompting you to enter an API token.
  14. If you have generated an API token already, proceed to step 19. If you have not generated a token, click on the hyperlink “My Profile.”
  15. Zapier directs you the iAuditor web app
  16. Scroll to the bottom of the page and locate the box labeled “API”
  17. Generate an API Token from this box by entering your iAuditor password
  18. Click “Generate Token”
  19. Return to Zapier
  20. From here, you can copy/paste the token in  the space provided
  21. “Test” your account to ensure connectivity
  22. Zapier will return a “Success” message. If you encounter an error, feel free to reach out to us.
  23. “Save + Continue” to complete the first phase of setup

Step 2: Trigger action from failed item setup

  1. Return to the “Set Up Options” step
  2. Select the inspection template from above
  3. Hit “Continue.”
  4. Provided you have recently conducted an inspection from this template “Fetch and Continue” will complete the trigger setup
  5. For this workflow, the only Action required is Code by Zapier
  6. Select “Run Python”, then “Save + Continue”
  7. To configure the input data, type “audit_id” in the first Input Data field (exactly as shown, any deviation from this will cause an error)
  8. Select the audit_id value from the dropdown on the right column, as shown (below)
  9. Note: The correct audit_id should automatically pull in based on the inspection template you selected in the previous trigger
  10. A sample script appears in the code box.
  11. Delete the code that is pre-filled in the “Code” section of the Zap
  12. Copy and paste the following script in its place:

    — [code] —

    import requests
    auth_header = {'Authorization': 'Bearer YOUR_SAFETYCULTURE_API_TOKEN'}
    webhook_url = 'YOUR_WEBHOOK_URL'
    api_url = ''
    audit_id = input['audit_id']
    audit_doc = requests.get(api_url + audit_id, headers=auth_header).json()
    failed_items = []
    audit_author = audit_doc['audit_data']['authorship']['author']
    conducted_on = audit_doc['audit_data']['date_completed']
    conducted_on = conducted_on[:conducted_on.index('T')]
    audit_title = audit_doc['template_data']['metadata']['name']
    for item in audit_doc['items']:
        if item.get('responses') and item['responses'].get('failed') == True:
            label = item.get('label')
            if label is None:
                label = 'no_label'
            responses = item['responses']
            response_label = responses['selected'][0]['label']
            notes = responses.get('text')
            if notes is None:
                notes = ''
            failed_items.append({'label': label,
                'response_label': response_label,
                'conducted_on': conducted_on,
                'notes': notes,
                'author': audit_author
    for item in failed_items:
        r =, data = item)

    — [/code] —

  13. You’ll notice in the code there are two values which are not filled out.
  14. Value 1:  YOUR_SAFETYCULTURE_API_TOKEN. Replace the entire term, including the brackets with your actual API token
  15.  Value 2: YOUR_WEBHOOK_URL. Continue to the steps below to find this value.
  16. In a second tab, open Zapier in your browser again.
  17. Again, select “Make a Zap”.
  18. Select the trigger “Webhooks by Zapier,”
  19. Trigger type “catch hook”
  20. Click “Save + Continue,” and then skip past the next stage, where Zapier asks if you’d like to “Pick off a child key.” We do not want to.
  21. Leave it blank, and hit “Continue”.
  22. Now, we finally obtain our webhook URL.
  23. Return to the Zap tab that includes “Code by Zapier”
  24. Copy the webhook URL from the previous step, and place it into the Code by Zapier script
  25. Proceed to the “action” step of your “Code by Zapier” zap
  26. Scroll down and select “Continue”, then “Create and Continue”.
  27. Test for errors, with no errors, proceed.
  28. Select “Finish”, name your Zap and toggle it to On.
  29. Switch back to our second Zap (the Webhook Zap), and select “Okay, I did this”
  30. Your test should be successful, as completing the first Zap should have sent a request to this webhook.
  31. Hit “Continue” to move on to the next step, configuring the action which will be conducted every time a failed item is sent to the webhook.
  32. For this tutorial, we’ll use “Email by Zapier.” You can substitute this with any action you like.
  33. “Send Outbound Email” is the only option available for this action, so let’s select it and “Save + Continue” to configure the email.
  34. Select a valid “To” address and enter in a subject line.
  35. Choose the “Add Item” icon in the “Body” section.
  36. Here, you’ll see every value we sent to the webhook from the Code by Zapier script earlier.
  37. You can add any or all of these values, as well as free typing text
  38. The rest of the fields are optional – fill them out if you choose to, and then select “Continue” to test.
  39. You’ll see a preview of what would be sent. Select “Create + Continue” to test it.
  40. The “To” address you selected should receive a test email.
  41. You can safely delete this as it was to test the connection.
  42. Select “Finish”, name your Zap and turn it on, and you’re done!
  43. It’s a good idea now to test this workflow end-to-end by conducting an inspection (audit) from the template we set up in the first step, and selectively failing some items.
  44. The expected result is a single email per failed item.
Was this article helpful?

We love your feedback. Please tell us what you think.

Yes No
Care to share a bit more so we can continue to make improvements for you? Care to share a bit more so we can make this article even better for you? Thanks for your feedback!