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/.

Course Training in Canvas

The third use case in the Canvas business scenario is course training. This page describes the relevant tasks and the operations you use in the Canvas connector and the other ESB connectors. It contains the following sections:

Overview

The flow for course training is illustrated in the following diagram. The ESB connectors for GoToTraining, Eventbrite, and MailChimp will be used to connect to each service. GotoTraining can be used as an online training service that facilitates the instructor to perform live training and interactions and provide instructions to the student. Eventbrite is an online ticketing service that allows event organizers to plan and set up ticket sales and promote and publish events. MailChimp is an online e-mail marketing solution used to create campaigns, manage contacts, send e-mails, and track results.

Training management

In this use case, you retrieve a calendar event from Canvas and create it as a paid training in GoToTraining and also as an event in Eventbrite with the required ticket details. You then publish the created event through the Eventbrite API. For published events, you create and send a campaign in MailChimp for marketing purposes. As a prerequisite, MailChimp should have the list of existing subscribers. 

  1. Retrieve calendar events from Canvas using the getCalendarEvent operation.

  2. Create the retrieved events as paid training in GoToTraining using the createTraining operation

  3. Create an event in Eventbrite using the createEvent operation, and create a ticket class for that particular event using the createTicketClass operation. Publish the created event using the publishEvent operation. 

  4. Create a campaign for the published event in MailChimp using the createDraftCampaign operation, and send the campaign using the sendCampaign operation.

    Once the e-mail has been sent from MailChimp, users can access the event, pay online, and purchase tickets for that event in Eventbrite. This is an offline process.

Canvas operations
MailChimp operations
GoToTraining operations
Eventbrite operations
Samples
Sample template for creating a campaign and sending it in MailChimp
	<?xml version="1.0" ?>
<!-- This template is responsible for creating a campaign and sending it in MailChimp 
     according to the given access token of MailChimp with other parameters. -->
<template name="createCampaignAndSend" xmlns="http://ws.apache.org/ns/synapse">
	<!-- MailChimp related template parameters -->
	<parameter name="mailchimp.apiUrl" description="Base endpoint URL of MailChimp API."/>
    <parameter name="mailchimp.apiKey" description="API Authentication Key to access the MailChimp API."/>
	<parameter name="mailchimp.options" description="A struct of the standard options for this campaign."/>
    <parameter name="mailchimp.content" description="The content for this campaign."/>
	<parameter name="mailchimp.listId" description="Id of the Subscriber list."/>
	<parameter name="mailchimp.subject" description="Subject of the campaign."/>
	<parameter name="mailchimp.fromEmail" description="Campaign sender's email."/>
	<parameter name="mailchimp.fromName" description="Sender's name."/>
	<parameter name="mailchimp.toName" description="Receiver's Name."/>
	<parameter name="mailchimp.templateId" description="Id of the campaign template."/>
	<parameter name="mailchimp.eventName" description="Name of the event."/>
	<parameter name="mailchimp.startTime" description="Event start time."/>
	<parameter name="mailchimp.startTimeZone" description="Event start time zone."/>
	<parameter name="mailchimp.endTime" description="Event end time."/>
	<parameter name="mailchimp.endTimeZone" description="Event end time zone."/>
	<parameter name="mailchimp.eventDescription" description="Event description."/>
	<parameter name="mailchimp.eventUrl" description="Url of the event."/>
	<parameter name="campaign.idObject" description="Id as Key value pair(s) for response handler (Ex. id1:value1,id2:value2)."/>
    <sequence>
		<!-- MailChimp related template properties -->
		<property name="mailchimp.apiUrl" expression="$func:mailchimp.apiUrl"/>
		<property name="mailchimp.apiKey" expression="$func:mailchimp.apiKey"/>
		<property name="mailchimp.content" expression="$func:mailchimp.content"/>
		<property name="mailchimp.listId" expression="$func:mailchimp.listId"/>
		<property name="mailchimp.subject" expression="$func:mailchimp.subject"/>
		<property name="mailchimp.fromEmail" expression="$func:mailchimp.fromEmail"/>
		<property name="mailchimp.fromName" expression="$func:mailchimp.fromName"/>
		<property name="mailchimp.toName" expression="$func:mailchimp.toName"/>
		<property name="mailchimp.templateId" expression="$func:mailchimp.templateId"/>
		
		<property name="mailchimp.eventName" expression="$func:mailchimp.eventName"/>
		<property name="mailchimp.startTime" expression="$func:mailchimp.startTime"/>
		<property name="mailchimp.startTimeZone" expression="$func:mailchimp.startTimeZone"/>
		<property name="mailchimp.endTime" expression="$func:mailchimp.endTime"/>
		<property name="mailchimp.endTimeZone" expression="$func:mailchimp.endTimeZone"/>
		<property name="mailchimp.eventDescription" expression="$func:mailchimp.eventDescription"/>
		<property name="mailchimp.eventUrl" expression="$func:mailchimp.eventUrl"/>
		
		<property name="campaign.idObject" expression="$func:campaign.idObject"/>
		
			<!--Building the MailChimp options parameter.-->
			<payloadFactory media-type="json">
			<format>
					{
						"options":{
									"list_id": "$1",
									"subject": "$2",
									"from_email": "$3",
									"from_name": "$4",
									"to_name": "$5",
									"template_id": $6
						}
					}
			</format>
				<args>
					<arg  expression="get-property('mailchimp.listId')"/>
					<arg  expression="get-property('mailchimp.subject')"/>
					<arg  expression="get-property('mailchimp.fromEmail')"/>
					<arg  expression="get-property('mailchimp.fromName')"/>
					<arg  expression="get-property('mailchimp.toName')"/>
					<arg  expression="get-property('mailchimp.templateId')"/>
				</args>
			</payloadFactory>
			
			<property name="mailchimp.options" expression="json-eval($.options)"/>
			
			<!--Building the MailChimp content parameter.-->
			<payloadFactory media-type="json">
					<format>
							{
								"content":{
									"sections": {
										"eventTitle": "$1",
										"startTime":"$2",
										"startTimeZone":"$3",
										"endTime":"$4",
										"endTimeZone":"$5",
										"eventDescription":"$6",
										"eventUrl":"To reserve your ticket please visit: $7"
									}
								}
							}
					</format>
						<args>
							<arg expression="get-property('mailchimp.eventName')"/>
							<arg expression="get-property('mailchimp.startTime')"/>
							<arg expression="get-property('mailchimp.startTimeZone')"/>
							<arg expression="get-property('mailchimp.endTime')"/>
							<arg expression="get-property('mailchimp.endTimeZone')"/>
							<arg expression="get-property('mailchimp.eventDescription')"/>
							<arg expression="get-property('mailchimp.eventUrl')"/>
						</args>
					</payloadFactory>
					
					<property name="mailchimp.content" expression="json-eval($.content)"/>
		
		<!-- If the MailChimp API key is available, proceed with the MailChimp call. -->
		<filter source="boolean(get-property('mailchimp.apiKey'))" regex="true">
            <then> 
				<!-- Calling the MailChimp connector createDraftCampaign method. -->
				<mailchimp.init>
					<apiUrl>{$ctx:mailchimp.apiUrl}</apiUrl>
					<apiKey>{$ctx:mailchimp.apiKey}</apiKey>
					<format>json</format>
				</mailchimp.init>
				<mailchimp.createDraftCampaign>
					<options>{$ctx:mailchimp.options}</options>
					<content>{$ctx:mailchimp.content}</content>
					<type>regular</type>
				</mailchimp.createDraftCampaign>
				
				<!-- Getting the created campaign ID. -->
				<property name="campaignId" expression="json-eval($.id)" />
				
				<filter source="boolean(get-property('campaignId'))" 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('Campaign was successfully created with campaign id ',get-property('campaignId'),'.')" />
					</else>
				</filter>
				<call-template target="responseHandlerTemplate">
							<with-param name="activity" value="mailchimp_createCampaign" />
							<with-param name="id" value="{$ctx:campaign.idObject}" />
							<with-param name="status" value="{$ctx:status}" />
							<with-param name="message" value="{$ctx:message}" />
				</call-template>
				
				<!-- Send the campaign, only if the campaign is created. -->
				<filter source="boolean(get-property('campaignId'))" regex="true">
					<then>
						<mailchimp.init>
							<apiUrl>{$ctx:mailchimp.apiUrl}</apiUrl>
							<apiKey>{$ctx:mailchimp.apiKey}</apiKey>
							<format>json</format>
						</mailchimp.init>
						<mailchimp.sendCampaign>
							<campaignId>{$ctx:campaignId}</campaignId>
						</mailchimp.sendCampaign>
						
						<property name="isCampaignSendComplete" expression="json-eval($.complete)" />
						
						<filter xpath="boolean(get-property('isCampaignSendComplete')) and get-property('isCampaignSendComplete')='true' " >
							<then>
								<property name="status" value="Success" />
								<property name="message" value="Email for the campaign has been sent." />
							</then>
							<else>
								<property name="status" value="Error" />
								<property name="message" expression="json-eval($.)" />
							</else>
						</filter>
						
						<call-template target="responseHandlerTemplate">
							<with-param name="activity" value="mailchimp_sendCampaign" />
							<with-param name="id" value="{$ctx:campaign.idObject}" />
							<with-param name="status" value="{$ctx:status}" />
							<with-param name="message" value="{$ctx:message}" />
						</call-template>
					</then>
				</filter>
            </then>
		</filter>
    </sequence>
</template>
Sample template for creating and publishing events in Eventbrite, creating event tickets, and creating GoToTraining trainings
	<?xml version="1.0" encoding="UTF-8"?>
<!-- This template is responsible for creating the Eventbrite event and event tickets, publishing the event, and
		creating the GotoTraining training. -->
<template xmlns="http://ws.apache.org/ns/synapse"
          name="createEventAndTraining">
		<parameter name="eventbrite.apiUrl" description="URL of the eventbrite API."/>
		<parameter name="eventbrite.accessToken" description="Access token to eventbrite API."/>
		<parameter name="eventbrite.currency" description="Currency code for the event ticket."/>
		<parameter name="eventbrite.venueId" description="Event venue id."/>
		<parameter name="eventbrite.ticketQty" description="Event ticket quantity."/>
		<parameter name="eventbrite.price" description="Event ticket price."/>
		
		<parameter name="gototraining.apiUrl" description="GotoTraining API URL."/>
		<parameter name="gototraining.accessToken" description="Access token to gotoTraining API."/>
        <parameter name="gototraining.organizerKey" description="GotoTraining organizer key."/>
        <parameter name="gototraining.grantType" description="GotoTraining access grant type."/>
        <parameter name="gototraining.userId" description="GotoTraining user id."/>
        <parameter name="gototraining.password" description="GotoTraining account password."/>
        <parameter name="gototraining.clientId" description="GotoTraining client id."/>
        
		<parameter name="event.timezone" description="Event time zone (Olson format)."/>
		<parameter name="event.endTime" description="End time of the event."/>
		<parameter name="event.startTime" description="Start time of the event."/>
		<parameter name="event.name" description="Name of the event."/>
		<parameter name="event.description" description="Description about the event."/>
		<parameter name="event.idObject" description="Id as Key value pair(s) for response handler (Ex. id1:value1,id2:value2)."/>
		
   
	<sequence>
   
		<!-- EventBrite Properties-->
		<property name="eventbrite.apiUrl" expression="$func:eventbrite.apiUrl"/>
		<property name="eventbrite.accessToken" expression="$func:eventbrite.accessToken"/>
		<property name="eventbrite.currency" expression="$func:eventbrite.currency"/>
		<property name="eventbrite.venueId" expression="$func:eventbrite.venueId"/>
		<property name="eventbrite.ticketQty" expression="$func:eventbrite.ticketQty"/>
		<property name="eventbrite.price" expression="$func:eventbrite.price"/>
        <property name="eventbrite.onlineEvent" value="false"/>
		<property name="eventbrite.isFree" value="false"/>
		
		<!-- GotoTraining Properties-->
		<property name="gototraining.apiUrl" expression="$func:gototraining.apiUrl"/>		
		<property name="gototraining.accessToken" expression="$func:gototraining.accessToken"/>
        <property name="gototraining.organizerKey" expression="$func:gototraining.organizerKey"/>
        <property name="gototraining.grantType" expression="$func:gototraining.grantType"/>
        <property name="gototraining.userId" expression="$func:gototraining.userId"/>
        <property name="gototraining.password" expression="$func:gototraining.password"/>
        <property name="gototraining.clientId" expression="$func:gototraining.clientId"/>
		
		<!-- Common Properties-->
		<property name="event.timezone" expression="$func:event.timezone"/>
		<property name="event.endTime" expression="$func:event.endTime"/>
		<property name="event.startTime" expression="$func:event.startTime"/>
		<property name="event.name" expression="$func:event.name"/>
		<property name="event.description" expression="$func:event.description"/>
		<property name="event.idObject" expression="$func:event.idObject"/>
		
		<!-- Operation status flags -->
		<property name="eventbrite.isSuccess" value="false"/>
		<property name="gototraining.isSuccess" value="false"/>
        
		<!-- Process Eventbrite operations, only if the Eventbrite accessToken is provided. -->
		<filter source="boolean(get-property('eventbrite.accessToken'))" regex="true">
			<then>
				<filter source="boolean(get-property('eventbrite.venueId'))" regex="false">
					<then>
						<property name="eventbrite.onlineEvent" value="true"/>
					</then>
				</filter>
				
				<!-- Calling the Eventbrite connector createEvent method. -->
				<eventbrite.init>
					<accessToken>{$ctx:eventbrite.accessToken}</accessToken>
					<apiUrl>{$ctx:eventbrite.apiUrl}</apiUrl>
				</eventbrite.init>
				<eventbrite.createEvent>
					<startTimezone>{$ctx:event.timezone}</startTimezone>
					<endTimezone>{$ctx:event.timezone}</endTimezone>
					<endTime>{$ctx:event.endTime}</endTime>
					<currency>{$ctx:eventbrite.currency}</currency>
					<startTime>{$ctx:event.startTime}</startTime>
					<name>{$ctx:event.name}</name>
					<venueId>{$ctx:eventbrite.venueId}</venueId>
					<description>{$ctx:event.description}</description>
					<onlineEvent>{$ctx:eventbrite.onlineEvent}</onlineEvent>
				</eventbrite.createEvent> 
				<sequence key="removeResponseHeaders" />
						
				<property name="eventbriteEventId" expression="json-eval($.id)" />
				
				<filter source="boolean(get-property('eventbriteEventId'))" 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('Event Created successfully with the Event Id ',get-property('eventbriteEventId'),' .')" />
					</else>
				</filter>
				<call-template target="responseHandlerTemplate">
					<with-param name="id" value="{$ctx:event.idObject}" />
					<with-param name="activity" value="eventbrite_createEvent" />
					<with-param name="status" value="{$ctx:status}" />
					<with-param name="message" value="{$ctx:message}" />
				</call-template>
				
				
						
				<!-- Create the event ticket, only if the event is created. -->
				<filter source="boolean(get-property('eventbriteEventId'))" regex="true">
					<then>
						<filter source="boolean(get-property('eventbrite.price'))" regex="false">
							<then>
								<property name="eventbrite.isFree" value="true"/>
								<property name="eventbrite.currency" value=" "/>
							</then>
						</filter>
						<eventbrite.init>
							<accessToken>{$ctx:eventbrite.accessToken}</accessToken>
							<apiUrl>{$ctx:eventbrite.apiUrl}</apiUrl>
						</eventbrite.init>
						<eventbrite.createTicketClass>
							<eventId>{$ctx:eventbriteEventId}</eventId>
							<className>{$ctx:event.name}</className>
							<classDescription>{$ctx:event.name}</classDescription>
							<quantityTotal>{$ctx:eventbrite.ticketQty}</quantityTotal>
							<costCurrency>{$ctx:eventbrite.currency}</costCurrency>
							<costValue>{$ctx:eventbrite.price}</costValue>
							<isFree>{$ctx:eventbrite.isFree}</isFree>
						</eventbrite.createTicketClass>
						
						<!-- Remove custom headers from the Eventbrite response.-->
						<sequence key="eventbrite-removeResponseHeaders" />
						<sequence key="removeResponseHeaders" />
						
						<property name="eventbriteTicketId" expression="json-eval($.id)" />
						
						<filter source="boolean(get-property('eventbriteTicketId'))" 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('Ticket Created successfully with the Ticket Id ',get-property('eventbriteTicketId'),' .')" />
							</else>
						</filter>
						
						<call-template target="responseHandlerTemplate">
							<with-param name="id" value="{$ctx:event.idObject}" />
							<with-param name="activity" value="eventbrite_createEventTicket" />
							<with-param name="status" value="{$ctx:status}" />
							<with-param name="message" value="{$ctx:message}" />
						</call-template>
						
						
						<!-- Publish the event, only if the event ticket is created. -->
						<filter source="boolean(get-property('eventbriteTicketId'))" regex="true">
							<then>
								<eventbrite.init>
									<accessToken>{$ctx:eventbrite.accessToken}</accessToken>
									<apiUrl>{$ctx:eventbrite.apiUrl}</apiUrl>
								</eventbrite.init>
								<eventbrite.publishEvent>
									<eventId>{$ctx:eventbriteEventId}</eventId>
								</eventbrite.publishEvent>	
								<!-- Remove custom headers from eventbrite response.-->
								<sequence key="eventbrite-removeResponseHeaders" />
								<sequence key="removeResponseHeaders" />
								<property name="eventPublished" expression="json-eval($.published)" />
						
								<filter source="boolean(get-property('eventPublished'))" 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('Event [',get-property('eventbriteEventId'),'] has been published.')" />
										<property name="eventbrite.isSuccess" value="true"/>
									</else>
								</filter>
								<call-template target="responseHandlerTemplate">
									<with-param name="id" value="{$ctx:event.idObject}" />
									<with-param name="activity" value="eventbrite_publishEvent" />
									<with-param name="status" value="{$ctx:status}" />
									<with-param name="message" value="{$ctx:message}" />
								</call-template>
								
								
							</then>
							
						</filter>
						
					</then>
				</filter> 
			</then>
		</filter>
		
		<!-- Process gotoTraining operations, only if the gotoTraining accessToken is provided. -->
		<filter source="boolean(get-property('gototraining.accessToken'))" regex="true">
			<then>
				<payloadFactory media-type="json">
						<format>
							{
							"times": [
										{
										  "startDate": "$1",
										  "endDate": "$2"
										}
									]
							}
						</format>
						<args>
							<arg expression="get-property('event.startTime')" />
							<arg expression="get-property('event.endTime')" />
						</args>
		        </payloadFactory>
				
				<property name="gototraining.times" expression="json-eval($.times)" />
				
				
				<gototraining.init>
					<accessToken>{$ctx:gototraining.accessToken}</accessToken>
					<organizerKey>{$ctx:gototraining.organizerKey}</organizerKey>
					<grantType>{$ctx:gototraining.grantType}</grantType>
					<userId>{$ctx:gototraining.userId}</userId>
					<password>{$ctx:gototraining.password}</password>
					<clientId>{$ctx:gototraining.clientId}</clientId>
					<apiUrl>{$ctx:gototraining.apiUrl}</apiUrl>
				</gototraining.init>
				<gototraining.createTraining>
					<name>{$ctx:event.name}</name>
					<description>{$ctx:event.description}</description>
					<timeZone>{$ctx:event.timezone}</timeZone>
					<times>{$ctx:gototraining.times}</times>
				</gototraining.createTraining>
				<filter source="$axis2:HTTP_SC" regex="201">
					<then>
						<property name="status" value="Success" />
						<property name="message" expression="fn:concat('Training Created successfully ','.')" />
						<property name="gototraining.isSuccess" value="true"/>
					</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:canvas.event.idObject}" />
					<with-param name="activity" value="gotoTraining_createTraining" />
					<with-param name="status" value="{$ctx:status}" />
					<with-param name="message" value="{$ctx:message}" />
				</call-template>
			</then>
		</filter>
	</sequence>
</template>
Sample Proxy for Retrieving Canvas Calendar Events, Creating them as Events in Eventbrite, and Creating Paid Training in GoToTraining
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="canvas_createTrainingAsEventAndCampaign" transports="https" statistics="disable" trace="disable" startOnLoad="true">
    <target>
        <inSequence onError="faultHandlerSeq">
            <!--Canvas Properties-->
            <property name="canvas.apiUrl" expression="json-eval($.canvasApiUrl)" />
            <property name="canvas.accessToken" expression="json-eval($.canvasAccessToken)" />
			<property name="canvas.calendarEventCount" expression="count(//canvasCalendarEvents/data)" scope="operation" />
			<property name="canvas.calendarEventIndex" value="0"  scope="operation" />
			
			<!--EventBrite Properties-->
            <property name="eventbrite.apiUrl" expression="json-eval($.eventbriteApiUrl)" />
            <property name="eventbrite.accessToken" expression="json-eval($.eventbriteAccessToken)" />
			
			<!-- GotoTraining Properties-->
			<property name="gototraining.apiUrl" expression="json-eval($.gototrainingApiUrl)"/>
			<property name="gototraining.accessToken" expression="json-eval($.gototrainingAccessToken)"/>
            <property name="gototraining.organizerKey" expression="json-eval($.gototrainingOrganizerKey)"/>
            <property name="gototraining.grantType" expression="json-eval($.gototrainingGrantType)"/>
            <property name="gototraining.userId" expression="json-eval($.gototrainingUserId)"/>
            <property name="gototraining.password" expression="json-eval($.gototrainingPassword)"/>
            <property name="gototraining.clientId" expression="json-eval($.gototrainingClientId)"/>
			
			<!--MailChimp related properties-->
			<property name="mailchimp.apiUrl" expression="json-eval($.mailchimpApiUrl)"/>
			<property name="mailchimp.apiKey" expression="json-eval($.mailchimpApiKey)"/>
			<property name="mailchimp.listId" expression="json-eval($.mailchimpListId)"/>
			<property name="mailchimp.subject" expression="json-eval($.mailchimpSubjectPrefix)"/>
			<property name="mailchimp.fromEmail" expression="json-eval($.mailchimpFromEmail)"/>
			<property name="mailchimp.fromName" expression="json-eval($.mailchimpFromName)"/>
			<property name="mailchimp.toName" expression="json-eval($.mailchimpToName)"/>
			<property name="mailchimp.templateId" expression="json-eval($.mailchimpTemplateId)"/>
            
             <iterate continueParent="true" id="calendarEvents" expression="//canvasCalendarEvents/data" sequential="true">
                <target>
					<sequence>
						<property name="canvas.calendarEventId" expression="//data/calendarEventId/text()" />
						<property name="eventbrite.price" expression="//data/price/text()" />
						<property name="eventbrite.currency" expression="//data/currency/text()" />
						<property name="eventbrite.venueId" expression="//data/venueId/text()" />
						<property name="eventbrite.timeZone" expression="//data/timeZone/text()" />
						<property name="eventbrite.ticketQty" expression="//data/ticketQty/text()" />
						
						<canvas.init>
							<apiUrl>{$ctx:canvas.apiUrl}</apiUrl>
							<accessToken>{$ctx:canvas.accessToken}</accessToken>
						</canvas.init>
						<canvas.getCalendarEvent>
							<calendarEventId>{$ctx:canvas.calendarEventId}</calendarEventId>
						</canvas.getCalendarEvent>
						<!--Removing Content-Encoding and Status Headers. -->
						<header name="Content-Encoding" action="remove" scope="transport" />
						<header name="Status" action="remove" scope="transport" />
						
						<property name="canvasCalendarEventId" expression="json-eval($.id)" />
						
						<filter source="boolean(get-property('canvasCalendarEventId'))" regex="false">
							<then>
								<property name="status" value="Error" />
								<property name="message" expression="json-eval($.)" />
								
								<call-template target="responseHandlerTemplate">
									<with-param name="id" value="{}" />
									<with-param name="activity" value="canvas_createTrainingAsEventAndCampaign" />
									<with-param name="status" value="{$ctx:status}" />
									<with-param name="message" value="{$ctx:message}" />
								</call-template>
							</then>
							<else>
								<property name="canvas.eventName" expression="json-eval($.title)" />
								<property name="canvas.eventStartTime" expression="json-eval($.start_at)" />
								<property name="canvas.eventEndTime" expression="json-eval($.end_at)" />
								<property name="canvas.description" expression="json-eval($.description)" type="OM"/>
								<property name="mailchimp.subject" expression="fn:concat(get-property('mailchimp.subject'),' - ',get-property('canvas.eventName'))"/>
								<property name="canvas.idObject" expression="fn:concat('event_id:',get-property('canvas.calendarEventId'))"/>
								
								<filter source="boolean(get-property('canvas.description'))" regex="false">
									<then>
										<property name="canvas.description" value="No Description."/>
									</then>
								</filter>
								
								<call-template target="createEventAndTraining">
									   <!-- Parameter values will be passed on to a sequence template. -->
									   (
										<with-param name="eventbrite.apiUrl" value="{$ctx:eventbrite.apiUrl}" /> |
										<with-param name="eventbrite.accessToken" value="{$ctx:eventbrite.accessToken}" /> |
										<with-param name="eventbrite.venueId" value="{$ctx:eventbrite.venueId}" /> |
									    <with-param name="eventbrite.currency" value="{$ctx:eventbrite.currency}" /> |
										<with-param name="eventbrite.price" value="{$ctx:eventbrite.price}" /> |
										<with-param name="eventbrite.ticketQty" value="{$ctx:eventbrite.ticketQty}" /> |
										<with-param name="event.timezone" value="{$ctx:eventbrite.timeZone}" /> |
										<with-param name="event.endTime" value="{$ctx:canvas.eventEndTime}" /> |
										<with-param name="event.startTime" value="{$ctx:canvas.eventStartTime}" /> |
										<with-param name="event.name" value="{$ctx:canvas.eventName}" /> |
										<with-param name="event.description" value="{$ctx:canvas.description}" /> |
										<with-param name="event.idObject" value="{$ctx:canvas.idObject}" /> |
										<with-param name="gototraining.accessToken" value="{$ctx:gototraining.accessToken}" /> |
										<with-param name="gototraining.apiUrl" value="{$ctx:gototraining.apiUrl}" /> |
										<with-param name="gototraining.organizerKey" value="{$ctx:gototraining.organizerKey}" /> |
										<with-param name="gototraining.grantType" value="{$ctx:gototraining.grantType}" /> |
										<with-param name="gototraining.userId" value="{$ctx:gototraining.userId}" /> |
										<with-param name="gototraining.password" value="{$ctx:gototraining.password}" /> |
										<with-param name="gototraining.clientId" value="{$ctx:gototraining.clientId}" /> |
									    ) *
								</call-template>
								
								<!-- Call the createCampaignAndSend template, only if the event is created. -->
								<filter source="get-property('eventbrite.isSuccess')" regex="true">
									<then>
										
										<eventbrite.init>
											<accessToken>{$ctx:eventbrite.accessToken}</accessToken>
											<apiUrl>{$ctx:eventbrite.apiUrl}</apiUrl>
										</eventbrite.init>
										<eventbrite.eventDetails>
											<EventID>{$ctx:eventbriteEventId}</EventID>
										</eventbrite.eventDetails>
										
										<property name="eventbrite.eventName" expression="json-eval($.name.text)"/>
										<property name="eventbrite.startTime" expression="json-eval($.start.local)"/>
										<property name="eventbrite.startTimeZone" expression="json-eval($.start.timezone)"/>
										<property name="eventbrite.endTime" expression="json-eval($.end.local)"/>
										<property name="eventbrite.endTimeZone" expression="json-eval($.end.timezone)"/>
										<property name="eventbrite.eventDescription" expression="json-eval($.description.text)"/>
										<property name="eventbrite.eventUrl" expression="json-eval($.url)"/>
										
										<!-- Remove custom headers before calling the canvas-eventMarketing template.-->
										<sequence key="eventbrite-removeResponseHeaders" />
										
										<!-- Call the template createCampaignAndSend to create a campaign and send for events.-->
										<call-template target="createCampaignAndSend">
											(
											<with-param name="mailchimp.apiUrl" value="{$ctx:mailchimp.apiUrl}"/>|
											<with-param name="mailchimp.apiKey" value="{$ctx:mailchimp.apiKey}"/>|
											<with-param name="mailchimp.options" value="{$ctx:mailchimp.options}"/>|
											<with-param name="mailchimp.content" value="{$ctx:mailchimp.content}"/>|
											<with-param name="campaign.idObject" value="{$ctx:canvas.idObject}" /> |
											<with-param name="mailchimp.listId" value="{$ctx:mailchimp.listId}" /> |
											<with-param name="mailchimp.subject" value="{$ctx:mailchimp.subject}" /> |
											<with-param name="mailchimp.fromEmail" value="{$ctx:mailchimp.fromEmail}" /> |
											<with-param name="mailchimp.fromName" value="{$ctx:mailchimp.fromName}" /> |
											<with-param name="mailchimp.toName" value="{$ctx:mailchimp.toName}" /> |
											<with-param name="mailchimp.templateId" value="{$ctx:mailchimp.templateId}" /> |
											<with-param name="mailchimp.eventName" value="{$ctx:eventbrite.eventName}" /> |
											<with-param name="mailchimp.startTime" value="{$ctx:eventbrite.startTime}" /> |
											<with-param name="mailchimp.startTimeZone" value="{$ctx:eventbrite.startTimeZone}" /> |
											<with-param name="mailchimp.endTime" value="{$ctx:eventbrite.endTime}" /> |
											<with-param name="mailchimp.endTimeZone" value="{$ctx:eventbrite.endTimeZone}" /> |
											<with-param name="mailchimp.eventDescription" value="{$ctx:eventbrite.eventDescription}" /> |
											<with-param name="mailchimp.eventUrl" value="{$ctx:eventbrite.eventUrl}" /> |
											) *
										</call-template>
									</then>
									<else>
										<property name="status" value="skipped" />
										<property name="message" value="Marketing campaign creation skipped, because event is being not created." />
										
										<call-template target="responseHandlerTemplate">
											<with-param name="id" value="{$ctx:event.idObject}" />
											<with-param name="activity" value="mailchimp_createAndSendCampaign" />
											<with-param name="status" value="{$ctx:status}" />
											<with-param name="message" value="{$ctx:message}" />
										</call-template>
									</else>
									
								</filter>
								
							</else>
						</filter>
						
						<property name="canvas.calendarEventIndex" expression="get-property('operation','canvas.calendarEventIndex') + 1" scope="operation" />
					</sequence>
                </target>
            </iterate>
			<filter xpath="get-property('operation','canvas.calendarEventCount') = get-property('operation','canvas.calendarEventIndex')">
				<then>
					<loopback />
				</then>
			</filter>
            
        </inSequence>
        <outSequence>
            <payloadFactory media-type="json">
                <format>{
					"Response":{
						"process":"canvas_createTrainingAsEventAndCampaign",
						"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 Canvas calendar events, creating them as events in Eventbrite, and creating paid training in GoToTraining
{
"canvasApiUrl":"https://canvas.instructure.com",
"canvasAccessToken":"7~UnsR6KCrYoap7KyAYMfNvANQeD59OinOIRp0S82FU7z1o5dz7o0VIBqNl6afoVBO",
"canvasCalendarEvents":{"data":[
				{
					"calendarEventId":"868705",
					"price":"",
					"currency":"USD",
					"timeZone":"Asia/Colombo",
					"venueId":"",
					"ticketQty":"50"
				},
				{
					"calendarEventId":"878455",
					"price":"",
					"currency":"USD",
					"timeZone":"Asia/Colombo",
					"venueId":"",
					"ticketQty":"50"
				}
			]
			},
"eventbriteApiUrl":"https://www.eventbriteapi.com",
"eventbriteAccessToken":"4SMVCVGYVT2K3FYPMMLP",
"gototrainingApiUrl": "https://api.citrixonline.com",
"gototrainingAccessToken": "zR14S7cGFWC0UXuujbYP5DGKbeOR",
"gototrainingOrganizerKey": "3596608450020387846",
"gototrainingGrantType": "password",
"gototrainingUserId": "wso2connector@gmail.com",
"gototrainingPassword": "1qaz2wsx@",
"gototrainingClientId": "2UVpqLxGDrkcQvs0JGvUMDyO1Mha9FT0",
"mailchimpApiUrl": "https://us9.api.mailchimp.com",
    "mailchimpApiKey": "2ad58ea9a2e332a6fe0a4ef6ea6dca10-us9",
    "mailchimpListId": "0239fb6051",
    "mailchimpSubjectPrefix": "Oracle University",
    "mailchimpFromEmail": "palamayuranrox@gmail.com",
    "mailchimpFromName": "Oracle University Admin",
    "mailchimpToName": "Dear Subscriber",
    "mailchimpTemplateId": 171393
}

Manage attendees

In this use case, you retrieve attendees from Eventbrite and create them as registrants in GoToTraining. You also add them to the MailChimp subscribers list if they are not in the list already. 

  1. Retrieve attendees from Eventbrite using the eventAttendees operation. Create the retrieved attendees as registrants in GoToTraining using the addRegistrant operation. 

  2. Add the attendees to the MailChimp subscribers list using the addSubscribersToList operation, if they are not in the list. 

MailChimp operations
GoToTraining operations
Eventbrite operations
  • eventAttendees

Samples
Sample proxy for retrieving attendees' email addresses from Eventbrite on a specific event
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="canvas_addSubscribersToMailChimpAndRegistrantsToGotoTraining"
       transports="https"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
      	<inSequence onError="faultHandlerSeq">
	  
	 	<!-- Eventbrite parameters -->
	  	<property name="eventbrite.apiUrl" expression="json-eval($.eventbriteApiUrl)" />
	  	<property name="eventbrite.accessToken" expression="json-eval($.eventbriteAccessToken)" />
	  	<property name="eventbrite.eventId" expression="json-eval($.eventbriteEventId)" />
	  	<!-- MailChimp parameters -->
	  	<property name="mailchimp.apiUrl" expression="json-eval($.mailChimpApiUrl)" />
	  	<property name="mailchimp.apiKey" expression="json-eval($.mailChimpApiKey)" />
      	<property name="mailchimp.updateExisting" expression="json-eval($.mailChimpUpdateExisting)"/>
	  	<property name="mailchimp.listId" expression="json-eval($.mailChimpListId)"/>
	  	<!-- GoToTraining parameters -->
      	<property name="gototraining.apiUrl" expression="json-eval($.gototrainingApiUrl)"/>
	  	<property name="gototraining.accessToken" expression="json-eval($.gototrainingAccessToken)"/>
	  	<property name="gototraining.organizerKey" expression="json-eval($.gototrainingOrganizerKey)"/>
	  	<property name="gototraining.trainingKey" expression="json-eval($.gototrainingTrainingKey)"/>
	  	<property name="emailBuilder" value="[" scope="operation"/>
	  	<property name="emailList" value="" scope="operation"/>
	  
	  	<!-- Retrieve event attendees from Eventbrite. -->
	   	<eventbrite.init>
            <apiUrl>{$ctx:eventbrite.apiUrl}</apiUrl>
            <accessToken>{$ctx:eventbrite.accessToken}</accessToken>
        </eventbrite.init>
        <eventbrite.eventAttendees>
            <EventID>{$ctx:eventbrite.eventId}</EventID>
        </eventbrite.eventAttendees>
        <sequence key="eventbrite-removeResponseHeaders" />
	   	<property name="noOfAttendees" expression="count(//attendees)" scope="operation" />
        <property name="attendeesIndex" expression="0" scope="operation" />
        <filter xpath="get-property('operation','noOfAttendees') = get-property('operation','attendeesIndex')">
        	<then>
				<property name="id" expression="fn:concat('eventbrite_eventId:', get-property('eventbrite.eventId'))" />
                <property name="status" value="Failure" />
                <property name="message" value="No attendees were found for the event." />
                <!--Call the response handler template.-->
		        <call-template target="responseHandlerTemplate">
		        	<with-param name="activity" value="gototraining_addResgistrantToTraining" />
		            <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>
				<!--FOR EACH Attendee: BEGIN-->
		        <iterate continueParent="false" id="attendees" expression="//attendees" sequential="true">
		            <target>
		                <sequence>
		                	<!--Store the attendee's e-mail address in the MailChimp subscriber list.-->
		                    <property name="attendeeEmail" expression="//attendees/profile/email/text()" />
		                    <property name="fullName" expression="//attendees/profile/name/text()" />
		                    <property name="firstName" expression="//attendees/profile/first_name/text()" />
		                    <property name="lastName" expression="//attendees/profile/last_name/text()" />
		                    <property name="timeZone" expression="//attendees/event/start/timezone/text()" />
							<!--Concatanate the emails to build an array in a way MailChimp expects.-->
							<property name="emailJSON" expression="fn:concat('{ &quot;email&quot;: { &quot;email&quot;: &quot;',get-property('attendeeEmail'),'&quot; },&quot;email_type&quot;: &quot;html&quot;}')" /> 
							<property name="emailBuilder" expression="fn:concat(get-property('operation','emailBuilder'), get-property('emailJSON') , ', ')" scope="operation"/>
						   	<!--Add the user as the registrant in GoToTraining.-->
		                    <call-template target="addUsersAndRegistrants">
					   			<with-param name="gototraining.apiUrl" value="{$ctx:gototraining.apiUrl}" />
					   			<with-param name="gototraining.accessToken" value="{$ctx:gototraining.accessToken}" />
					   			<with-param name="gototraining.organizerKey" value="{$ctx:gototraining.organizerKey}" />
					   			<with-param name="gototraining.trainingKey" value="{$ctx:gototraining.trainingKey}" />
					   			<with-param name="fullName" value="{$ctx:fullName}" />
					   			<with-param name="email" value="{$ctx:attendeeEmail}" />
					   			<with-param name="firstName" value="{$ctx:firstName}" />
							   	<with-param name="lastName" value="{$ctx:lastName}" />
							   	<with-param name="timeZone" value="{$ctx:timeZone}" />
					 		</call-template>
					 		<!--Increment the attendee count.-->
                            <property name="attendeesIndex" expression="get-property('operation', 'attendeesIndex') + 1" scope="operation" />						   	
						</sequence>
					</target>    					
		        </iterate>	
		        <!--FOR EACH Attendee: END-->
				
                <filter xpath="get-property('operation', 'noOfAttendees') = get-property('operation', 'attendeesIndex')">
                    <then>                        	
                    	<property name="mailchimp.batch" expression="fn:concat(fn:substring(get-property('operation', 'emailBuilder'), 0, fn:string-length(get-property('operation', 'emailBuilder')) - 1), ']')"/>
						
						<!-- Add the attendee email address to the subscriber list in MailChimp. -->
						<mailchimp.init>
				            <apiUrl>{$ctx:mailchimp.apiUrl}</apiUrl>
				            <apiKey>{$ctx:mailchimp.apiKey}</apiKey>
				            <format>json</format>
				        </mailchimp.init>
						<mailchimp.addSubscribersToList>
						    <listId>{$ctx:mailchimp.listId}</listId>
						    <batch>{$ctx:mailchimp.batch}</batch>
						    <doubleOptin>false</doubleOptin>
						    <updateExisting>{$ctx:mailchimp.updateExisting}</updateExisting>
						    <replaceInterests>false</replaceInterests>
						</mailchimp.addSubscribersToList>
						<property name="noOfAttendeesAdded" expression="json-eval($.add_count)" />
						<filter source="boolean(get-property('noOfAttendeesAdded'))" regex="true">
							<then>
								<!--Store the attendee details in the MailChimp subscriber list.-->
								<property name="id" expression="fn:concat('mailchimp_listId', get-property('mailchimp.listId'))" />
						        <property name="status" value="Added" />
						        <property name="message" expression="fn:concat('No. of email addresses added to subscription list: ', get-property('noOfAttendeesAdded'))" />
							</then>
							<else>
								<!-- In a failure, while adding the attendee details in the MailChimp subscriber list.-->
								<property name="id" expression="fn:concat('mailchimp_listId', get-property('mailchimp.listId'))" />
						        <property name="status" value="Failure" />
						        <property name="message" expression="json-eval($)" />
							</else>
						</filter>
				        <!--Call the response handler template.-->
				        <call-template target="responseHandlerTemplate">
				            <with-param name="activity" value="mailchimp_addSubscribersToList" />
				            <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>
                </filter>
                
			</else>	
		</filter>
      </inSequence>
      <outSequence>
         <payloadFactory media-type="json">
                <format>{
					"Response":{
						"activity":"canvas-addSubscribersToMailChimpAndRegistrantsToGotoTraining",
						"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' email addresses from Eventbrite on a specific event
{
	"eventbriteApiUrl" : "https://www.eventbriteapi.com",
	"eventbriteAccessToken" : "O5CHYSIJQPS7QNQKBYU6",
	"eventbriteEventId" : "14747958541",
	"mailChimpApiUrl" : "https://us9.api.mailchimp.com",
	"mailChimpApiKey" : "33b1f0d89fe028aa2039029d0164344a-us9",
	"mailChimpUpdateExisting" : "false",
	"mailChimpListId" : "c49ef78b31",
	"gototrainingApiUrl" : "https://api.citrixonline.com",
	"gototrainingAccessToken" : "BaOzgIYVLCkb7Pxhod0oH72Dhrmk",
	"gototrainingOrganizerKey" : "3293142141408683781",
	"gototrainingTrainingKey" : "4219188218008573185"
}