Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member197733
Contributor
In a recent blog we've explained how we build a sample food app that leverages several building blocks of the SAP Business Technology Platform, such as Cloud Platform Integration, and Conversational UI. More recently, I explained how we leveraged the SAP Workflow Service API, in the Business Technology Platform. In this blog we are going to understand how to use said APIs to create a low code integration with Qualtrics.

We've played with Qualtrics in the past, using the wide range of APIs available in its solutions. But today's approach is a bit different. Qualtrics will take a more active role, implementing the business rules and validations, while the Workflow Service will just receive a request to start a workflow instance using Qualtrics Actions.

The business scenario is a continuation of this demo:

https://www.youtube.com/watch?v=AUDrn5Sv950

 

The customer receives a Qualtrics Survey,  gives it a bad review and only in this case it is offered a free pizza -- vicious cycle, I know.

So let's see how we can do it with very minimal code:

Creating the Survey with conditional questions


First, we create a survey with the questions relevant to our scenario:



Then, we add the business logic to only show the 2 last questions in case the customer had a bad experience. We can do it without using any code, by clicking on Add Display Logic





 

So, after implementing the display logic for the last two questions it should be as following:


Triggering SAP Workflow Services from Qualtrics


Now that the UI part is completed, we can configure the initiation of a workflow instance every time a survey is completed. We can achieve that with Qualtrics Actions.

Qualtrics Actions are a simple way to trigger other systems based on survey events or timers. There are already several options of integrations pre-configured, and you can also create your own.

In the Actions tab, we start adding a new Event-based action:



We want to trigger it every time a Survey is responded.



That is, a survey is created:



So now our action is ready to be "coded"



The first step is to add a new condition



We want to make sure we have the data we need to trigger the workflow. That will also mean that the customer isn't happy and deserve a free meal. Also, we are going to move forward and add a new task. This time to connect to the workflow service using its APIs:



 

As explaining in my previous blog, exploring the SAP Workflow Service API's. In order to be able to start a workflow instance, there is a previous step to handle the authentication. This can be easily achieved choosing the Web Service Task type:



This is a simple step, that just require populating the parameters explained in the previous blog. I also set a basic authentication where the user and password are the Client ID and Client Secret of the workflow instance running on the Business Technology Platform.



If this web service calls works, its response should be an authentication token. This token can then be used on a subsequent request, in order to start a workflow instance.

To make things easier, we are going to add a new task, after the first web service call, of the type code. But don't worry, we just need a couple lines of it. As following:
function codeTask() {
const data = < REPLACE WITH PIPED DATA FROM QUALTRICS >
return {token: "Bearer "+ data.access_token}
}

 

Piped text is a very interesting feature from Qualtrics that allows you to have access to all sorts of dynamic data generated on your survey. In our case, we want to use the piped text (aka access token)  that comes as a response from the first web service call.

We use the option in the code task window. And that will change our code to:



This will help us in a subsequent web service task. That should be configured as the following:



URL: The endpoint for the workflow-instances, in this case: https://api.workflow-sap.cfapps.eu10.hana.ondemand.com/workflow-service/rest/v1/workflow-instances

Authorization: A pipe text with the return of the code task created previously. When asked to set a field, choose token

definitionId: the workflow definition that you want to trigger.

context: the payload accordingly to the workflow definition. In my case as following.
{"recipient":"${q://QID4/ChoiceTextEntryValue}", 
"orderData":{"CustomerName":"🙁 Customer via Qualtrics",
"CustomerEmail":"${q://QID4/ChoiceTextEntryValue}",
"ProductID":"PZ00001"}}

Attention for the 2 pipe texts used to set the recipient of the workflow task.

After saving the whole action should be as following:



 

And once we try our customer survey



And check if the action was triggered in the Reporting Tab.

https://i.imgur.com/fJxelf6.png

Everything looks fine. Now let's take a look at the SAP Workflow Inbox

et voilà!


That was how to integrate Qualtrics with the Business Technology Platform Workflow Service with a low code approach. If you have any comments please put them down below. Thank you for reading, and you can also find me on Twitter. @Ralphive 🐥