Strategic Software Consultant

I'm the partner of choice for many of the world's leading enterprises. I help businesses elevate their value through solution discovery, software development, design, QA, and consultancy services. As your Strategic Software Consultant, I work across many technology products and delivery teams. The scope of technology is broad, and it is my job to understand how your technology applications holistically support and connect to create a sustainable technology ecosystem. The ecosystem of technologies may span to 3rd party applications, in-house developed solutions, business intelligence, data integrations, and of course, SaaS applications.

Oracle Certified Specialist
Oracle B2C Service Cloud Oracle Integration Cloud Oracle Intelligent Advisor

Oracle Intelligent Advisor Transcript to PDF

First off, a big thanks to the Richard Napier at intelligent-advisor.com for his post Interview.fetch() TRANSCRIPT.

Goal

Create a PDF summary of all the interview questions asked and answers given during the interview.

Solution

To complete this task, we take advantage of the Intelligent Advisor’s interview.fetch() method introduced in version 21A. The use of Intelligent Advisor’s interview.fetch() method is a bit misleading since the method can POST, PUT, DELETE, PATCH, and GET. Oracle also created the pseudo method TRANSCRIPT, which we are using for this task. In short, the TRANSCRIPT method POST all the interview questions asked and answers given during the interview to your designated endpoint in the JSON format.

This is the sample TRANSRIPT payload request.

{
    "timestamp": "2021-01-20T04:02:44Z",
    "deployment": "StudentBenefits",
    "contextSessionValues": {
        "student_eligible": true
    },
    "screens": [
        {
            "screen": "Eligibility for Student Aid",
            "controls": [
                {
                    "type": "label",
                    "text": "Hi Lisa Smith"
                },
                {
                    "type": "label",
                    "text": "There are many grants, scholarships, loans and work-study programs available to help students throughout their university studies. "
                },
                {
                    "type": "label",
                    "text": "This interview will help you determine whether any of these resources may be appropriate for you."
                }
            ]
        },
        {
            "screen": "Basic Information",
            "controls": [
                {
                    "type": "input",
                    "text": "Name:",
                    "inputType": "text",
                    "entity": "global",
                    "instanceId": "global",
                    "attribute": "student_name",
                    "inputValue": "Lisa Smith"
                }
            ]
        },
        {
            "screen": "Family",
            "controls": [
                {
                    "type": "input",
                    "text": "How many people are in your family?",
                    "inputType": "number",
                    "entity": "global",
                    "instanceId": "global",
                    "attribute": "51a9ff94-8ba5-4033-ba38-e8296a6e53cd",
                    "inputValue": 5
                }
            ]
        },
        {
            "screen": "Satisfactory Academic Progress",
            "controls": [
                {
                    "type": "input",
                    "text": "Have you maintained satisfactory academic progress in college or career school?",
                    "inputType": "boolean",
                    "entity": "global",
                    "instanceId": "global",
                    "attribute": "6d334774-ca3c-4f92-9772-b95053312b24",
                    "inputValue": true
                }
            ]
        }
    ]
}

Step 1

The first step is to create an endpoint to accept the TRANSCRIPT request.  You create an endpoint using Oracle Integration Cloud or any web service application. In our case, the client is using Oracle B2B Service, so we created a PHP file named transcript.php and uploaded this to the File Manager. Ideally, we could have used the B2B Service custom controller, but all requests to a custom controller create a Tier 1 session, and our client is not licensed for Tier 1 sessions.

transcript.php

<?php
header('Content-Type: application/json; charset=utf-8');
$inputJSON = file_get_contents('php://input');
$jsonResponse = array('responseText' => null);
if(strlen($inputJSON))
{
    $data = json_decode($inputJSON);
    $jsonResponse['responseText'] .= '<table border="1" cellpadding="2" cellspacing="0">';
    $jsonResponse['responseText'] .= '<td colspan="2">'.$data->deployment.'</tr></td>';
    foreach($data->screens as $screenData)
    {
        $jsonResponse['responseText'] .= '<tr><td colspan="2">'.$screenData->screen.'';
        foreach($screenData->controls as $questions)
        {
            if($questions->type == 'input' && $questions->attribute != 'Transcript' && $questions->inputValue && !is_object($questions->inputValue))
            {
                $jsonResponse['responseText'] .= '<tr><td>' . $questions->text . '</td>';
                $jsonResponse['responseText'] .= '<td>';
                if($questions->inputType == 'boolean')
                {
                    $jsonResponse['responseText'] .= ($questions->inputValue) ? 'Yes' : 'No';
                } else{
                    $jsonResponse['responseText'] .= $questions->inputValue;
                }
                $jsonResponse['responseText'] .= '</tr></td>';
            }
        }
    }
    $jsonResponse['responseText'] .= '</table>';
}
echo json_encode($jsonResponse);
?>

In the transcript.php file, we ingest the TRANSCRIPT request sent by Intelligent Advisor interview extension. We parse this JSON string into a PHP object using json_decode method. We iterate through the object to get the questions and their respective answers while storing this data in a string. We’ve also included some HTML table formatting, so it looks presentable in out PDF file. Finally output this the JSON format. The Intelligent Advisor interview extension will use this JSON response.

Step 2

Upload the file to B2B Service File Manager by following the 6 steps below.

1. Configuration
2. File Manager
3. Select your Interface.
4. Choose ‘custom scripts’
5. Browse to the transcript.php file on your local machine.
6. Click ‘Go’

The resulting endpoint for your file is

https://example.custhelp.com/cgi-bin/example.cfg/php/custom/transcript.php

where example is your interface name.

Step 3

Create a new connection in your OPA Hub with the type “Interview Extension”.

Step 4

  1. Interview Attribute

Step 5

  1. Interview Extension
OraclePolicyAutomation.AddExtension({
  fullCustomInput: function (control, interview) {
    if (control.getProperty("name") === "transcript") {
      return {
        mount: function () {

          var opts = {
            connectionName: "OSvCTranscript",
            method: "TRANSCRIPT",
            transcriptVersion: "12.2.21",
          };

          try {
            interview.fetch(opts)
              .then(function (response) {
                let promise = response.json().then(function (json) {
                  control.setValue(json.responseText);
                });
              });
          }
          catch (e) {
            console.log(e.message);
          }
        }
      };
    }
  }
});

Step 6

Create Intelligent Advisor BI Publisher form as PDF

Step 7

Display PDF for download and attach to Incident.