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/.
Marketing Events in Eventbrite
The second use case in the Eventbrite business scenario is used for marketing events. This page describes the related tasks and the operations you use in the Eventbrite connector and the other ESB connectors.Â
Overview
The flow for marketing events is illustrated in the following diagram. The ESB connectors for Facebook and Constant Contact will be used to connect to each service.Â
- Retrieve the selected set of published events from the Eventbrite API using the eventDetails operation.
Publish the above retrieved events in the Facebook API as a post which contains the Eventbrite event link using the createPost operation.
- Create a campaign for the above retrieved events in the Constant Contact API using the createCampaign operation in order to market the Eventbrite event with the Eventbrite link. Create a schedule using the createSchedule operation in the Constant Contact API.
- Retrieve the list of contacts who clicked on the link contained in the sent email campaign from the Constant Contact API using the getContactById operation, create a contact list (group) for the particular campaign within the Constant Contact API, and update the contact with the new contact list using the updateContact operation.
Facebook operations
Eventbrite operations
eventDetails
Constant Contact operations
Samples
Sample Template for Creating Campaigns in Constant Contact and Adding Posts in Facebook which are Retrieved from Eventbrite
<?xml version="1.0" encoding="UTF-8"?> <!-- This template is used to create a campaign in Constant Contact and add posts in Facebook which are retrieved from Eventbrite. --> <template xmlns="http://ws.apache.org/ns/synapse" name="createPostsAndCampaigns"> <!-- Constant Contact Parameters --> <parameter name="constantContact.apiToken" description="Encrypted alphanumeric string to authenticate the Constant Contact credentials." /> <parameter name="constantContact.apiUrl" description="The constantContact API URL." /> <parameter name="constantContact.apiKey" description="The constantContact API Key." /> <parameter name="constantContact.fromEmail" description="The name of the campaign." /> <parameter name="constantContact.emailContent" description="The email content of the campaign. " /> <parameter name="constantContact.sendToContactList" description="The contactList id to send the campaign. " /> <parameter name="constantContact.replyToEmail" description="The email address to send replies. " /> <parameter name="constantContact.fromName" description="The campaign sender's name. " /> <property name="constantContact.url" description="The url to send in the campaign. " /> <property name="constantContact.sheduledDate" description="The sheduled date to send the campaign. " /> <parameter name="constantContact.emailTitle" description="The email title of the constant contact." /> <parameter name="constantContact.url" description="The urlCaption of the constant contact." /> <parameter name="constantContact.urlDescription" description="The url description of the constant contact post." /> <!-- Facebook Parameters --> <parameter name="facebook.accessToken" description="Encrypted alphanumeric string to authenticate the facebook credentials." /> <parameter name="facebook.apiUrl" description="The facebook API URL." /> <parameter name="facebook.urlDescription" description="The url description of the facebook post." /> <parameter name="facebook.url" description="The url of facebook post." /> <parameter name="facebook.urlCaption" description="The urlCaption of the facebook post." /> <parameter name="facebook.urlName" description="The name of the link of the facebook post." /> <!-- Common Parameters --> <parameter name="event.idObj" description="Id as Key value pair(s) for response handler (Ex. id1:value1,id2:value2)." /> <sequence> <property name="constantContact.apiToken" expression="$func:constantContact.apiToken" /> <property name="constantContact.apiUrl" expression="$func:constantContact.apiUrl" /> <property name="constantContact.apiKey" expression="$func:constantContact.apiKey" /> <property name="constantContact.fromEmail" expression="$func:constantContact.fromEmail" /> <property name="constantContact.sendToContactList" expression="$func:constantContact.sendToContactList" /> <property name="constantContact.emailContent" expression="$func:constantContact.emailContent" /> <property name="constantContact.replyToEmail" expression="$func:constantContact.replyToEmail" /> <property name="constantContact.fromName" expression="$func:constantContact.fromName" /> <property name="constantContact.emailTitle" expression="$func:constantContact.emailTitle" /> <property name="constantContact.url" expression="$func:constantContact.url" /> <property name="constantContact.urlDescription" expression="$func:constantContact.urlDescription" /> <property name="constantContact.sheduledDate" expression="$func:constantContact.sheduledDate" /> <property name="facebook.apiUrl" expression="$func:facebook.apiUrl" /> <property name="facebook.accessToken" expression="$func:facebook.accessToken" /> <property name="facebook.urlDescription" expression="$func:facebook.urlDescription" /> <property name="facebook.urlName" expression="$func:facebook.urlName" /> <property name="facebook.url" expression="$func:facebook.url" /> <property name="facebook.urlCaption" expression="$func:facebook.urlCaption" /> <property name="event.idObj" expression="$func:event.idObj" /> <property name="constantContact.subject" expression="fn:concat('Campaign for - ',get-property('constantContact.emailTitle'))" /> <property name="constantContact.emailBody" expression="fn:concat('You have been successfully subscribed for the event -',get-property('constantContact.emailTitle'),'. ')" /> <property name="constantContact.emailUser" value="Dear user," /> <property name="constantContact.regards1" value="Best regards," /> <!-- Create the campaign only if the access token is given. --> <filter source="boolean(get-property('constantContact.apiToken'))" regex="true"> <then> <property name="messageType" value="application/json" scope="axis2" /> <payloadFactory media-type="json"> <format> { "html_content":"<html><body><p>$1</p></br><p>$2<a href='$3'>$4</a></p><p></br>$5<br>$6</p></body></html>" } </format> <args> <arg expression="get-property('constantContact.emailUser')"/> <arg expression="get-property('constantContact.emailBody')"/> <arg expression="get-property('constantContact.url')" /> <arg expression="get-property('constantContact.urlDescription')" /> <arg expression="get-property('constantContact.regards1')" /> <arg expression="get-property('constantContact.fromName')" /> </args> </payloadFactory> <property name="constantContact.emailContent" expression="json-eval($.html_content)" /> <!-- Call the constantContact connector createCampaign method. --> <constantcontact.init> <apiToken>{$ctx:constantContact.apiToken}</apiToken> <apiUrl>{$ctx:constantContact.apiUrl}</apiUrl> <apiKey>{$ctx:constantContact.apiKey}</apiKey> </constantcontact.init> <constantcontact.createCampaign> <subject>{$ctx:constantContact.subject}</subject> <emailContentFormat>HTML</emailContentFormat> <emailContent>{$ctx:constantContact.emailContent}</emailContent> <name>{$ctx:constantContact.subject}</name> <fromEmail>{$ctx:constantContact.fromEmail}</fromEmail> <greetingString>Welcome</greetingString> <replyToEmail>{$ctx:constantContact.replyToEmail}</replyToEmail> <sentToContactLists>{$ctx:constantContact.sendToContactList}</sentToContactLists> <fromName>{$ctx:constantContact.fromName}</fromName> <textContent>{$ctx:constantContact.urlDescription}</textContent> </constantcontact.createCampaign> <property name="id" expression="fn:concat('{event_id:',get-property('event.idObj'),'}')"/> <property name="campaignId" expression="json-eval($.id)" /> <filter xpath="get-property('campaignId')='null'"> <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('Constant Contact campaign has been created with the ID - [',get-property('campaignId'),']')" /> </else> </filter> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:id}" /> <with-param name="activity" value="constantcontact-createCampaign" /> <with-param name="status" value="{$ctx:status}" /> <with-param name="message" value="{$ctx:message}" /> </call-template> <!-- Schedule the campaign, only if the campaign is created. --> <filter xpath="get-property('campaignId') !='null'"> <then> <constantcontact.init> <apiToken>{$ctx:constantContact.apiToken}</apiToken> <apiUrl>{$ctx:constantContact.apiUrl}</apiUrl> <apiKey>{$ctx:constantContact.apiKey}</apiKey> </constantcontact.init> <constantcontact.createSchedule> <campaignId>{$ctx:campaignId}</campaignId> <scheduledDate>{$ctx:constantContact.sheduledDate}</scheduledDate> </constantcontact.createSchedule> <property name="CampaignSendId" expression="json-eval($.id)" /> <filter xpath="get-property('CampaignSendId')='null'" > <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('Campaign has been sheduled for - [',get-property('constantContact.sheduledDate'),']')" /> </else> </filter> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:event.idObj}" /> <with-param name="activity" value="constantcontact-sheduledCampaign" /> <with-param name="status" value="{$ctx:status}" /> <with-param name="message" value="{$ctx:message}" /> </call-template> </then> </filter> </then> </filter> <!-- Create a Facebook post only if the access token is given. --> <filter source="boolean(get-property('facebook.accessToken'))" regex="true"> <then> <!-- Call the Facebook connector createPost method. --> <facebook.init> <apiUrl>{$ctx:facebook.apiUrl}</apiUrl> <accessToken>{$ctx:facebook.accessToken"}</accessToken> </facebook.init> <facebook.createPost> <link>{$ctx:facebook.url}</link> <name>{$ctx:facebook.urlName}</name> <caption>{$ctx:facebook.urlCaption}</caption> <description>{$ctx:facebook.urlDescription}</description> </facebook.createPost> <header name="Facebook-API-Version" action="remove" scope="transport" /> <property name="id" expression="fn:concat('{event_id:',get-property('event.idObj'),'}')"/> <property name="postId" expression="json-eval($.id)" /> <filter source="boolean(get-property('postId'))" 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('FaceBook post is created with the ID - [',get-property('postId'),']')" /> </else> </filter> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:id}" /> <with-param name="activity" value="facebook-createPost" /> <with-param name="status" value="{$ctx:status}" /> <with-param name="message" value="{$ctx:message}" /> </call-template> </then> </filter> </sequence> </template>
Sample Proxy for Retrieving the Selected Set of Eventbrite Published Events
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="eventbrite_retrieveEventsAndMarketing" transports="https http" startOnLoad="true" trace="disable"> <target> <inSequence> <!-- Eventbrite Properties --> <property name="eventBrite.apiUrl" expression="json-eval($.eventBriteApiUrl)" /> <property name="eventBrite.accessToken" expression="json-eval($.eventBriteAccessToken)" /> <property name="eventbrite.eventCount" expression="count(//eventBriteEventIds)" scope="operation" /> <property name="eventbrite.eventIndex" expression="0" scope="operation" /> <!-- Facebook Properties --> <property name="facebook.apiUrl" expression="json-eval($.facebookApiUrl)" /> <property name="facebook.accessToken" expression="json-eval($.facebookAccessToken)" /> <!-- Constant Contact Properties --> <property name="constantContact.apiUrl" expression="json-eval($.constantContactApiUrl)" /> <property name="constantContact.apiToken" expression="json-eval($.constantContactApiToken)" /> <property name="constantContact.apiKey" expression="json-eval($.constantContactApiKey)" /> <property name="constantContact.fromEmail" expression="json-eval($.constantContactFromEmail)" /> <property name="constantContact.fromName" expression="json-eval($.constantContactFromName)" /> <property name="constantContact.replyToEmail" expression="json-eval($.constantContactreplyToEmail)" /> <property name="constantContact.sendToContactList" expression="json-eval($.constantContactSentToContactLists)" /> <!-- Process only if the event array is not empty. --> <filter xpath="get-property('operation','eventbrite.eventCount') >0"> <then> <property name="futureEvent" value="false" scope="operation" /> <property name="publishedEvent" value="false" scope="operation" /> <!-- FOR EACH event: BEGIN --> <iterate continueParent="true" id="events" expression="//eventBriteEventIds" sequential="true"> <target> <sequence> <property name="eventbrite.eventId" expression="//eventBriteEventIds/text()" /> <!-- Call the Eventbrite connector eventDetails method. Get the event details for the given event ID. --> <eventbrite.init> <apiUrl>{$ctx:eventBrite.apiUrl}</apiUrl> <accessToken>{$ctx:eventBrite.accessToken}</accessToken> </eventbrite.init> <eventbrite.eventDetails> <EventID>{$ctx:eventbrite.eventId}</EventID> </eventbrite.eventDetails> <!-- Remove unused headers before calling the createPostsAndCampaigns template. --> <sequence key="removeResponseHeaders" /> <property name="eventId" expression="json-eval($.id)" /> <!-- Process only if the event details are retrieved successfully. --> <filter source="boolean(get-property('eventId'))" regex="false"> <then> <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="eventbrite_eventDetails" /> <with-param name="status" value="{$ctx:status}" /> <with-param name="message" value="{$ctx:message}" /> </call-template> </then> <else> <property name="eventbrite.id" expression="json-eval($.id)" /> <property name="eventbrite.url" expression="json-eval($.url)" /> <property name="eventbrite.name" expression="json-eval($.name.text)" /> <property name="eventbrite.status" expression="json-eval($.status)" /> <property name="eventbrite.startTime" expression="json-eval($.start.local)" /> <property name="eventbrite.endTime" expression="json-eval($.end.local)" /> <property name="facebook.urlDescription" expression="fn:concat('Starting time - ',get-property('eventbrite.startTime'),' End time - ',get-property('eventbrite.endTime'))" /> <property name="facebook.urlCaption" value="click here to view the event"/> <property name="constantcontact.urlDescription" value="For more details please click here"/> <!--Process only if the event is a publish event--> <filter xpath="get-property('eventbrite.status')!='live'"> <then> <property name="id" expression="fn:concat('{event_id:',get-property('eventbrite.eventId'),'}')" /> <property name="status" value="Skipped" /> <property name="message" value="This event is not a published event." /> <call-template target="responseHandlerTemplate"> <with-param name="activity" value="retrieveEventsAndMarketing" /> <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="publishedEvent" value="true" scope="operation" /> <property name="constantContact.sheduledDate" value="" /> <property name="dateComparison" value="false" /> <script language="js"><![CDATA[var eventStartingDate = mc.getProperty('eventbrite.startTime'); var comparedDate = mc.getProperty('dateComparison'); var eventStartDay = ""; var systemDate=new Date(); var minutes = systemDate.getMinutes(); var hours = systemDate.getHours(); var currentDate=""+systemDate.getDate(); var sheduledMins = minutes + 5; if(sheduledMins<10){ sheduledMins ="0"+sheduledMins; } if(currentDate.length==1){ currentDate="0"+currentDate; } var dateString=systemDate.getFullYear() + "-" + Number(systemDate.getMonth()+1) + "-" + currentDate ; var sheduledDate= dateString+"T"+hours+":"+sheduledMins+":00.000Z" if (eventStartingDate != null && eventStartingDate != "") { eventStartDay = eventStartingDate.split('T')[0]; } if(dateString < eventStartDay) { comparedDate = "true"; } mc.setProperty("constantContact.sheduledDate", sheduledDate); mc.setProperty("dateComparison", comparedDate);]]></script> <!-- Process only if the event is a future event. --> <filter source="get-property('dateComparison')" regex="false"> <then> <property name="id" expression="fn:concat('{event_id:',get-property('eventbrite.eventId'),'}')" /> <property name="status" value="Skipped" /> <property name="message" value="The start date of this event is not a future date." /> <call-template target="responseHandlerTemplate"> <with-param name="activity" value="retrieveEventsAndMarketing" /> <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="futureEvent" value="true" scope="operation" /> <!-- Call the createPostsAndCampaigns template to create the campaign in Constant Contact and post in Facebook. --> <call-template target="createPostsAndCampaigns"> <!-- Parameter values will be passed on to a sequence template. --> ( <with-param name="event.idObj" value="{$ctx:eventbrite.id}" /> | <with-param name="facebook.apiUrl" value="{$ctx:facebook.apiUrl}" /> | <with-param name="facebook.accessToken" value="{$ctx:facebook.accessToken}" /> | <with-param name="facebook.url" value="{$ctx:eventbrite.url}" /> | <with-param name="facebook.urlDescription" value="{$ctx:facebook.urlDescription}" /> | <with-param name="facebook.urlName" value="{$ctx:eventbrite.name}" /> | <with-param name="constantContact.apiUrl" value="{$ctx:constantContact.apiUrl}" /> | <with-param name="constantContact.apiToken" value="{$ctx:constantContact.apiToken}" /> | <with-param name="constantContact.apiKey" value="{$ctx:constantContact.apiKey}" /> | <with-param name="constantContact.fromEmail" value="{$ctx:constantContact.fromEmail}" /> | <with-param name="constantContact.sendToContactList" value="{$ctx:constantContact.sendToContactList}" /> | <with-param name="constantContact.replyToEmail" value="{$ctx:constantContact.replyToEmail}" /> | <with-param name="constantContact.fromName" value="{$ctx:constantContact.fromName}" /> | <with-param name="constantContact.emailTitle" value="{$ctx:eventbrite.name}" /> | <with-param name="constantContact.url" value="{$ctx:eventbrite.url}" /> | <with-param name="constantContact.urlDescription" value="{$ctx:constantcontact.urlDescription}" /> | <with-param name="constantContact.sheduledDate" value="{$ctx:constantContact.sheduledDate}" /> | ) * </call-template> </else> </filter> </else> </filter> </else> </filter> <property name="eventbrite.eventIndex" expression="get-property('operation','eventbrite.eventIndex') + 1" scope="operation" /> </sequence> </target> </iterate> <!-- FOR EACH event: END --> <filter xpath="get-property('operation','eventbrite.eventIndex') = get-property('operation', 'eventbrite.eventCount')"> <then> <loopback /> </then> </filter> </then> <else> <payloadFactory media-type="json"> <format>{ "Response":{ "process":"eventbrite_retrieveEventsAndMarketing", "activityResponse":"The event list is empty - No entries to be processed." } }</format> <args> <arg expression="get-property('operation','responseString')" /> </args> </payloadFactory> <property name="messageType" value="application/json" scope="axis2" /> <respond /> </else> </filter> </inSequence> <outSequence> <property name="messageType" value="application/json" scope="axis2" /> <payloadFactory media-type="json"> <format>{ "Response":{ "process":"eventbrite_retrieveEventsAndMarketing", "activityResponse":[$1] } }</format> <args> <arg expression="get-property('operation', 'responseString')" /> </args> </payloadFactory> <send /> </outSequence> </target> <description /> </proxy>
Sample Proxy for Retrieving a List of Contacts from Constant Contact who have Clicked on the Link in the Sent Mail Campaign, and Creating a Contact List in Constant Contact
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="eventbrite_retrieveClickersAndCreateContactList" transports="https http" startOnLoad="true" trace="disable"> <description /> <target> <inSequence onError="faultHandlerSeq"> <!-- Constant Contact Properties --> <property name="constantContact.apiUrl" expression="json-eval($.constantContactApiUrl)" /> <property name="constantContact.apiToken" expression="json-eval($.constantContactApiToken)" /> <property name="constantContact.apiKey" expression="json-eval($.constantContactApiKey)" /> <property name="constantContact.campaignId" expression="json-eval($.constantContactCampaignId)" /> <property name="constantContact.contactListId" expression="json-eval($.constantContactContactListId)" /> <!-- Call the Constant Contact connector listCampaignClicks method to retrieve details of clickers. --> <constantcontact.init> <apiUrl>{$ctx:constantContact.apiUrl}</apiUrl> <apiToken>{$ctx:constantContact.apiToken}</apiToken> <apiKey>{$ctx:constantContact.apiKey}</apiKey> </constantcontact.init> <constantcontact.listCampaignClicks> <campaignId>{$ctx:constantContact.campaignId}</campaignId> </constantcontact.listCampaignClicks> <!-- Process only if the clickers list is retrieved successfully. --> <filter source="$axis2:HTTP_SC" regex="200"> <then> <property name="clickersCount" expression="count(//jsonObject/results)" scope="operation" /> <property name="clickerIndex" expression="0" scope="operation" /> <property name="publishedEvents" value="false" scope="operation" /> <filter xpath="get-property('operation', 'clickersCount') != 0"> <then> <!-- FOR EACH clicker: BEGIN --> <iterate continueParent="true" id="clickerIterator" preservePayload="true" expression="//jsonObject/results" sequential="true"> <target> <sequence> <property name="constantContact.contactID" expression="//results/contact_id/text()" /> <!-- Call the Constant Contact connector getContactById method to retrieve details of the contact. --> <constantcontact.init> <apiUrl>{$ctx:constantContact.apiUrl}</apiUrl> <apiToken>{$ctx:constantContact.apiToken}</apiToken> <apiKey>{$ctx:constantContact.apiKey}</apiKey> </constantcontact.init> <constantcontact.getContactById> <contactId>{$ctx:constantContact.contactID}</contactId> </constantcontact.getContactById> <property name="addressCount" expression="count(//jsonObject/addresses)" /> <property name="constantContact.id" expression="json-eval($.id)" /> <property name="constantContact.exsistingList" expression="json-eval($.lists)" /> <property name="constantContact.email" expression="json-eval($.email_addresses[0].email_address)" /> <property name="constantContact.firstName" expression="json-eval($.first_name)" /> <property name="constantContact.middleName" expression="json-eval($.middle_name)" /> <property name="constantContact.lastName" expression="json-eval($.last_name)" /> <property name="constantContact.fax" expression="json-eval($.fax)" /> <property name="constantContact.cellPhone" expression="json-eval($.cell_phone)" /> <property name="constantContact.companyName" expression="json-eval($.company_name)" /> <property name="constantContact.jobtitle" expression="json-eval($.job_title)" /> <property name="constantContact.prefixName" expression="json-eval($.prefix_name)" /> <property name="constantContact.homePhone" expression="json-eval($.home_phone)" /> <property name="constantContact.workPhone" expression="json-eval($.work_phone)" /> <property name="constantContact.customFields" expression="json-eval($.custom_fields)" /> <property name="constantContact.addLine1" expression="json-eval($.addresses[0].line1)" /> <property name="constantContact.addLine2" expression="json-eval($.addresses[0].line2)" /> <property name="constantContact.addCity" expression="json-eval($.addresses[0].city)" /> <property name="constantContact.addCountryCode" expression="json-eval($.addresses[0].country_code)" /> <property name="constantContact.addType" expression="json-eval($.addresses[0].address_type)" /> <property name="constantContact.actionBy" expression="json-eval($.email_addresses[0].opt_in_source)" /> <!-- Process only if the contact has an address. --> <filter xpath="get-property('addressCount') != 0"> <then> <payloadFactory media-type="json"> <format>{ "emailAddresses":[{ "email_address": "$1" }], "addresses":[{ "address_type": "$2", "line1": "$3", "line2": "$4", "city": "$5", "country_code": "$6" }], "list": { "id":"$7" } }</format> <args> <arg expression="get-property('constantContact.email')" /> <arg expression="get-property('constantContact.addType')" /> <arg expression="get-property('constantContact.addLine1')" /> <arg expression="get-property('constantContact.addLine2')" /> <arg expression="get-property('constantContact.addCity')" /> <arg expression="get-property('constantContact.addCountryCode')" /> <arg expression="get-property('constantContact.contactListId')" /> </args> </payloadFactory> <property name="constantContact.addresses" expression="json-eval($.addresses)" /> <property name="constantContact.email" expression="json-eval($.emailAddresses)" /> <property name="constantContact.newList" expression="json-eval($.list)" /> <property name="constantContact.newList" expression="fn:concat(fn:substring(get-property('constantContact.exsistingList'),0,fn:string-length(get-property('constantContact.exsistingList'))),',',get-property('constantContact.newList'),']')" /> </then> <else> <payloadFactory media-type="json"> <format>{ "emailAddresses":[{ "email_address": "$1" }], "list": { "id":"$2" } }</format> <args> <arg expression="get-property('constantContact.email')" /> <arg expression="get-property('constantContact.contactListId')" /> </args> </payloadFactory> <property name="constantContact.email" expression="json-eval($.emailAddresses)" /> <property name="constantContact.newList" expression="json-eval($.list)" /> <property name="constantContact.newList" expression="fn:concat(fn:substring(get-property('constantContact.exsistingList'),0,fn:string-length(get-property('constantContact.exsistingList'))),',',get-property('constantContact.newList'),']')" /> <property name="constantContact.addresses" expression="json-eval($.addresses)" /> </else> </filter> <!-- Call the Constant Contact connector updateContact method to add the contact to the clickers contact list. --> <constantcontact.init> <apiUrl>{$ctx:constantContact.apiUrl}</apiUrl> <apiToken>{$ctx:constantContact.apiToken}</apiToken> <apiKey>{$ctx:constantContact.apiKey}</apiKey> </constantcontact.init> <constantcontact.updateContact> <middleName>{$ctx:constantContact.middleName}</middleName> <lastName>{$ctx:constantContact.lastName}</lastName> <fax>{$ctx:constantContact.fax}</fax> <customFields>{$ctx:constantContact.customFields}</customFields> <cellPhone>{$ctx:constantContact.cellPhone}</cellPhone> <actionBy>{$ctx:constantContact.actionBy}</actionBy> <companyName>{$ctx:constantContact.companyName}</companyName> <homePhone>{$ctx:constantContact.homePhone}</homePhone> <prefixName>{$ctx:constantContact.prefixName}</prefixName> <contactId>{$ctx:constantContact.contactId}</contactId> <workPhone>{$ctx:constantContact.workPhone}</workPhone> <addresses>{$ctx:constantContact.addresses}</addresses> <firstName>{$ctx:constantContact.firstName}</firstName> <lists>{$ctx:constantContact.newList}</lists> <jobTitle>{$ctx:constantContact.jobTitle}</jobTitle> <emailAddresses>{$ctx:constantContact.email}</emailAddresses> </constantcontact.updateContact> <property name="id" expression="fn:concat('{contact_id:',get-property('constantContact.contactID'),'}')"/> <filter source="$axis2:HTTP_SC" regex="200"> <then> <property name="status" value="success" /> <property name="message" expression="fn:concat('The clicker has been added to the contact list [', get-property('constantContact.contactListId'), '].')" /> </then> <else> <property name="status" value="error" /> <property name="message" expression="json-eval($)" /> </else> </filter> <!-- Call the Response Handler template. --> <call-template target="responseHandlerTemplate"> <with-param name="activity" value="constantcontact_updateContact" /> <with-param name="id" value="{$ctx:id}" /> <with-param name="status" value="{$ctx:status}" /> <with-param name="message" value="{$ctx:message}" /> </call-template> <property name="clickerIndex" expression="get-property('operation','clickerIndex') + 1" scope="operation" /> </sequence> </target> </iterate> <!-- FOR EACH clicker: END --> <filter xpath="get-property('operation','clickerIndex') = get-property('operation', 'clickersCount')"> <then> <loopback /> </then> </filter> </then> <else> <payloadFactory media-type="json"> <format>{ "Response":{ "process":"eventbrite_retrieveClickersAndCreateContactList", "activityResponse":"The clickers' list is empty - No contacts to be processed." } }</format> <args> <arg expression="get-property('operation','responseString')" /> </args> </payloadFactory> <property name="messageType" value="application/json" scope="axis2" /> <respond /> </else> </filter> </then> <else> <property name="id" value="{}" /> <property name="status" value="Error" /> <property name="message" expression="json-eval($.)" /> <call-template target="responseHandlerTemplate"> <with-param name="activity" value="eventbrite_retrieveClickersAndCreateContactList" /> <with-param name="id" value="{$ctx:id}" /> <with-param name="status" value="{$ctx:status}" /> <with-param name="message" value="{$ctx:message}" /> </call-template> <loopback /> </else> </filter> </inSequence> <outSequence> <property name="messageType" value="application/json" scope="axis2" /> <payloadFactory media-type="json"> <format>{ "Response":{ "process":"eventbrite_retrieveClickersAndCreateContactList", "activityResponse":[$1] } }</format> <args> <arg expression="get-property('operation', 'responseString')" /> </args> </payloadFactory> <send /> </outSequence> </target> </proxy>
Sample Request for Retrieving a List of Contacts from Constant Contact who have Clicked on the Link in the Sent Mail Campaign, and Creating a Contact List in Constant Contact
{ "constantContactApiUrl":"https://api.constantcontact.com", "constantContactApiToken":"bcb827b5-99d9-48b1-9e53-3030f0d449c3", "constantContactApiKey":"9cwvw4st5apz7m9hvupfh6gg", "constantContactCampaignId":"1119437832992", "constantContactContactListId":"1200801750" }