Webhook Action

Applies to Infiniti v9.2 or later
 
 
A Webhook is a simple HTTP publish and subscription model for passing information between services. With the Webhook action you can call your own HTTP endpoint when a form is submitted and optionally include form answers. This means all your connector logic can remain in an external service that can be updated and load balanced separately.
 
The service call is made as a POST and the body of the request contains the JSON payload. Service response codes determine if the action is considered to have failed or completed. This action does not deal with generated documents.
 
Manage
There are 2 Manage level connector settings that provide the defaults for all the Webhook actions to be used in the account.
 
 
 
Default Webhook URL Endpoint: The URL of your service, must be accessible via the web server.
 
Default Secret Key: User provided API key that is sent to and validated by your service. Prevents other people calling your service.
 
 
Design
 
The action appears as "Post to Webhook" and it has 3 inputs and 2 outputs.
 
Inputs
 
  1. Webhook URL Endpoint: The URL of your service.
 
 
 
 
  1. Answer Values: Optional values and question references that you want to send to your service. Same format as the SQL Server action's parameters, @name=[q1] <linebreak>
 
*Only Fixed Value are supported in Answer Values. Other reference types - Data Question and Answer value are not supported.
 
 
  1. Secret Key: User provided API key that is sent to and validated by your service.
 
 
 
Outputs
 
  1. Response Body Output: The HTTP response body that was returned from your service.
 
  1. Response Code Output: The HTTP response code that was returned from your service.
 
 
 
 
 
Example Payload
{
  "action": "My Action Name",
  "created": "2015-11-24T04:34:46.8659932Z",
  "secretKey": "MySecret",
  "sender": {
    "userGuid": "405f36cf-81e0-4c4d-b08a-197d97a195e3"
  },
  "project": {
    "projectName": "Webhook",
    "projectGroupGuid": "d74f6aa1-1039-4ad7-9646-c3ea68a1fdca",
    "runId": "00e32b92-0b20-4b28-a3b0-64555431d6ee"
  },
  "values": {
    "q1": "1",
    "q2": "2",
    "myValue": "abcdef"
  }
}
 
Example WebAPI Endpoint
using Newtonsoft.Json.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
 
namespace WebApplication2.Controllers.Api
{
  public class WebhookController : ApiController
  {
    public HttpResponseMessage Post([FromBody] JObject data)
    {
      if ((string)data["secretKey"] != "MySecret")
      {
          return new HttpResponseMessage(HttpStatusCode.Forbidden);
      }
 
      // Process data[values] dictionary
 
      return new HttpResponseMessage(HttpStatusCode.OK);
    }
  }
}

 

Related Articles

 

 

Keywords

 

webhook action http publish subscription model endpoint submit post json payload