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/.
Event Surveys in Eventbrite
The fifth use case in the Eventbrite business scenario is used for event surveys. This page describes the related tasks and the operations you use in the Eventbrite connector and the other ESB connectors.Â
Overview
The flow for event surveys is illustrated in the following diagram. The ESB connectors for SurveyMonkey and Gmail will be used to connect to each service.Â
- Create survey templates in the SurveyMonkey API as an offline process.
- Retrieve past event attendees using the eventAttendees operation in the Eventbrite API for selected events and send surveys to them using the createFlow operation in the SurveyMonkey API.
- Retrieve information on how many respondents have started or completed the survey using the getResponseCounts operation in the SurveyMonkey API, and send an e-mail to the Organizer for notification purposes using the sendMail operation in the Gmail API.
Eventbrite operations
eventAttendees
SurveyMonkey operations
Gmail operations
Samples
Sample Proxy for Retrieving Attendees of Past Events from Eventbrite and Sending Surveys to them using SurveyMonkey
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="eventbrite_retrievePastEventAttendeesAndSendSurveys" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence onError="faultHandlerSeq"> <!-- Eventbrite Properties --> <property name="eventbrite.apiUrl" expression="json-eval($.eventBriteApiUrl)"/> <property name="eventbrite.accessToken" expression="json-eval($.eventBriteAccessToken)"/> <property name="eventbrite.eventCount" expression="count(//pastEventData)" scope="operation" /> <property name="eventbrite.eventIndex" expression="0" scope="operation" /> <property name="eventbrite.idObject" value="" scope="operation" /> <!-- SurveyMonkey Properties --> <property name="surveymonkey.apiUrl" expression="json-eval($.surveyMonkeyApiUrl)" /> <property name="surveymonkey.accessToken" expression="json-eval($.surveyMonkeyAccessToken)" /> <property name="surveymonkey.apiKey" expression="json-eval($.surveyMonkeyApiKey)" /> <property name="surveymonkey.surveyTitle" expression="json-eval($.surveyMonkeySurveyTitle)" /> <property name="surveymonkey.collectorName" expression="json-eval($.surveyMonkeyCollectorName)" /> <property name="surveymonkey.replyEmail" expression="json-eval($.surveyMonkeyReplyEmail)" /> <property name="surveymonkey.messageSubject" expression="json-eval($.surveyMonkeyMessageSubject)" /> <!-- Common Properties --> <property name="event.Recipients" value="" scope="operation"/> <filter xpath="get-property('operation','eventbrite.eventCount') >0"> <then> <iterate continueParent="true" id="events" expression="//pastEventData" sequential="true"> <target> <sequence> <property name="eventbrite.eventId" expression="//pastEventData/eventId/text()"/> <property name="surveymonkey.fromSurveyId" expression="//pastEventData/surveyId/text()"/> <!-- Call Eventbrite eventAttendees to retrieve event attendees. --> <eventbrite.init> <apiUrl>{$ctx:eventbrite.apiUrl}</apiUrl> <accessToken>{$ctx:eventbrite.accessToken}</accessToken> </eventbrite.init> <eventbrite.eventAttendees> <EventID>{$ctx:eventbrite.eventId}</EventID> </eventbrite.eventAttendees> <filter source="$axis2:HTTP_SC" regex="200"> <then> <property name="event.attendeesCount" expression="json-eval($.pagination.object_count)" scope="operation"/> <filter xpath="get-property('eventbrite.attendeesCount')=0"> <then> <property name="id" expression="fn:concat('{event_id:',get-property('eventbrite.eventId'),'}')"/> <property name="status" value="Skipped" /> <property name="message" value="No attendees to the event id" /> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:id}" /> <with-param name="activity" value="surveymonkey_sendSurveys" /> <with-param name="status" value="{$ctx:status}" /> <with-param name="message" value="{$ctx:message}" /> </call-template> </then> <else> <property name="eventbrite.idObject" expression="fn:concat(get-property('operation','eventbrite.idObject'), get-property('eventbrite.eventId'), ',')" scope="operation"/> <property name="event.attendees" expression="json-eval($.attendees)" /> <iterate continueParent="true" id="attendees" expression="//attendees" sequential="true"> <target> <sequence> <property name="event.attendeeFirstName" expression="json-eval($.attendees.profile.first_name)" /> <property name="event.attendeeLastName" expression="json-eval($.attendees.profile.last_name)" /> <property name="event.attendeeEmail" expression="json-eval($.attendees.profile.email)" /> <payloadFactory media-type="json"> <format> { "email":"$1", "first_name":"$2", "last_name":"$3" } </format> <args> <arg expression="get-property('event.attendeeEmail')"/> <arg expression="get-property('event.attendeeFirstName')"/> <arg expression="get-property('event.attendeeLastName')"/> </args> </payloadFactory> <property name="event.recipient" expression="json-eval($.)"/> <property name="event.Recipients" expression="fn:concat(get-property('operation','event.Recipients'), get-property('event.recipient'), ',')" scope="operation"/> </sequence> </target> </iterate> <filter source="boolean(get-property('operation','eventbrite.idObject'))" regex="true"> <then> <property name="event.Recipients" expression="fn:substring(get-property('operation','event.Recipients'),1,fn:string-length(get-property('operation','event.Recipients'))-1)"/> <property name="surveymonkey.Recipients" expression="fn:concat('[',get-property('event.Recipients'),']')" /> <property name="surveymonkey.messageBody" value="Please use this link to complete the survey. [SurveyLink] If you do not want to receive these emails in the future, unsubscribe yourself with the use of this link. [RemoveLink]"/> <!-- Remove unused headers by calling a sequence template. --> <sequence key="removeResponseHeaders" /> <!-- Call SurveyMonkey createFlow to create and send a survey to event attendees. --> <surveymonkey.init> <accessToken>{$ctx:surveymonkey.accessToken}</accessToken> <apiKey>{$ctx:surveymonkey.apiKey}</apiKey> <apiUrl>{$ctx:surveymonkey.apiUrl}</apiUrl> </surveymonkey.init> <surveymonkey.createFlow> <surveyTitle>{$ctx:surveymonkey.surveyTitle}</surveyTitle> <fromSurveyId>{$ctx:surveymonkey.fromSurveyId}</fromSurveyId> <collectorType>email</collectorType> <collectorName>{$ctx:surveymonkey.collectorName}</collectorName> <recipients>{$ctx:surveymonkey.Recipients}</recipients> <collectorSend>true</collectorSend> <replyEmail>{$ctx:surveymonkey.replyEmail}</replyEmail> <messageSubject>{$ctx:surveymonkey.messageSubject}</messageSubject> <messageBody>{$ctx:surveymonkey.messageBody}</messageBody> </surveymonkey.createFlow> <filter source="$axis2:HTTP_SC" regex="201"> <then> <property name="collectorId" expression="json-eval($.data.collector.collector_id)" /> <property name="status" value="Success" /> <property name="message" expression="fn:concat('Survey was successfully sent with the collector id ', get-property('collectorId'),'.')" /> </then> <else> <property name="status" value="Error" /> <property name="message" expression="json-eval($.)" /> </else> </filter> </then> </filter> <property name="eventbrite.idObject" expression="fn:substring(get-property('operation','eventbrite.idObject'),1,fn:string-length(get-property('operation','eventbrite.idObject'))-1)" scope="operation" /> <property name="eventbrite.idObject" expression="fn:concat('{event_ids:[',get-property('operation','eventbrite.idObject'),']}')" /> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:eventbrite.idObject}" /> <with-param name="activity" value="surveymonkey_sendSurveys" /> <with-param name="status" value="{$ctx:status}" /> <with-param name="message" value="{$ctx:message}" /> </call-template> </else> </filter> </then> <else> <property name="id" expression="fn:concat('{event_id:',get-property('eventbrite.eventId'),'}')"/> <property name="status" value="Skipped" /> <property name="message" expression="json-eval($.)" /> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:id}" /> <with-param name="activity" value="surveymonkey_sendSurveys" /> <with-param name="status" value="{$ctx:status}" /> <with-param name="message" value="{$ctx:message}" /> </call-template> </else> </filter> <property name="eventbrite.eventIndex" expression="get-property('operation','eventbrite.eventIndex') + 1" scope="operation" /> </sequence> </target> </iterate> <filter xpath="get-property('operation','eventbrite.eventCount') = get-property('operation','eventbrite.eventIndex')"> <then> <loopback /> </then> </filter> </then> <else> <property name="id" value="{event_ids:[]}" /> <property name="status" value="Skipped" /> <property name="message" value="No EventBrite event ids on request to retrieve attendees." /> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:id}" /> <with-param name="activity" value="surveymonkey_sendSurveys" /> <with-param name="status" value="{$ctx:status}" /> <with-param name="message" value="{$ctx:message}" /> </call-template> <loopback /> </else> </filter> </inSequence> <outSequence> <payloadFactory media-type="json"> <format>{ "Response":{ "process":"Eventbrite-retrievePastEventAttendeesAndSendSurveys", "activityResponse":[$1] } }</format> <args> <arg expression="get-property('operation','responseString')" /> </args> </payloadFactory> <property name="messageType" value="application/json" scope="axis2" /> <send /> </outSequence> </target> <description /> </proxy>
Sample Request for Retrieving Attendees of Past Events from Eventbrite and Sending Surveys to them using SurveyMonkey
{ "eventBriteApiUrl": "https://www.eventbriteapi.com", "eventBriteAccessToken": "O5CHYSIJQPS7QNQKBYU6", "pastEventData": [ { "eventId":"14845207415", "surveyId":"59164527" }, { "eventId":"123", "surveyId":"59164527" } ], "surveyMonkeyApiUrl":"https://api.surveymonkey.net", "surveyMonkeyAccessToken":"paTBz61kMlD0mPWrsaHR3921EuYbHlBvqU0GDZQ.5nahBvB1GbdZpbh2WnOzXY4SpgPezvIfjiLKg1h6dpRI5VJpOBjV3RTscaxNGlgM2w8=", "surveyMonkeyApiKey":"v9wjtvutfpvz5x82t5dqtt8v", "surveyMonkeySurveyTitle":"Survey Demo", "surveyMonkeyCollectorName":"Test Demo", "surveyMonkeyReplyEmail":"test@gmail.com", "surveyMonkeyMessageSubject":"Thank you for attending to the event" }
Sample Proxy for Retrieving Survey Respondents from SurveyMonkey and Sending an e-mail to the Organizer as a Notification using Gmail
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="eventbrite_retrieveSurveyRespondentsAndSendToOrganizer" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence onError="faultHandlerSeq"> <!-- SurveyMonkey Properties --> <property name="surveymonkey.apiUrl" expression="json-eval($.surveyMonkeyApiUrl)" /> <property name="surveymonkey.accessToken" expression="json-eval($.surveyMonkeyAccessToken)" /> <property name="surveymonkey.apiKey" expression="json-eval($.surveyMonkeyApiKey)" /> <property name="surveymonkey.collectorId" expression="json-eval($.surveyMonkeyCollectiorId)" /> <!-- GMail Properties --> <property name="gmail.username" expression="json-eval($.gmailUsername)" /> <property name="gmail.accessToken" expression="json-eval($.gmailAccessToken)" /> <property name="gmail.subject" expression="json-eval($.gmailSubject)" /> <property name="gmail.toRecipients" expression="json-eval($.eventOrganizerEmail)" /> <!-- Call the SurveyMonkey getResponseCounts method to retrieve survey respondents. --> <surveymonkey.init> <apiUrl>{$ctx:surveymonkey.apiUrl}</apiUrl> <accessToken>{$ctx:surveymonkey.accessToken}</accessToken> <apiKey>{$ctx:surveymonkey.apiKey}</apiKey> </surveymonkey.init> <surveymonkey.getResponseCounts> <collectorId>{$ctx:surveymonkey.collectorId}</collectorId> </surveymonkey.getResponseCounts> <property name="id" expression="fn:concat('collector_id:',get-property('surveymonkey.collectorId'))" /> <property name="surveymonkey.data" expression="json-eval($.data)" /> <filter source="boolean(get-property('surveymonkey.data'))" regex="true"> <then> <property name="surveymonkey.startedRespondents" expression="json-eval($.data.started)" /> <property name="surveymonkey.completedRespondents" expression="json-eval($.data.completed)" /> <property name="gmail.textContent" expression="fn:concat('Here is your survey respondents details. Number of Started respondents on your survey is : ',get-property('surveymonkey.startedRespondents'),' and Number of completed respondents on your survey is: ', get-property('surveymonkey.completedRespondents'))" /> <!-- Call the GMail sendMail method to send survey respondent details to the organizer. --> <gmail.init> <username>{$ctx:gmail.username}</username> <oauthAccessToken>{$ctx:gmail.accessToken}</oauthAccessToken> </gmail.init> <gmail.sendMail> <subject>{$ctx:gmail.subject}</subject> <toRecipients>{$ctx:gmail.toRecipients}</toRecipients> <textContent>{$ctx:gmail.textContent}</textContent> </gmail.sendMail> <property name="messageSubject" expression="json-eval($.sendMailResponse.message.subject)" /> <filter source="boolean(get-property('messageSubject'))" regex="false"> <then> <property name="status" value="Error" /> <property name="message" expression="json-eval($.)" /> </then> <else> <property name="status" value="Success" /> <property name="message" expression="fn:concat('Survey response details are successfully sent to the event organizer email (', get-property('gmail.toRecipients') ,').')" /> </else> </filter> </then> <else> <property name="status" value="Error" /> <property name="message" expression="json-eval($.)" /> </else> </filter> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:eventbrite.idObject}" /> <with-param name="activity" value="gmail_sendRespondentsToOrganizer" /> <with-param name="status" value="{$ctx:status}" /> <with-param name="message" value="{$ctx:message}" /> </call-template> <loopback/> </inSequence> <outSequence> <payloadFactory media-type="json"> <format> { "Response":{ "process":"Eventbrite-retrieveSurveyRespondentsAndSendToOrganizer", "activityResponse":[$1] } } </format> <args> <arg expression="get-property('operation','responseString')" /> </args> </payloadFactory> <property name="messageType" value="application/json" scope="axis2" /> <send /> </outSequence> </target> <description /> </proxy>
Sample Request for Retrieving Survey Respondents from SurveyMonkey and Sending an e-mail to the Organizer as a Notification using Gmail
{ "surveyMonkeyApiUrl":"https://api.surveymonkey.net", "surveyMonkeyAccessToken":"paTBz61kMlD0mPWrsaHR3921EuYbHlBvqU0GDZQ.5nahBvB1GbdZpbh2WnOzXY4SpgPezvIfjiLKg1h6dpRI5VJpOBjV3RTscaxNGlgM2w8=", "surveyMonkeyApiKey":"v9wjtvutfpvz5x82t5dqtt8v", "surveyMonkeyCollectiorId":"61874290", "gmailUsername":"testUser", "gmailAccessToken":"ya29.3QAinAl8rTI1GU3b70wddYpOn_sOMLXdh4LWhnkk-xUSvau0Z1xaA9JrdFrikby6N94vnWq6BHMe8Q", "gmailSubject":"Your Survey Response Details", "eventOrganizerEmail":"test@gmail.com" }