Only this pageAll pages
Powered by GitBook
1 of 7

Webhooks

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Outbound Connection

Outbound Connection defines and sets up the external system’s URL and authentication that are common to one or more endpoints defined by the External Adaptor.

Figure 2 - Layout of an Outbound Connection

The standard layout (from v11.3 Update 16), now displays credential fields appropriate to the authentication method selected.

Setting
Description

Base URL Fail-over

Where you have specified a secondary URL, the fail-over logic will become enabled.

If Base URL 1 does not respond after the retry count, set in the Export Adaptor, the system will then fail-over to Base URL 2.

Assuming Base URL 2 is successful, all following triggers will continue to first be sent to Base URL 2.

If Base URL 2 fails to respond, then the system will fail-over back to Base URL 1.

If both Base URLs are unavailable, the system will give up after the fail-over Base URL fails to respond. (it will not continue to flip-flop between Base URLs)

Export Adaptor Logs

When Export Adaptors are enabled for logging, all Export Adaptor communications will be logged into the Export Adaptor Log to assist with auditing and troubleshooting. (By default, logging is enabled for all adaptors.) From the navigation menu, click System and click Export Adaptor Logs to view the log entries.

Figure 9 - Export Adaptor Logs List

Click the ID in the Export Adaptor Log No column to view the details of a log entry, including all relevant values such as date times and request/response payloads.

Figure 10 - Export Adaptor Log Entry

There is an Action Menu item on individual documents to display a filtered Export Adaptor Log for that specific document. For example, when viewing a Work Order, the Action Menu item filters the log entries to that specific Work Order only.

Description

Enter a label for the connection, such as the name and version of the external system or interface.

External Key

Optionally enter a label to identify the external system, as with any Xytech document.

Authentication Method

Select the method used to log in to the external system: - Basic - Enter the Username and Password, below. - API Key – Enter the Key and Value pair into the Username and Password fields. - OAuth2 - Enter Authorization URL, Client ID, Secret and Scope.

Base URL 1

Base URL 1 is required. (exclude any trailing '/')

Base URL 2

Base URL 2 is optional. (exclude any trailing '/')

Export Adaptor Logs on the Work Order Action Menu

To prevent the log tables from growing exponentially due to large payload values, a periodic clean-up process removes the request and response payloads from "old" log items. The system retains the log entry that provides information that the payload was sent but removes the payloads. The default setting for this process is to clean up log items older than 60 days. This setting can be manually overwritten if required via the Application Server configuration settings.

Action Menu

Auto Log Clean-Up

Export Adaptor

Export Adaptors define the endpoint(s) for an Outbound Connection. An Export Adaptor is assigned to a specific Event Trigger so that the triggered payload knows where to be sent.

Figure 3 - Layout for External Adaptor Setup

Setting
Description

Description

URL Parameters can be added to endpoints that include a combination of static text and dynamically populated values from the triggered document. Use the same field naming convention when defining the payload template for an Event Trigger.

Examples:

  • Endpoint field: order/external_key=[jm_job.external_key]

  • Endpoint field: order/job_no=[jm_job.job_no]/jm_episode]

Tips and Troubleshooting

Email Notification of a failure

If you want to be notified by email or an alert pop-up when a webhook fails to send or receives an error response, you can set up an additional Event Trigger on the Export Adaptor Log with a condition set to trigger on receiving an error response status code (or whatever is the most appropriate trigger condition for your integration).

Troubleshooting

Trigger Condition Report While testing an Event Trigger, it’s recommended to validate the trigger conditions by using the Event Trigger Report run from the modified record to check whether the trigger condition is met prior to saving the record. You can find this on the Action Menu - Document

Test by Creating a Mock Web Service using Postman There are many ways to create a mock Web service for testing. One of the easiest is to use tools such as Postman (https://www.postman.com/) or WireMock (https://wiremock.org/).

Known Issues

URL Parameters not populated using GET method (v11.0)

In some scenarios, when configuring an Export Adaptor to include a URL parameter with a value that's a document field, the parameter fails get populated.

A workaround that forces the parameter to be populated correctly, is to additionally add the field to the Alert Template of the Event Trigger. The Alert Template does not need to be configured to actually send the alert (by omitting any alert users). e.g.

This issue is not present from v11.1 onwards.

Webhooks Introduction

Introduced from release v10.4 this feature enables users, through the Xytech UI, to configure triggers that send API payloads to external Web service endpoints. This mechanism allows external systems to initiate workflows based on Xytech-generated trigger events.

This feature enhances the existing Event Trigger functionality by adding a new notification type. Setup items:

  • Outbound connection - Stores the connectivity details of the external endpoint

  • Export Adaptor - Stores one or more endpoints for an Outbound Connection

  • Event Trigger - Trigger condition, payload structure and fields used to dynamically generate the JSON or XML payload to send to an Export Adaptor's endpoint.

Figure 1 - Webhooks Related Data Objects

What's New

Webhooks Export Adaptor logs have been enhanced to include an event identifier so all logs for the same triggered event can be identified and grouped. This now avoids the initial additional log entry so that all log entries now relate to an attempted message send.

The webhooks feature now has the ability to deactivate Export Adaptors or Outbound Connections. This can be very useful especially when restoring a backup onto a test or development instance to prevent accidental outbound integrations from happening to production external services. (26565)

Export Adaptors now includes an optional flag to send all dates in ISO standard format. (27017)

Export adaptor payloads can include an array of values from child tables. The syntax requires the array fields to be nested under child table tags using specific syntax as shown in the example below.

The JSON syntax must be manually managed around these table tags. You can drag and drop fields from the child table onto the template text area where the prefix syntax of the table name will be automatically applied.

An example Export Adaptor payload template for a Media Order Event Trigger that includes a list of Services and a list of Operations.

Enter a label for this adapter, such as the purpose and criteria of the message.

Output Type

Select the type of system to which messages will be sent. Currently, only REST is supported.

Output Format

Select the standard used to format outbound data, either JSON or XML.

Response Format

Select the expected standard format for the response payload (if a response is expected).

Output Method

Select the method or verb used to send messages. Available options include POST, PATCH, GET, PUT and DELETE.

Connection

Select the Outbound Connection to use for this Export Adaptor.

Endpoint

Add the endpoint of the API and include the initial backslash. E.g. /orders. The endpoint can include URL Parameters, as described in below If there is no endpoint and the payload can be sent to the base URL, simply add a forward slash ‘/’ into the endpoint field.

Retry Count

If there is no response from the endpoint, the retry count defines the number of times the system will attempt to send the payload before trying the other Outbound Connection URL (if one has been defined).

Retry Delay

If there is no response from the endpoint, the retry count defines the number of times the system will attempt to resend the payload. After completing the reties, the Export Adaptor will fail-over to the Outbound Connection URL (if more than one URL has been defined). Zero = no retries after first attempt.

Time Out

The duration in seconds to wait for a response from the endpoint.

Disable Logging

Select (check) to stop capturing activity into the Export Adaptor Log.

Headers

Provides the ability for the webhook to send custom headers and whether they are to be treated as Content Headers (default = false). Note: in this release you cannot add a Content-Type override from the system generated one e.g 'application/json' when JSON is the outbound format. This is possible from v11.1

URL Parameters

Note: This will make the template non-JSON standard. The template syntax will be validated as Xytech compliant on save.

Example payload generated:

Please note that the tables cannot be nested within each other, only one level of sub-tables is supported. No restrictions on which table is used to setup the trigger conditions as the code is document based. In other words, if your document is Media Order, you could use any sub table in the trigger conditions and all the available sub tables could be used in the template. (24750)

You are now able to add a custom header of 'Content-Type' to an Export Adaptor that will override the default generated Content-Type header. Note: you must flag the custom header as a Content Header.

Webhooks Export Adaptor logging has been enhanced so that errors are logged when the error occurs prior to being able to execute the API call. This gives greater logging visibility to users especially when in the past no log entry would be created and the user would have no awareness.

Webhooks Export Adaptor Template now includes encoding of whitespace characters.

Webhooks now includes the ability to store value(s) received in the response body into a field from the triggered document.

This allows Xytech to store the ID generated by an external system as a result of a web hook POST that creates the record. See Export Adaptor

When configuring an Export Adaptor to use URL parameters, to include a filed in the URL the field name is now prefixed by table name (as opposed to DOC) which makes it clearer to understand it's source.

Given the introduction of the response parsing feature, it now makes sense to add the GET method as an option.

Webhooks, Event Trigger - Export Adaptor payload template will now accept JSON payloads that start with square brackets. The JSON validator will no longer object.

#[<child table name>]
	<fields>
#[/<child table name>]

v26.1

Export Adaptor Log - includes trigger event identifier and removes initial log entry

v11.3

Ability to disable Export Adaptors or Outbound Connections

ISO Datetime formats

Ability to include child-table field values

{
  "document": "MoMediaOrder",
  "id": "[jm_work_order.wo_no_seq]",
  "idField": "wo_no_seq",
  "details": [
		{
	       "services": [
			    #[mo_service_row]
		        {
		          "description": "[mo_service_row.service_desc]",
		          "service_row_no": "[mo_service_row.service_row_no]"
		        }
			    #[/mo_service_row]
		        ],
			"operations": [
		    	#[mo_operation]
			     {
			           "service_row_no": "",
			           "description": "[mo_operation.trx_resource_code]",
			           "op_no": "[mo_operation.operation_no]"
				 }
				#[/mo_operation]
				 ]
		}
	],
	"type": "UPDATE"
}
{
  "document": "MoMediaOrder",
  "id": "109483-1",
  "idField": "wo_no_seq",
  "details": [
    {
       "services": [
               {
          "description": "Color Program/Review - Per Hr",
          "service_row_no": "50094"
        },
              {
          "description": "Color Program/Review - Per Hr",
          "service_row_no": "50095"
        },
              {
          "description": "142 Digital Receipt",
          "service_row_no": "229496"
        }
      
        ],
      "operations": [
                {
          "service_row_no": "",
          "description": "",
          "op_no": "71032"
        },
                {
          "service_row_no": "",
          "description": "",
          "op_no": "71033"
        }
        
      ]
    }

  ],
  "type": "UPDATE"
}

v11.1

Export Adaptor custom headers override default

Export Adaptor Logs improved capture of failures

Encode illegal characters in outbound payload

v11.0

Response payload parsing and storing of values

URL Parameters now use table names (not DOC prefix)

GET is added as an Export Adaptor method

Export Adaptor square brackets allowed

v10.6

Ability to define custom headers for Export Adaptors

Enhanced URL fail-over logic for Outbound Connections

v10.4

Webhooks Feature Introduced in v10.4

Event Trigger

The Webhooks functionality builds on the existing Event Trigger features of Xytech, providing a notification template option where you can assign an Export Adaptor and the payload template.

The Event Trigger defines the criteria that determine when a payload is sent, the method and content of the payload, and the Export Adapter to which it is sent.

  • The Event Triggers and Conditions tabs determine the criteria of when to send payloads.

  • The Notifications tab determines the method used to send the payload.

  • The Notification Template tab determines the destination of the trigger content.

Refer to the Online Help for more information about Event Triggers and how to configure them.

Event Trigger

Defines the field conditions that initiate a trigger, such as when a specific field is set or modified.

Event Trigger Conditions

Establishes the notification type – select ‘Email/Alert’ for webhooks.

Event Trigger Notification Type

Defines the action to take for the trigger.

Event Trigger Layout for Export Adaptor

Select the Export Adaptor to use.

Click to generate a standard payload template for the selected Document, Event Type, and Export Adaptor.

If any of the Document, Event Type, or Export Adaptor Type definitions change, you should re-generate the default template which will overwrite the previous template. If manual changes have been made to the template, you can update manually or note the additions prior to regenerating the template and reapply the changes.

  • Displays the payload template used to generate the payload.

  • Either in JSON or XML format. (The format of the template should match the format specified in the Export Adapter that will use the template.)

  • Syntax validation will occur when saving the Event Trigger and you will not be able to save if the template contain invalid JSON/XML syntax.

Dragging a field from the Template Fields list into the payload template.

v11.3

Export adaptor payloads can include an array of values from child tables. The syntax requires the array fields to be nested under child table tags using specific syntax as shown in the example below.

The JSON syntax must be manually managed around these table tags. You can drag and drop fields from the child table onto the template text area where the prefix syntax of the table name will be automatically applied.

An example Export Adaptor payload template for a Media Order Event Trigger that includes a list of Services and a list of Operations.

Note: This will make the template non-JSON standard. The template syntax will be validated as Xytech compliant on save.

Example payload generated:

Please note that the tables cannot be nested within each other, only one level of sub-tables is supported. No restrictions on which table is used to setup the trigger conditions as the code is document based. In other words, if your document is Media Order, you could use any sub table in the trigger conditions and all the available sub tables could be used in the template.

Web hooks includes the ability to store a value(s) received in the response body back into a field from the triggered document.

Note: This means that if an Operation in a Media Order generated a trigger, you can update a field in the Operation and not the Media Order or other related documents.

This allows Xytech to store the ID generated by an external system as a result of a web hook POST that creates the record.

Supported is the parsing of scalar and single values to be read and stored. Not arrays or JSON objects.

Can only store values back into the originating document, not related documents.

The Export adaptor includes a ‘Response Format’ parameter to define the expected response format.

Figure 1 - Response Format

If you don’t specify a content type , the default will be plain text. The storing of Notes and Blob base64 image values is supported.

The Event Trigger includes a new field to define the Export Adaptor’s ‘Response Parsing Template’.

Here you will add the parse criteria in the format of: <table name.field name> = response.<parse field>.

Figure 2 - Response Parsing Template

Example response payload:

Note: always include the response prefix.

If the originating document was Title and you wanted to store the 'id' value into ‘external_key’, then it would look like this: [lib_title.external_key] = response.data.id

You can store more than one value from the response payload: e.g.: [table.field1] = response.data.id [table.field2] = response.data.desc

To parse an XML response, use XPATH syntax. W3Schools XPath tutorial: https://www.w3schools.com/xml/xpath_intro.asp

Simple parse: [lib_title.external_key] = response/desc

An attribute of an element: [lib_title.external_key] = response/catalog/book/@id

Return all values under /response as text [lib_title.title_desc_2] = response

Example XML:

[lib_title.external_key] = response/catalog/book/@id returns the first id 'bk101' [lib_title.title_desc_2] = response/catalog/book[@id='bk102']/title returns 'Midnight Rain'

Where a text response is configure, the system will store the whole text payload. If the response value returned is too big to store in the target field, it will get truncated. Any existing values in the database will get overwritten with the new value.

Example: [lib_title.title_desc_2] = response

The prefix of 'response' is mandatory to represent the response payload.

It is important to ensure the data type or the target field matches the parsed field.

In other words, you will not be able to store a string value into a numeric field.

Else you will see a response parsing error in the Exp[ort Adaptor Log: "System encountered problem with saving Parsed Response into Database"

Document

Select the data object for the trigger.

Doc Table Name

Select the sub-table of the document for the trigger.

Access

Select Global to trigger payloads for the entire system, or select an access method (Division or Work Group) to limit payloads to a specific subset of the system.

Division

When Access is set to Division, select the Division for which payloads will be sent. Only documents related to the selected Division will generate payloads.

Work Group

When Access is set to Work Group, select the Work Group for which payloads will be sent. Only documents related to the selected Work Group will generate payloads.

Users can add document fields to the payload using the syntax [table.fieldName]. Additionally, users can drag and drop a field from the Template Fields list on the left into the payload template field. Note. You can only include fields on the template from the primary triggered document and not from related tables.

Active

Select (check) to make this payload active, or deselect (clear) to stop sending messages for this payload.

Event Code

Use the event code of NOTIFY

Event

Description of the trigger

Event Type

Select when to trigger:

INSERT sends messages when a record is first created.

UPDATE sends messages when a record is modified.

DELETE sends messages when a record is deleted.

Event Trigger options described

Conditions

Notifications

Notification Template

Export Adaptor Trigger Details

Generate Default Template

Export Adaptor Template

Include child-table field values

Parsing and storing of response payload values

Configure Export Adaptor's response format

Event Trigger Response Parsing Template

To Parse JSON

To Parse XML

Text Response

TIP

#[<child table name>]
	<fields>
#[/<child table name>]
{
  "document": "MoMediaOrder",
  "id": "[jm_work_order.wo_no_seq]",
  "idField": "wo_no_seq",
  "details": [
		{
	       "services": [
			    #[mo_service_row]
		        {
		          "description": "[mo_service_row.service_desc]",
		          "service_row_no": "[mo_service_row.service_row_no]"
		        }
			    #[/mo_service_row]
		        ],
			"operations": [
		    	#[mo_operation]
			     {
			           "service_row_no": "",
			           "description": "[mo_operation.trx_resource_code]",
			           "op_no": "[mo_operation.operation_no]"
				 }
				#[/mo_operation]
				 ]
		}
	],
	"type": "UPDATE"
}
{
  "document": "MoMediaOrder",
  "id": "109483-1",
  "idField": "wo_no_seq",
  "details": [
    {
       "services": [
               {
          "description": "Color Program/Review - Per Hr",
          "service_row_no": "50094"
        },
              {
          "description": "Color Program/Review - Per Hr",
          "service_row_no": "50095"
        },
              {
          "description": "142 Digital Receipt",
          "service_row_no": "229496"
        }
      
        ],
      "operations": [
                {
          "service_row_no": "",
          "description": "",
          "op_no": "71032"
        },
                {
          "service_row_no": "",
          "description": "",
          "op_no": "71033"
        }
        
      ]
    }

  ],
  "type": "UPDATE"
}
{
    "data": {
        "desc": "This is sample description.",
        "id": "ABCEFJ23454"
    }
}
<?xml version="1.0"?>
<catalog>
     <book id="bk101">
        <author>Gambardella, Matthew</author>
        <title>XML Developer's Guide</title>
        <genre>Computer</genre>
        <price>44.95</price>
        <publish_date>2000-10-01</publish_date>
        <description>An in-depth look at creating applications 
        with XML.</description>
     </book>
     <book id="bk102">
        <author>Ralls, Kim</author>
        <title>Midnight Rain</title>
        <genre>Fantasy</genre>
        <price>5.95</price>
        <publish_date>2000-12-16</publish_date>
        <description>A former architect battles corporate zombies, 
        an evil sorceress, and her own childhood to become queen 
        of the world.</description>
     </book>
</catalog>