Webhook
  • 30 Jan 2023
  • 2 Minutes to read
  • Dark
    Light

Webhook

  • Dark
    Light

Article Summary

The Webhook integration generates a unique endpoint in Torq (URL). You can send external events to this address or have users use it to trigger workflows. Torq webhooks recognize several content types, which are transformed to JSON format in Torq. This means that the event data will be accessible as key-value pairs from the event JSON.

You can also send unrecognized content types to a Torq endpoint (URL), but the data will not be transformed or structured.

Create a Webhook integration

Perform these steps in Torq.

  1. Go to Integrations > Triggers.
  2. Locate Webhook and click Add.
  3. Type a meaningful name for the integration instance.
  4. By default, the integration will work only with recognized content types. Check the Accept raw HTTP requests checkbox to work with unrecognized content types.
  5. (Optional) Add authentication headers as required. We recommend adding authentication headers for security purposes.
  6. Click Add to create the integration.
  7. Locate the integration and copy the URL link.
    Screenshot of creating a Webhook integration in Torq and copying the endpoint URL.
  8. Provide the integration URL (endpoint) in other platforms to pass events from the other platforms to Torq or use the URL as a hyperlink that users can click to trigger a workflow.

Recognized content types

Torq Webhooks recognize the following content types. Torq automatically converts XML and form URL-encoded formats to JSON and they are accessible from the event JSON.

  • application/json
  • application/xml
  • text/xml
  • application/x-www-form-urlencoded

Unrecognized content types

For an unrecognized content type to be ingested as an event in Torq, make sure you enable Accept raw HTTP requests mode. You can enable this mode when you create a new integration or by editing an existing integration.

If this mode is off, you'll get an error. When you send an unrecognized content type to Torq, the event data will not be accessible as key/value pairs from the event JSON. Rather, the data will be accessible from $.event.body in string form.

Screenshot of selecting to accept raw http response for a webhook integration.

To extract data from the event, such as IP addresses, email addresses, and so on, you'll need to use a step that extracts data, and pass the $.event.body expression as input.


Screenshot showing how to reference and access data from the webhook event.

Trigger workflows with the Webhook URL

The webhook URL (endpoint) can be embedded in the form of a hyperlink, for example, in service tickets (JIRA, ServiceNow). Users can click the link to trigger a Torq workflow straight from the ticket. The webhook URL can be entered in a browser for the same result.

You can also provide key and value pairs with the URL and have them available in the trigger event JSON.

Add key and value pairs to the webhook URL: https://hooks.torq.io/v1/webhooks/997f45e6- - - -ac483691e340?key1=value1&key2=value2&key3=value3


Screenshot of triggering a workflow by accessing the webhook URL in a browser.

 

The key and value pairs are available in the trigger event JSON and can be referenced during the workflow run.
Screenshot of the event log for the Webhook integration after triggering the workflow from a browser.



Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.