Skip to main content

Get FIDO Pre-reg shipment details

In this step we will configure the custom action that will call to the YubiEnterprise Delivery API to get the details about a FIDO Pre-reg shipment. When ready, this will include the finalized PIN and credential responses.

Before you proceed ensure that you have configured the connection alias and credential used for calling the YubiEnterprise API with your API token.

Action properties

On the ServiceNow home screen, search for flow designer.

Click Flow Designer, a new window should open.

Configuration menu

Once the Flow Designer page opens, click the Create new button, then select Action.

Configuration menu

A menu will appear to configure the action's properties. Use the following values to initialize your action.

  • Action name: YubiEnterprise get shipment (Pre-reg)
  • Application: YubiEnterprise Delivery App
  • Description: Get information about a specific YubiEnterprise FIDO Pre-reg shipment

Configuration menu

Click Submit.

Action inputs

Next we are going to configure the inputs that go into the action. These inputs are the parameters that are going to be passed into our API call by our flow.

For each row in the table below, perform the following steps:

  1. Click the +Create Input button at the top.
  2. Fill in the input using the data provided below to the corresponding field (note that name will be automatically input).
LabelTypeMandatory
Shipment IDStringon

Your actions input menu should look like the example below.

Inputs menu

Click Save once your inputs are complete.

API REST call

Next we will configure the action step for making the REST HTTP call to the YubiEnterprise Delivery API.

On the left side, in the Action Outline, click the bottom blue + button.

Add second action

Search for rest and select the REST option

note

If the REST option does not appear then you have not activated the IntegrationHub plugin. Follow the instructions in the prerequisites section.

Inputs menu

Connection details

First we will add our API credentials to the REST call. We will utilize the connection alias that was created earlier in this guide.

Ensure that the Connection field is set to Use Connection Alias.

Change the Connection Alias to the one created earlier in the guide. The Base URL should be set automatically based on the connection alias.

Your connection details should look like the example below.

Connection details final

Request details

Next we will configure the details of the API method call. We will be utilizing the GET /fpr/shipments/{id} API method

Configure the Request Details section with the following values:

  • Build Request: Manually
  • Resource Path: Type /fpr/shipments/ then drag the Shipment ID data pill to the end of the url (see the image below for an example)
  • HTTP Method: GET

The Headers should include two header properties using the values below

NameValue
Acceptapplication/json
Content-Typeapplication/json

Your request details should look like the example below.

Request details final

Output script

We will now create a script to format the outputs of the action. This will ensure that we are able to not only capture data from a successful shipment, but to identify and understand potential errors with our shipment.

On the left side, in the Action Outline, click the bottom blue + button.

Action outline 3

Search for scripts and select the Script option

Script action step

Script inputs

We'll start by creating the input for the script. We will only create one input, which will be the result of the previous REST step call

  1. Click the +Create Variable button
  2. Name: responseBody (case sensitive)
  3. Value: Drag the Response Body data pill from the REST step section on the right side of the menu

Your script inputs menu should look like the example below.

Script action step

Adding the script

Next we are going to add a script to Script field. Copy the script provided below into the Script field.

(function execute(inputs, outputs) {
const response = JSON.parse(inputs.responseBody);

const shipment_state_id = response.shipment_state.shipment_state_id;
outputs.shipment_state_id = shipment_state_id;

if (shipment_state_id === 103 || shipment_state_id === 104) {
//Assuming only one shipment for POC
const shipment_item = response.shipment_items[0];

//Assuming only one product data item
const product_data = shipment_item.product_data[0];

outputs.serial_number = product_data.serial_number;
outputs.firmware_version = product_data.firmware_version;
outputs.pin_response = product_data.fido_pin_response;

//Assuming only one credential for POC
outputs.cred_response = product_data.fido_credential_responses[0];
}
})(inputs, outputs);

Script outputs

Lastly, we will add the output variables for the script

For each row in the table below, perform the following steps:

  1. Click the +Create Variable button at the bottom.
  2. Fill in the input using the data provided below to the corresponding field (note that name will be automatically input).
LabelTypeMandatory
shipment_state_idIntegeron
serial_numberStringoff
firmware_versionStringoff
pin_responseStringoff
cred_responseStringoff

Your script outputs menu should look like the example below.

Script outputs

Click Save once your output script is complete

Action outputs

Lastly we will define the outputs of the action. These outputs will be usable by the final flow that will orchestrate the ordering experience. We want to ensure that the action outputs are able to express details about the shipment, and any issues should they have occurred.

We will start by clicking the Outputs tab in the Action Outline pane.

Action outline outputs

Next we are going to configure the outputs.

For each row in the table below, perform the following steps:

  1. Click the +Create Output button at the top.
  2. Fill in the input using the data provided below to the corresponding field (Note: Unlike the previous examples, the Name field is not auto-populated).
LabelNameTypeMandatory
Status Codestatus_codeStringon
Shipment State IDshipment_state_idIntegeron
Serial Numberserial_numberStringoff
Firmware Versionfirmware_versionStringoff
PIN Responsepin_responseStringoff
Credential Responsecred_responseStringoff

Your actions outputs menu should look like the example below.

Inputs menu

Once complete, press the Exit Edit Mode button on the top of the menu.

A new menu should appear showing the outputs you just defined with empty Value fields. For each output, you will add a data pill from the REST step and the second Script step sections on the right side of the menu

Use the table below to correlate the correct data pill to a label.

LabelSection > Data pill
Status CodeREST step > Status Code
Shipment State IDScript step > shipment_state_id
Serial NumberScript step > serial_number
Firmware VersionScript step > firmware_version
PIN ResponseScript Step > pin_response
Credential ResponseScript step > credential_response

Your actions outputs menu should look like the example below.

Inputs menu

Click Save once your outputs are complete

Publish the action

If everything looks good, click the Publish button at the top of the action menu to make the action available for all flows.