Getting External Answer Data When the Interview Loads

Note: only users with the Integration Administrator user role can manage webhooks.

An Interview Load Event webhook enables HotDocs Advance to populate interviews with answer data retrieved from you own web application. This event activates when the user opens an interview.

Prerequisites

This webhook has the following prerequisites:

  • Creating a Webhook – you must have an existing webhook that:
    • Uses the Interview Load Event type
    • Has access to the work groups in which you want the webhook to apply
  • Answer JSON that matches the variable names and structure of the Author template
  • An endpoint on your web application that accepts a GET request and returns a set of answer data

Overview

When you create an interview load event webhook, you specify an endpoint on your web application that accepts a GET request and returns answer data. This answer data must be in the HotDocs answer JSON format. 

The GET request to the endpoint is activated when a user opens an Advance interview. When the data is returned to the interview from your endpoint, Advance overlays the answer data into the interview, populating the answer fields for your user.

Your Existing Webhook

This example supposes that you have an existing webhook with the following properties:

  • Name – WebhookExample02
  • URLhttp://localhost/WebhookExampleApp/GetAnswerData
  • Tokenexampletoken
  • Event Type Interview Load Event
  • Active StatusActive
  • Untrusted SSL certificatesNo
  • Work Groups - WorkGroupExample01

The URL for the webhook should point to the GET endpoint in your own web application.

Token

The token specified in the webhook is passed in the request sent to your endpoint, in the Authorization header. You should always use this token to authenticate requests from Advance to your own application.

Data Sent from Advance to your Endpoint

When the Interview Load Event webhook is activated by a user, the webhook sends a GET request to your endpoint. The request contains a JSON string that includes the following data:

  • linkedVariable — typically null; may be populated with data passed from a template link's linkdata property
  • userContextData — the user context data for the template; this includes details about the user that activated the webhook

For example:

{
    "linkedVariable": { "ParameterValue": null },
    "userContextData": {
        "UserId": "8727d822-7b4a-5f6d-ab56-781f498af6cc", 
        "UserFirstName": "John",
        "UserLastName": "MacDiarmid",
        "UserEmailAddress": "jm@example.com",
        ...
}

You can use this information when constructing the data you will return to Advance. For example, if you need to look up information specific to the user making the request.

Data Sent from your Endpoint to Advance

The response sent back to Advance from your endpoint must be a JSON string that conforms to the HotDocs answer JSON format. For example, this answer set returns values for text, number, date, true/false, and multi select variables:

"[
    {""n"":""textVar1"",""t"":""TX"",""v"":""Francis Smith""},
    {""n"":""numberVar1"",""t"":""NU"",""v"":123},
    {""n"":""dateVar1"",""t"":""DA"",""v"":""31 12 1999""},
    {""n"":""trueFalseVar1"",""t"":""TF"",""v"":true},
    {""n"":""multiSelectVar1"",""t"":""TL"",""v"":{""v"":[""Option A"",""Option B""]}}
]"

Getting Answer Data from an Existing Interview

You can use the HotDocs JavaScript API HD$.GetJSONAnswers function with an open HotDocs interview to quickly generate an example answer set. Running the command in the console of your browser's Developer Tools window retrieves the JSON answer data from the in-progress interview.

Validating Your Answer Data

You should validate your answer data before sending it to Advance. See Validating HotDocs Answer Sets for more information.