How to integrate a webhook with a third party web service or application

Making HTTP POST Requests to TelemetryTV Webhooks

TelemetryTV offers Webhook services for actions which can be sent to Devices, Metrics and Overrides on your account. This can be done by sending a HTTP POST request to a designated URL called a 'webhook tag' along with your API authorization key. The coded example below demonstrates how Webhooks can be integrated in code to trigger a Metric update and Override to display in your App.

Webhooks can be integrated effectively as shortcuts to specific access points in your API i.e. instead of stating the API path and service/device IDs you can configure your webhook tag to handles these values. This not only makes code more comprehensive for use with third party apps but also means that you can easily create or delete authorization of your webhooks without having to delete an entire API key.

2872

A Device Webhook configured to Control a Specific Device with Pause command upon POST to URL tag

Webhook Types

Since the Webhooks themselves handle the information there is little need to pass any additional Action parameters in the actual code itself, for example the Override Webhook request merely triggers an existing pre-configured override on your account. However, in the case of the Metric Webhook 'value' is typically assigned as the "Metric Query" parameter to allow updating metric value data. The Devices Webhook is similar to the Override webhook insofar as they are pre-configured for a single defined action. However, posting to a Device Webhook will targets a single predefined action for a specific device whereas an Override Webhook will target all devices on an account (or a sub-organization within the account).

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Token PASU2tA6GUAMLB2XpAQRgULxc6PwnUeF"); // Insert your TelemetryTV Authorization Key
var overrideTag = "wh58564487622948gh32628894282to5923"; // tags from TelemetryTV Webhooks Dashboard
var metricTag = "wh422653253hr827549473229ay4769929";		

function updateMetric(value) {
var webhook = metricTag;
var metric = value;
var data = { value: metric }; // 'value' is value assigned under the 'Metric   Query' paramater in the TelemetryTV Webhooks Dashbook
var raw = JSON.stringify(data);


				var requestOptions = {
					method: 'POST',
					headers: myHeaders,
					body: raw,
					redirect: 'follow',
				}

					fetch(`https://user-api.telemetrytv.com/webhooks/${webhook}`, requestOptions)
					.then(response => response.text())
					.then(result => console.log(result))
					.catch(error => console.log('error', error));

			};

				function playOverride() {
				var webhook = overrideTag;
          
				var requestOptions = {
					method: 'POST',
					headers: myHeaders,
					redirect: 'follow',
				}

					fetch(`https://user-api.telemetrytv.com/webhooks/${webhook}`, requestOptions)
				  .then(response => response.text())
				  .then(result => console.log(result))
				  .catch(error => console.log('error', error));

			};

// This function can be called with a value to update a metric while triggering a playlist. This could be configured to play a board override triggering the data to then display on screen instantly.

		function myWebhook() {
			updateMetric("InsertYourMetricData");
			playOverride();
		};

Integrating with Third-Party Services

Possibilities are endless with integrating your TelemtryTV Webhooks with third party services. Integrating with a third party application would take place by passing a HTTPS POST request directly from your Third Pary Application or through a Middleware application that handles the triggered request. Middleware software like Zapier could be used to send requests to your Webhook Tag URLs opening up the possibility of a plethora of integrations.

Zapier

Below is an example of the structure of a zap in which TelemetryTV Webhook can be integrated with Zapier Webhooks using your Webhook URL tag and API token to initiate a zap to push notifications for any new Intercom Conversations.

2878 2550

Another example use case would be of employing an emergency alert system, described below.

Use Case: Twilio SMS API

By using a programmable contact portal such as Twilio you can take a predefined SMS protocol using Twilio to trigger a Webhook once an SMS has been sent e.g. an emergency message. This can then integrate with your TelemetryTV device by triggering on override which pushes a notification slide to all screens in your organization. This could be done by invoking your Webhook function above whenever your Twilio API has received an emergency message. Alternatively, you could use a Zap to trigger a HTTP POST to your Webhook URL once an SMS is received.

By invoking Metric and Override webhooks concurrently you can send information to your screens instantaneously. Data can be sent in real-time to TelemetyTV via the MetricWebhook. This can be used to pipe data to individual metrics. Only sending a Metric Update Webhook request once your data has been updated may prove to be more useful than sending periodic updates from your entire database.

Displaying Real-time Data Notifications using Metrics and Override webhook

In the code example above, the override could be configured to communicate real-time event notifications i.e. a new customer has been added to your Database. This could be achieved by using the Metric specified in your 'updateMetric' Webhook as a value on a Board which is triggered as an Override by your 'playOverride' function in the coded example shown earlier.