This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Service Handling in Cliniko
The third use case in the Cliniko business scenario is service handling. This page describes the relevant tasks and the operations you use in the Cliniko connector and the other ESB connectors. It contains the following sections:
Overview
The flow for service handling is illustrated in the following diagram. The ESB connectors for Billomat, Formstack and Mandrill will be used to connect to each service.
Retrieving daily invoices, creating invoices and creating patients
Retrieve invoices issued for the current date from the Cliniko API using the listInvoices operation.
Retrieve the details of a patient from the Cliniko API using the getPatient operation related to the invoice.
Retrieve the clients e-mail from the Billomat API using the listClients operation in order to check if the patient exists as a client.
Create the client (patient) if they do not exist in the Billomat API using the createClient operation.
Create an invoice in the Billomat API using the createInvoice operation.
Complete the created invoice in the Billomat API using the completeInvoice operation.
Retrieve all settings from the Cliniko API using the getSettings operation.
Create the survey in the the Formstack API using the copyForm operation for the invoice.
Send the survey to the patient through the Mandrill API using the sendMessage operation.
Cliniko operations
Billomat operations
Formstack operations
Mandrill operations
Prerequisites
A form should be created in Formstack which is used as template ID to clone the form with the following fields:
Invoice ID (Short Answer field type - Hidden) : Make sure that this field is one before the last out of all the fields.
Cliniko Admin E-mail (Short Answer field type - Hidden) : Make sure that this field is the last out of all the fields.
Include three or more multiple choice questions to receive customer feedback (Radio button type).
When creating invoices in the Cliniko API make sure to add a note to the invoice which indicates for what the invoice has been made.
Samples
Sample Template for updating the fields in a form in Formstack
<?xml version="1.0" encoding="UTF-8"?>
<!-- This template updates the fields in a form in Formstack. -->
<template xmlns="http://ws.apache.org/ns/synapse" name="formstack_updateFieldContent">
<parameter name="apiUrl" description="Base endpoint URL of Formstack API." />
<parameter name="accessToken" description="API Key to access data of Formstack account." />
<parameter name="fieldId" description="ID of the field whose content needs to be updated." />
<parameter name="content" description="Content to add to the field." />
<sequence>
<property name="uri.var.apiUrl" expression="$func:apiUrl" />
<property name="uri.var.accessToken" expression="$func:accessToken" />
<property name="uri.var.fieldId" expression="$func:fieldId" />
<property name="uri.var.content" expression="$func:content" />
<header name="Authorization" expression="fn:concat('Bearer ', get-property('uri.var.accessToken'))" scope="transport" />
<payloadFactory media-type="json">
<format>
{
"default_value": "$1"
}
</format>
<args>
<arg expression="get-property('uri.var.content')" />
</args>
</payloadFactory>
<call>
<endpoint>
<http method="put" uri-template="{uri.var.apiUrl}/api/v2/field/{uri.var.fieldId}.json" />
</endpoint>
</call>
<!-- Remove custom Headers from the API Response -->
<header name="Access-Control-Allow-Origin" action="remove" scope="transport" />
<header name="X-AspNet-Version" action="remove" scope="transport" />
<header name="X-AspNetMvc-Version" action="remove" scope="transport" />
<header name="X-Powered-By" action="remove" scope="transport" />
</sequence>
</template>Sample Proxy for retrieving daily invoices from Cliniko, creating a completed invoice in Billomat, creating the patient as a customer in Billomat if they do not exist and creating and sending a survey via Formstack to the patient to retrieve feedback
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2005-2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!-- This scenario creates Invoices in Billomat and create Surveys in Formstack for Cliniko Invoices-->
<proxy xmlns="http://ws.apache.org/ns/synapse" name="cliniko_createInvoicesAndSurveys" transports="https http" startOnLoad="true" trace="disable">
<target>
<inSequence>
<!-- Formstack Properties -->
<property name="formstack.apiUrl" expression="get-property('registry', 'connectors/Formstack/apiUrl')" />
<property name="formstack.accessToken" expression="get-property('registry', 'connectors/Formstack/accessToken')" />
<property name="formstack.templateFormId" expression="json-eval($.formstack.templateFormId)" />
<property name="formstack.invoiceId" expression="json-eval($.formstack.invoiceIdLabel)" />
<property name="formstack.adminEmail" expression="json-eval($.formstack.adminEmailLabel)" />
<property name="formstack.productDetails" expression="json-eval($.formstack.productDetailsLabel)" />
<!-- Cliniko Properties -->
<property name="cliniko.apiUrl" expression="get-property('registry', 'connectors/Cliniko/apiUrl')" />
<property name="cliniko.apiKey" expression="get-property('registry', 'connectors/Cliniko/apiKey')" />
<!-- Billomat Properties -->
<property name="billomat.apiUrl" expression="get-property('registry', 'connectors/Billomat/apiUrl')" />
<property name="billomat.apiKey" expression="get-property('registry', 'connectors/Billomat/apiKey')" />
<!-- Mandrill Properties -->
<property name="mandrill.apiUrl" expression="get-property('registry', 'connectors/Mandrill/apiUrl')" />
<property name="mandrill.apiKey" expression="get-property('registry', 'connectors/Mandrill/apiKey')" />
<property name="mandrill.fromName" expression="json-eval($.mandrill.fromName)" />
<property name="mandrill.fromEmail" expression="json-eval($.mandrill.fromEmail)" />
<property name="beetrack.routeStatus" expression="json-eval($.status)" />
<!--Set the current date to issueDate parameter in Cliniko -->
<script language="js">
<![CDATA[
var currentDate = new java.text.SimpleDateFormat('yyyy-MM-dd').format(new java.util.Date());
var issueDate= 'issue_date:='+currentDate;
mc.setProperty('cliniko.invoiceIssueDate',issueDate);
mc.setProperty('cliniko.invoiceDate',currentDate);
]]>
</script>
<!--Call cliniko connector listInvoices method to list invoices issued for the current date -->
<cliniko.init>
<apiUrl>{$ctx:cliniko.apiUrl}</apiUrl>
<apiKey>{$ctx:cliniko.apiKey}</apiKey>
</cliniko.init>
<cliniko.listInvoices>
<query>{$ctx:cliniko.invoiceIssueDate}</query>
</cliniko.listInvoices>
<!-- START: Proceed only if the listInvoices method is successful -->
<filter source="$axis2:HTTP_SC" regex="200">
<then>
<property name="invoiceIndex" expression="0" scope="operation" />
<property name="cliniko.invoiceCount" expression="count(//invoices)" />
<!-- START: Proceed only if there is at least one invoice -->
<filter xpath="get-property('cliniko.invoiceCount') = 0.0">
<then>
<property name="id" value="{}" />
<property name="status" value="skipped" />
<property name="message" value="There are no invoices for the day" />
<call-template target="responseHandlerTemplate">
<with-param name="id" value="{$ctx:id}" />
<with-param name="activity" value="cliniko_listInvoices" />
<with-param name="status" value="{$ctx:status}" />
<with-param name="message" value="{$ctx:message}" />
</call-template>
<loopback />
</then>
<else>
<!--BEGIN : FOR EACH invoice -->
<iterate continueParent="false" id="invoices" expression="//invoices" sequential="true">
<target>
<sequence>
<property name="cliniko.invoiceId" expression="json-eval($.invoices.id)" />
<property name="cliniko.netAmount" expression="json-eval($.invoices.net_amount)" />
<property name="cliniko.patient" expression="json-eval($.invoices.patient.links.self)" />
<property name="cliniko.notes" expression="json-eval($.invoices.notes)" />
<!--Get the patient ID from the response -->
<script language="js">
<![CDATA[
var patientUrl = mc.getProperty('cliniko.patient');
var patient=patientUrl.substring(patientUrl.lastIndexOf('/') + 1);
mc.setProperty('cliniko.patientId',patient);
]]>
</script>
<!--Call cliniko connector getPatient method to get details of a patient -->
<cliniko.init>
<apiUrl>{$ctx:cliniko.apiUrl}</apiUrl>
<apiKey>{$ctx:cliniko.apiKey}</apiKey>
</cliniko.init>
<cliniko.getPatient>
<patientId>{$ctx:cliniko.patientId}</patientId>
</cliniko.getPatient>
<property name="cliniko.patientId" expression="json-eval($.id)" />
<property name="cliniko.patientEmail" expression="json-eval($.email)" />
<property name="cliniko.patientFirstName" expression="json-eval($.first_name)" />
<property name="cliniko.patientLastName" expression="json-eval($.last_name)" />
<property name="cliniko.patientCity" expression="json-eval($.city)" />
<sequence key="removeResponseHeaders" />
<!--Extract billomat-createCompletedInvoiceSeq to create a completed invoice -->
<sequence key="billomat-createCompletedInvoiceSeq" />
<!--Extract formstack_createAndSendSurveySeq to create and send surveys to the patient -->
<sequence key="formstack_createAndSendSurveySeq" />
<property name="invoiceIndex" expression="get-property('operation','invoiceIndex') + 1" scope="operation" />
<filter xpath="get-property('operation','invoiceIndex') = get-property('cliniko.invoiceCount')">
<then>
<loopback />
</then>
</filter>
</sequence>
</target>
</iterate>
<!--END : FOR EACH invoice -->
</else>
</filter>
<!-- END: Proceed only if there is at least one invoice -->
</then>
<else>
<property name="id" value="{}" />
<property name="status" value="error" />
<property name="message" expression="json-eval($.)" />
<call-template target="responseHandlerTemplate">
<with-param name="id" value="{$ctx:id}" />
<with-param name="activity" value="cliniko_listInvoices" />
<with-param name="status" value="{$ctx:status}" />
<with-param name="message" value="{$ctx:message}" />
</call-template>
<loopback />
</else>
</filter>
<!-- END: Proceed only if the listInvoices method is successful -->
</inSequence>
<outSequence>
<property name="messageType" value="application/json" scope="axis2" />
<payloadFactory media-type="json">
<format>{
"Response":{
"process":"Cliniko_createInvoicesAndSurveys",
"activityResponse":[$1]
}
}</format>
<args>
<arg expression="get-property('operation', 'responseString')" />
</args>
</payloadFactory>
<send />
</outSequence>
</target>
<description />
</proxy>Sample request for retrieving daily invoices from Cliniko, creating a completed invoice in Billomat, creating the patient as a customer in Billomat if they do not exist and creating and sending a survey via Formstack to the patient to retrieve feedback
{
"formstack": {
"templateFormId": "2166848",
"invoiceIdLabel": "Invoice Id",
"adminEmailLabel": "Cliniko Admin Email"
},
"mandrill": {
"fromName": "Hello Doctor - Medi Care",
"fromEmail": "yasasitest@gmail.com"
}
}Note
The following are the parameter descriptions:
formstack.templateFormId:The ID of the form that would be used as a template to create forms for each patient.formstack.invoiceIdLabel:Label name of the field in which the invoice ID of the Cliniko API would be saved.formstack.adminEmailLabel:Label name of the field in which the administrator's e-mail of the Cliniko API would be saved.mandrill.fromName:Name of the company/person to be used as the sender name when sending the surveys.mandrill.fromEmail:E-mail of the company/person to be used as the sender's e-mail when sending the surveys.
Gathering responses of surveys and sending them
Retrieve administrator details from the Cliniko API using the getSettings operation.
Retrieve all the forms from the Formstack API using the listForms operation.
If the form has been created two weeks prior, delete the form from the Formstack API using the deleteForm operation.
Retrieve all submissions for the form from the Formstack API using the listSubmissions operation.
Retrieve the details of the submission with all the field values from the Formstack API using the getSubmission operation.
Send the feedback to the Cliniko administrator via the Mandrill API using the sendMessage operation.
Cliniko operations
Formstack operations
Mandrill operations
Special Notes
Surveys should be completed in order to be considered in the case.
When multiple submissions are made for a single survey, the most recent submission would be considered.
Surveys without submission which are older than 14 days will be deleted upon execution of the case.
Samples
Sample Proxy for gathering responses of surveys in Formstack and sending them to the administrator of Cliniko
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2005-2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--Get the submissions and send the last survey response to the cliniko admin -->
<proxy xmlns="http://ws.apache.org/ns/synapse" name="cliniko_sendSurveyResponseToAdmin" transports="https,http" startOnLoad="true" trace="disable">
<description />
<target>
<inSequence onError="faultHandlerSeq">
<!-- Formstack Properties -->
<property name="formstack.apiUrl" expression="get-property('registry', 'connectors/Formstack/apiUrl')" />
<property name="formstack.accessToken" expression="get-property('registry', 'connectors/Formstack/accessToken')" />
<property name="formstack.questions" expression="json-eval($.formstack.questions)" />
<!-- Madnrill Properties -->
<property name="mandrill.apiUrl" expression="get-property('registry', 'connectors/Mandrill/apiUrl')" />
<property name="mandrill.apiKey" expression="get-property('registry', 'connectors/Mandrill/apiKey')" />
<property name="mandrill.fromName" expression="json-eval($.mandrill.fromName)" />
<property name="mandrill.fromEmail" expression="json-eval($.mandrill.fromEmail)" />
<!--Call cliniko connector getSettings method to administrator's details-->
<cliniko.init>
<apiUrl>{$ctx:cliniko.apiUrl}</apiUrl>
<apiKey>{$ctx:cliniko.apiKey}</apiKey>
</cliniko.init>
<cliniko.getSettings>
</cliniko.getSettings>
<property name="cliniko.accountName" expression="json-eval($.account.name)" />
<property name="cliniko.adminEmail" expression="json-eval($.account.admin.email)" />
<property name="cliniko.adminFirstName" expression="json-eval($.account.admin.first_name)" />
<!--Call formstack connector listForms method to list all the forms -->
<formstack.init>
<accessToken>{$ctx:formstack.accessToken}</accessToken>
<format>json</format>
<apiUrl>{$ctx:formstack.apiUrl}</apiUrl>
</formstack.init>
<formstack.listForms />
<property name="formstack.forms" expression="json-eval($.forms)" />
<sequence key="removeResponseHeaders" />
<!-- START: Proceed only if forms are retrieved successfully. -->
<filter source="boolean(get-property('formstack.forms'))" regex="false">
<then>
<property name="id" value="{}" />
<property name="status" value="error" />
<property name="message" expression="json-eval($)" />
<!--Call the responseHandler template -->
<call-template target="responseHandlerTemplate">
<with-param name="activity" value="formstack_listForms" />
<with-param name="id" value="{$ctx:id}" />
<with-param name="status" value="{$ctx:status}" />
<with-param name="message" value="{$ctx:message}" />
</call-template>
<loopback />
</then>
<else>
<property name="formstack.formIndex" expression="0" scope="operation" />
<property name="formstack.formCount" expression="count(//forms)" />
<!-- START: Proceed only if there is at least one form -->
<filter xpath="get-property('formstack.formCount') = 0.0">
<then>
<property name="id" value="{}" />
<property name="status" value="Skipped" />
<property name="message" value="There are no forms created." />
<call-template target="responseHandlerTemplate">
<with-param name="id" value="{$ctx:id}" />
<with-param name="activity" value="formstack_listForms" />
<with-param name="status" value="{$ctx:status}" />
<with-param name="message" value="{$ctx:message}" />
</call-template>
<loopback />
</then>
<else>
<!--BEGIN : FOR EACH form -->
<iterate continueParent="false" id="forms" expression="//forms" sequential="true">
<target>
<sequence>
<property name="formstack.formId" expression="json-eval($.forms.id)" />
<property name="formstack.submissions" expression="json-eval($.forms.submissions)" />
<property name="formstack.formCreated" expression="json-eval($.forms.created)" />
<!-- START: Proceed only there are submissions for the form -->
<filter xpath="get-property('formstack.submissions') = 0">
<then>
<!--Check whether the form is created before two weeks -->
<script language="js">
<![CDATA[
var createdDate = mc.getProperty('formstack.formCreated').split(" ")[0];
var twoWeeksBack= new java.text.SimpleDateFormat('yyyy-MM-dd').format(new java.util.Date(new java.util.Date().getTime() - 1209600000));
if(createdDate<twoWeeksBack) {
mc.setProperty("formstack.delete","true");
}
]]>
</script>
<!-- START: Delete the form if it is created before two weeks -->
<filter source="boolean(get-property('formstack.delete'))" regex="true">
<then>
<!--Call formstack connector deleteForm method to delete the given form -->
<formstack.init>
<accessToken>{$ctx:formstack.accessToken}</accessToken>
<format>json</format>
<apiUrl>{$ctx:formstack.apiUrl}</apiUrl>
</formstack.init>
<formstack.deleteForm>
<formId>{$ctx:formstack.formId}</formId>
</formstack.deleteForm>
<property name="formstack.deleted" expression="json-eval($.success)" />
<!-- START: Append a message to be sent to the user regarding the status of the delete operation. -->
<filter source="get-property('formstack.deleted')" regex="0">
<then>
<property name="id" expression="fn:concat('formstack_formId:',get-property('formstack.formId'))" />
<property name="message" expression="json-eval($)" />
<call-template target="responseHandlerTemplate">
<with-param name="activity" value="formstack_deleteForm" />
<with-param name="id" value="{$ctx:id}" />
<with-param name="status" value="error" />
<with-param name="message" value="{$ctx:message}" />
</call-template>
</then>
</filter>
<!-- END: Append a message to be sent to the user regarding the status of the delete operation. -->
</then>
</filter>
<!-- END: Delete the form if it is created before two weeks -->
</then>
<else>
<formstack.init>
<accessToken>{$ctx:formstack.accessToken}</accessToken>
<format>json</format>
<apiUrl>{$ctx:formstack.apiUrl}</apiUrl>
</formstack.init>
<formstack.listSubmissions>
<formId>{$ctx:formstack.formId}</formId>
<sort>DESC</sort>
<data>true</data>
</formstack.listSubmissions>
<property name="listSubmissions.statusCode" expression="$axis2:HTTP_SC" />
<!-- START: Proceed with the scenario only if the status code of the listSubmissions call is 200 OK. -->
<filter source="get-property('listSubmissions.statusCode')" regex="200">
<then>
<property name="formstack.submissionId" expression="json-eval($.submissions[0].id)" />
<!-- Get the details of the submission with all the field values. -->
<formstack.init>
<accessToken>{$ctx:formstack.accessToken}</accessToken>
<format>json</format>
<apiUrl>{$ctx:formstack.apiUrl}</apiUrl>
</formstack.init>
<formstack.getSubmission>
<submissionId>{$ctx:formstack.submissionId}</submissionId>
</formstack.getSubmission>
<property name="submissionData" expression="json-eval($.data)" />
<!-- Construct the mail body, subject and 'to' object to send the survey in email. -->
<script language="js">
<![CDATA[
var assigneeName = mc.getProperty('supportbee.assigneeName');
var submissionData = mc.getProperty('submissionData');
var userQuestions = mc.getProperty('formstack.questions');
var answerString = '';
if(submissionData != null && submissionData != ''){
submissionData = eval("(" + submissionData + ")");
userQuestions = eval("(" + userQuestions + ")");
var length = submissionData.length;
var invoiceId = submissionData[length-2].value;
var userName = submissionData[length-1].value;
if(submissionData.length > 0 && userQuestions.length > 0){
for(var i=0; i<userQuestions.length; i++){
var index = userQuestions[i].index - 1;
answerString += '<div><p>' + (i+1) + '. ' + userQuestions[i].question + ' <b><u>' + submissionData[index].value + '</u></b></p></div>';
}
}
}
mc.setProperty('answerString', answerString);
mc.setProperty('cliniko.invoiceId', invoiceId);
mc.setProperty('mandrill.subject', 'Patient Feedback for the invoice');
var mailTo = '[{"email": "' + userName + '", "type": "to"}]';
mc.setProperty('mandrill.to', mailTo);
]]>
</script>
<property name="mandrill.html" expression="fn:concat('<p><h3>Hi,</h3></p><p></p><p>You have been rated by the patient.</p></br></br><p>Invoice ID: <b>', get-property('cliniko.invoiceId'),'</b></p><p></p></br><p>Feedback is as follows:</p></br></br>', get-property('answerString'), '<p></p><p></p><p></p><p>This is an auto-generated email. Please do not reply.</p>')" />
<!-- Send the requester feedback to assignee via email. -->
<mandrill.init>
<apiKey>{$ctx:mandrill.apiKey}</apiKey>
<apiUrl>{$ctx:mandrill.apiUrl}</apiUrl>
<format>json</format>
</mandrill.init>
<mandrill.sendMessage>
<html>{$ctx:mandrill.html}</html>
<subject>{$ctx:mandrill.subject}</subject>
<fromEmail>{$ctx:mandrill.fromEmail}</fromEmail>
<fromName>{$ctx:mandrill.fromName}</fromName>
<important>false</important>
<autoHtml>true</autoHtml>
<urlStripQs>false</urlStripQs>
<preserveRecipients>true</preserveRecipients>
<viewContentLink>true</viewContentLink>
<to>{$ctx:mandrill.to}</to>
</mandrill.sendMessage>
<property name="mandrill.mailId" expression="json-eval($[0]._id)" />
<!-- START: Append a message to be sent to the user regarding the status of the send email operation. -->
<filter source="boolean(get-property('mandrill.mailId'))" regex="false">
<then>
<property name="id" expression="fn:concat('formstack_surveyId:', get-property('formstack.formId'))" />
<property name="status" value="error" />
<property name="message" expression="json-eval($)" />
<call-template target="responseHandlerTemplate">
<with-param name="activity" value="mandrill_sendSurveyResponse" />
<with-param name="id" value="{$ctx:id}" />
<with-param name="status" value="{$ctx:status}" />
<with-param name="message" value="{$ctx:message}" />
</call-template>
</then>
<else>
<property name="id" expression="fn:concat('formstack_formId:', get-property('formstack.formId'), ',cliniko_invoiceId:', get-property('cliniko.invoiceId'))" />
<property name="status" value="success" />
<property name="message" value="Survey response has been successfully sent to the administrator." />
<call-template target="responseHandlerTemplate">
<with-param name="activity" value="mandrill_sendSurveyResponse" />
<with-param name="id" value="{$ctx:id}" />
<with-param name="status" value="{$ctx:status}" />
<with-param name="message" value="{$ctx:message}" />
</call-template>
<!--Call formstack connector deleteForm method to delete the given form -->
<formstack.init>
<accessToken>{$ctx:formstack.accessToken}</accessToken>
<format>json</format>
<apiUrl>{$ctx:formstack.apiUrl}</apiUrl>
</formstack.init>
<formstack.deleteForm>
<formId>{$ctx:formstack.formId}</formId>
</formstack.deleteForm>
<property name="formstack.deleted" expression="json-eval($.success)" />
<!-- START: Append a message to be sent to the user regarding the status of the delete operation. -->
<filter source="get-property('formstack.deleted')" regex="0">
<then>
<property name="id" expression="fn:concat('formstack_formId:',get-property('formstack.formId'))" />
<property name="message" expression="json-eval($)" />
<call-template target="responseHandlerTemplate">
<with-param name="activity" value="formstack_deleteForm" />
<with-param name="id" value="{$ctx:id}" />
<with-param name="status" value="error" />
<with-param name="message" value="{$ctx:message}" />
</call-template>
</then>
</filter>
<!-- END: Append a message to be sent to the user regarding the status of the delete operation. -->
</else>
</filter>
<!-- END: Append a message to be sent to the user regarding the status of the send email operation. -->
</then>
<else>
<!-- Failure case: Append an error message to be sent to the user. -->
<property name="id" expression="fn:concat('formstack_surveyId: ', get-property('formstack.surveyId'))" />
<property name="message" expression="json-eval($)" />
<call-template target="responseHandlerTemplate">
<with-param name="activity" value="formstack_getSubmissions" />
<with-param name="id" value="{$ctx:id}" />
<with-param name="status" value="error" />
<with-param name="message" value="{$ctx:message}" />
</call-template>
</else>
</filter>
</else>
</filter>
<!-- END: Proceed only there are submissions for the form -->
<property name="formstack.formIndex" expression="get-property('operation','formstack.formIndex') + 1" scope="operation" />
<filter xpath="get-property('operation','formstack.formIndex') = get-property('formstack.formCount')">
<then>
<loopback />
</then>
</filter>
</sequence>
</target>
</iterate>
<!--END : FOR EACH form -->
</else>
</filter>
<!-- END: Proceed only if there is atleast one form -->
</else>
</filter>
<!-- END: Proceed only if there is a campaign from the given ID. -->
</inSequence>
<outSequence>
<property name="messageType" value="application/json" scope="axis2" />
<payloadFactory media-type="json">
<format>{
"Response":{
"process":"cliniko_sendSurveyResponseToAdmin",
"activityResponse":[$1]
}
}
</format>
<args>
<arg expression="get-property('operation', 'responseString')" />
</args>
</payloadFactory>
<send />
</outSequence>
</target>
</proxy>Sample Request for gathering responses of surveys in Formstack and sending them to the administrator of Cliniko
{
"formstack": {
"questions": [
{
"index": 3,
"question": "How satisfied are you with the service of 'Hello Doctor?"
},
{
"index": 4,
"question": "How likely are you to visit the same practioner again?"
},
{
"index": 5,
"question": "How likely are you to recommend our service to some one?"
}
]
},
"mandrill": {
"fromEmail": "etriggerit@gmail.com",
"fromName": "ETrigger Admin"
}
}Note
The following are the parameter descriptions:
formstack.questions:Array of objects each with the index of the question in the template form (in Formstack) and the label of the question. Please note that the values given for questions will be included in the mail sent to the administrator.E.g. [
{"index":4, "question":"How satisfied are you with the quality of the products that you have purchased?"},
{"index":5, "question":"How satisfied are you with speed and the quality of the delivery?"},
{"index":6, "question":"How satisfied are you with doing business with our company?"},
{"index":7, "question":"How likely are you to recommend our company to others?"}
]mandrill.fromName:Name of the company/person to be used as the sender name when sending the survey response.mandrill.fromEmail:E-mail of the company/person to be used as the sender e-mail when sending the survey response.