The createFlow
operation creates a survey, an e-mail connector and an e-mail message based on a template or existing survey.
createFlow
<surveymonkey.createFlow> <templateId>{$ctx:templateId}</templateId> <surveyTitle>{$ctx:surveyTitle}</surveyTitle> <fromSurveyId>{$ctx:fromSurveyId}</fromSurveyId> <collectorType>{$ctx:collectorType}</collectorType> <collectorName>{$ctx:collectorName}</collectorName> <recipients>{$ctx:recipients}</recipients> <collectorSend>{$ctx:collectorSend}</collectorSend> <replyEmail>{$ctx:replyEmail}</replyEmail> <messageSubject>{$ctx:messageSubject}</messageSubject> <messageBody>{$ctx:messageBody}</messageBody> </surveymonkey.createFlow>
Properties
The template ID to be used for creating the survey.templateId:
Required - The title of the survey.surveyTitle:
The ID of an existing survey to be used for creating the survey.fromSurveyId:
The type of the collector.collectorType:
The name of the collector.collectorName:
The array of recipients.recipients:
If "true", sends an email message to recipients.collectorSend:
The reply email of the email message to be sent to recipients.replyEmail:
The subject of the email message to be sent to recipients.messageSubject:
messageBody:
The plain text body of the email message to be sent to recipients.
Sample request
Following is a sample REST/JSON request that can be handled by the createFlow
operation.
Sample Request for createFlow
{ "apiUrl":"https://api.surveymonkey.net", "accessToken":"paTBz61kMlD0mPWrsaHR3921EuYbHlBvqU0GDZQ.5nahBvB1GbdZpbh2WnOzXY4SpgPezvIfjiLKg1h6dpRI5VJpOBjV3RTscaxNGlgM2w8=", "apiKey":"v9wjtvutfpvz5x82t5dqtt8v", "surveyTitle":"Test 1", "fromSurveyId":"58745768", "collectorType":"email", "collectorName":"Test", "recipients":[ { "email":"dvirajith@virtusa.com", "first_name":"Stannis", "last_name":"Baratheon", "custom_id":"94301" } ], "collectorSend":true, "replyEmail":"apptest.virajith@gmail.com", "messageSubject":"How's it happening", "messageBody":"You have successfully joined the happening group of WSO2 ESB Connector Development. Please complete the survey to find out how it's going on. [SurveyLink] If you are not a developer of this community, Please unsubscribe [RemoveLink]" }
Related SurveyMonkey documentation
https://developer.surveymonkey.com/mashery/create_flow
Sample configuration
Following is a sample proxy service that illustrates how to connect to SurveyMonkey with the init
operation and use the createFlow
operation. The sample request for this proxy can be found in the createFlow sample request.
Sample Proxy
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="surveymonkey_createFlow" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence onError="faultHandlerSeq"> <property name="apiUrl" expression="json-eval($.apiUrl)"/> <property name="accessToken" expression="json-eval($.accessToken)"/> <property name="apiKey" expression="json-eval($.apiKey)"/> <property name="templateId" expression="json-eval($.templateId)"/> <property name="surveyTitle" expression="json-eval($.surveyTitle)"/> <property name="fromSurveyId" expression="json-eval($.fromSurveyId)"/> <property name="collectorType" expression="json-eval($.collectorType)"/> <property name="collectorName" expression="json-eval($.collectorName)"/> <property name="recipients" expression="json-eval($.recipients)"/> <property name="collectorSend" expression="json-eval($.collectorSend)"/> <property name="replyEmail" expression="json-eval($.replyEmail)"/> <property name="messageSubject" expression="json-eval($.messageSubject)"/> <property name="messageBody" expression="json-eval($.messageBody)"/> <surveymonkey.init> <accessToken>{$ctx:accessToken}</accessToken> <apiKey>{$ctx:apiKey}</apiKey> <apiUrl>{$ctx:apiUrl}</apiUrl> </surveymonkey.init> <surveymonkey.createFlow> <templateId>{$ctx:templateId}</templateId> <surveyTitle>{$ctx:surveyTitle}</surveyTitle> <fromSurveyId>{$ctx:fromSurveyId}</fromSurveyId> <collectorType>{$ctx:collectorType}</collectorType> <collectorName>{$ctx:collectorName}</collectorName> <recipients>{$ctx:recipients}</recipients> <collectorSend>{$ctx:collectorSend}</collectorSend> <replyEmail>{$ctx:replyEmail}</replyEmail> <messageSubject>{$ctx:messageSubject}</messageSubject> <messageBody>{$ctx:messageBody}</messageBody> </surveymonkey.createFlow> <property name="responseStatus" expression="json-eval($.status)"/> <filter source="$axis2:HTTP_SC" regex="^[^2][0-9][0-9]"> <then> <switch source="$axis2:HTTP_SC"> <case regex="401"> <property name="ERROR_CODE" value="600401"/> <property name="ERROR_MESSAGE" value="Unauthorized"/> </case> <case regex="404"> <property name="ERROR_CODE" value="600404"/> <property name="ERROR_MESSAGE" value="Not Found"/> </case> <case regex="400"> <property name="ERROR_CODE" value="600400"/> <property name="ERROR_MESSAGE" value="Bad Request"/> </case> <case regex="403"> <property name="ERROR_CODE" value="600403"/> <property name="ERROR_MESSAGE" value="Forbidden."/> </case> <case regex="500"> <property name="ERROR_CODE" value="600500"/> <property name="ERROR_MESSAGE" value="Internal Server Error"/> </case> </switch> <property name="messageType" value="application/json" scope="axis2"/> <sequence key="faultHandlerSeq"/> </then> <else> <filter xpath="get-property('responseStatus') != 0"> <then> <switch source="get-property('responseStatus')"> <case regex="1"> <property name="HTTP_SC" value="401" scope="axis2"></property> <property name="ERROR_CODE" value="600401"/> <property name="ERROR_MESSAGE" value="Unauthorized"/> </case> <case regex="2"> <property name="HTTP_SC" value="403" scope="axis2"></property> <property name="ERROR_CODE" value="600403"/> <property name="ERROR_MESSAGE" value="Forbidden."/> </case> <case regex="3"> <property name="HTTP_SC" value="400" scope="axis2"></property> <property name="ERROR_CODE" value="600400"/> <property name="ERROR_MESSAGE" value="Bad Request"/> </case> <case regex="4"> <property name="HTTP_SC" value="403" scope="axis2"></property> <property name="ERROR_CODE" value="600403"/> <property name="ERROR_MESSAGE" value="Unknown User"/> </case> <case regex="5"> <property name="HTTP_SC" value="500" scope="axis2"></property> <property name="ERROR_CODE" value="600500"/> <property name="ERROR_MESSAGE" value="Internal Server Error"/> </case> </switch> <property name="error_description" expression="json-eval($.errmsg)"/> <property name="messageType" value="application/json" scope="axis2"/> <sequence key="faultHandlerSeq"/> </then> </filter> </else> </filter> <respond/> </inSequence> <outSequence> <send/> </outSequence> <faultSequence> <property name="ERROR_CODE" value="600500"/> <property name="ERROR_MESSAGE" value="Internal Server Error"/> <property name="messageType" value="application/json" scope="axis2"/> <sequence key="faultHandlerSeq"/> </faultSequence> </target> <description/> </proxy>