The first use case in the /wiki/spaces/CONNECTORS/pages/48465394is course initiation. 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 initiation is illustrated in the following diagram. The ESB connectors for Eventbrite, MailChimp, and Google Calendar will be used to connect to each service. Eventbrite is an online ticketing service that allows event organizers to plan, set up ticket sales, and promote and publish events. MailChimp is an online email marketing solution used to create campaigns, manage contacts, send emails, and track results. Google Calendar can be used as a communication medium through which the students can be notified/reminded about appointments and notifications.
Course creation and marketing
In this use case, we will create a course in Canvas as an offline process. We can retrieve this course from Canvas, create it as a paid event with the required ticket details in the Eventbrite API, and then publish it through the Eventbrite API. For the published events, we can create a campaign in the MailChimp API and send it for marketing purposes. As a prerequisite, MailChimp should have a list of existing subscribers.
Retrieve the course from Canvas using the getCourse operation.
In Eventbrite, create a paid event using the createEvent operation, create the ticket details associated with the event using the createTicketClass operation, and publish the event using the publishEvent operation.
In MailChimp, create a campaign using the createDraftCampaign operation, and then send the campaign using the sendCampaign operation.
Once the e-mail has been sent from MailChimp, users can access the event in Eventbrite through the e-mail sent from MailChimp, and they can pay online and purchase tickets for the event in Eventbrite. This is an offline process.
MailChimp operations
Canvas operations
Eventbrite operations
Samples
<?xml version="1.0" ?> <!-- This template is responsible for creating a campaign and sending 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>
The following sample template shows how to create an event as well as training, which is covered in /wiki/spaces/CONNECTORS/pages/48465429.
<?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 the 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>
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="canvas_createCourseAsEventAndCampaign" 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.courseCount" expression="count(//canvasCourses/data)" scope="operation" /> <property name="canvas.courseIndex" value="0" scope="operation" /> <!--Eventbrite Properties--> <property name="eventbrite.apiUrl" expression="json-eval($.eventbriteApiUrl)" /> <property name="eventbrite.accessToken" expression="json-eval($.eventbriteAccessToken)" /> <!--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="courses" expression="//canvasCourses/data" sequential="true"> <target> <sequence> <property name="canvas.courseId" expression="//data/courseId/text()" /> <property name="canvas.accountId" expression="//data/accountId/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()" /> <!-- Calling the Canvas connector getCourse method to retrieve course details. --> <canvas.init> <apiUrl>{$ctx:canvas.apiUrl}</apiUrl> <accessToken>{$ctx:canvas.accessToken}</accessToken> </canvas.init> <canvas.getCourse> <accountId>{$ctx:canvas.accountId}</accountId> <courseId>{$ctx:canvas.courseId}</courseId> <include>syllabus_body</include> </canvas.getCourse> <!--Removing the Content-Encoding and Status Headers. --> <sequence key="removeResponseHeaders" /> <property name="canvasCourseId" expression="json-eval($.id)" /> <filter source="boolean(get-property('canvasCourseId'))" regex="false"> <then> <property name="status" value="Error" /> <property name="message" expression="json-eval($.)" /> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:event.idObject}" /> <with-param name="activity" value="canvas_createCourseAsEventAndCampaing" /> <with-param name="status" value="{$ctx:status}" /> <with-param name="message" value="{$ctx:message}" /> </call-template> </then> <else> <property name="canvas.courseName" expression="json-eval($.name)" /> <property name="canvas.courseStartTime" expression="json-eval($.start_at)" /> <property name="canvas.courseEndTime" expression="json-eval($.end_at)" /> <property name="canvas.description" expression="json-eval($.syllabus_body)" type="OM"/> <property name="canvas.idObject" expression="fn:concat('course_id:',get-property('canvas.courseId'))"/> <property name="mailchimp.subject" expression="fn:concat(get-property('mailchimp.subject'),' - ',get-property('canvas.courseName'))"/> <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.courseEndTime}" /> | <with-param name="event.startTime" value="{$ctx:canvas.courseStartTime}" /> | <with-param name="event.name" value="{$ctx:canvas.courseName}" /> | <with-param name="event.description" value="{$ctx:canvas.description}" /> | <with-param name="event.idObject" value="{$ctx:canvas.idObject}" /> | ) * </call-template> <!-- Call the campaign 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 unwanted 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 has not been created." /> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:canvas.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.courseIndex" expression="get-property('operation','canvas.courseIndex') + 1" scope="operation" /> </sequence> </target> </iterate> <filter xpath="get-property('operation','canvas.courseCount') = get-property('operation','canvas.courseIndex')"> <then> <loopback /> </then> </filter> </inSequence> <outSequence> <payloadFactory media-type="json"> <format>{ "Response":{ "process":"canvas-createCourseAsEventAndCampaing", "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>
{ "canvasApiUrl":"https://canvas.instructure.com", "canvasAccessToken":"7~5pA2tUv3iq22u5BqMI8T3FyId333J2atYt4e1KMNAptdFsfBqCEVrREg0I0hPTcv", "canvasCourses":{"data":[ { "courseId":"893240", "accountId":"81259", "price":"1000", "currency":"JPY", "timeZone":"Asia/Colombo", "venueId":"9176393", "ticketQty":"50" }, { "courseId":"902512", "accountId":"81259", "price":"", "currency":"JPY", "timeZone":"Asia/Colombo", "venueId":"9176393", "ticketQty":"50" } ] }, "eventbriteApiUrl":"https://www.eventbriteapi.com", "eventbriteAccessToken":"4SMVCVGYVT2K3FYPMMLP", "mailchimpApiUrl": "https://us9.api.mailchimp.com", "mailchimpApiKey": "2ad58ea9a2e332a6fe0a4ef6ea6dca10-us9", "mailchimpListId": "0239fb6051", "mailchimpSubjectPrefix": "University of Oracle", "mailchimpFromEmail": "palamayuranrox@gmail.com", "mailchimpFromName": "Marketing Department - Oracle University", "mailchimpToName": "Dear Subscriber", "mailchimpTemplateId": 171393 }
Course management
You can retrieve attendees from Eventbrite and add them as users to the course in Canvas, or you can add them to the MailChimp subscribers list, if they are not in the list already. The users added to Canvas will receive an e-mail invitation, which they can use to register themselves to the course. You can retreive the enrolled users from Canvas and create a calendar that you can share with them in Google Calendar. To perform this step, students must have a given Gmail ID.
- Retrieve attendees from Eventbrite using the /wiki/spaces/CONNECTORS/pages/48465408 operation.
- Add the attendees to the MailChimp subscribers list using the /wiki/spaces/CONNECTORS/pages/48465308 operation.
- Using the addUser operation, add the attendees as users, and then enroll the user using the enrollUser operation in Canvas. Retrieve the users belonging to a course using the listCourseUsers operation.
- If the calendar ID is not provided, and if the user provided sufficient details to create a calendar, use the createCalendar operation of the Google Calendar connector to create a new calendar. In order to provide permissions for users, use the createAcl operation of the Google Calendar connector.
Google Calendar operations
MailChimp operations
Canvas operations
Eventbrite operations
Samples
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="canvas_addSubscribersToMailChimpAndAddingUsersToCanvas" 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)"/> <!-- Canvas parameters --> <property name="canvas.apiUrl" expression="json-eval($.canvasApiUrl)" /> <property name="canvas.accessToken" expression="json-eval($.canvasAccessToken)" /> <property name="canvas.accountId" expression="json-eval($.canvasAccountId)"/> <property name="canvas.courseId" expression="json-eval($.canvasCourseId)"/> <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="Failed" /> <property name="message" value="No attendees were found for the event." /> <!--Call the responseHandler template.--> <call-template target="responseHandlerTemplate"> <with-param name="activity" value="canvas_addUserToAccountAndEnroll" /> <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="true" id="attendees" expression="//attendees" sequential="true"> <target> <sequence> <!--Store the attendee's email 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('{ "email": { "email": "',get-property('attendeeEmail'),'" },"email_type": "html"}')" /> <property name="emailBuilder" expression="fn:concat(get-property('operation','emailBuilder'), get-property('emailJSON') , ', ')" scope="operation"/> <!--Add users to Canvas and enroll them for the course.--> <call-template target="addUsersAndRegistrants"> <with-param name="canvas.apiUrl" value="{$ctx:canvas.apiUrl}" /> <with-param name="canvas.accessToken" value="{$ctx:canvas.accessToken}" /> <with-param name="canvas.accountId" value="{$ctx:canvas.accountId}" /> <with-param name="canvas.courseId" value="{$ctx:canvas.courseId}" /> <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's 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 responseHandler 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-addSubscribersToMailChimpAndAddingUsersToCanvas", "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>
{ "eventbriteApiUrl" : "https://www.eventbriteapi.com", "eventbriteAccessToken" : "O5CHYSIJQPS7QNQKBYU6", "eventbriteEventId" : "14747958541", "mailChimpApiUrl" : "https://us9.api.mailchimp.com", "mailChimpApiKey" : "33b1f0d89fe028aa2039029d0164344a-us9", "mailChimpUpdateExisting" : "false", "mailChimpListId" : "cac586e1b4", "canvasApiUrl" : "https://orion-city.acme.instructure.com", "canvasAccessToken" : "51451~fwK08jirhrTKFiuyua8H3rpFVQtZJu7D7rf3mi7pecuHxMglbY24XOxQ42UWTvam", "canvasAccountId" : "1", "canvasCourseId" : "122" }
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="canvas_createAndShareGoogleCalendarWithCourseUsers" transports="https,http" 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.courseId" expression="json-eval($.canvasCourseId)" /> <!--GoogleCalendar Properties--> <property name="googlecalendar.apiUrl" expression="json-eval($.googlecalendarApiUrl)" /> <property name="googlecalendar.accessToken" expression="json-eval($.googlecalendarAccessToken)" /> <property name="googlecalendar.calendarId" expression="json-eval($.googlecalendarCalendarId)" /> <property name="googlecalendar.summary" expression="json-eval($.googlecalendarSummary)" /> <property name="googlecalendar.description" expression="json-eval($.googlecalendarDescription)" /> <property name="googlecalendar.location" expression="json-eval($.googlecalendarLocation)" /> <property name="googlecalendar.timeZone" expression="json-eval($.googlecalendarTimeZone)" /> <property name="responseString" value="" scope="operation" /> <!--Only if the user HAS NOT provided the calendarID, create one and use its calendarID. --> <filter source="boolean(get-property('googlecalendar.calendarId'))" regex="false"> <then> <googlecalendar.init> <apiUrl>{$ctx:googlecalendar.apiUrl}</apiUrl> <accessToken>{$ctx:googlecalendar.accessToken}</accessToken> </googlecalendar.init> <googlecalendar.createCalendar> <summary>{$ctx:googlecalendar.summary}</summary> <description>{$ctx:googlecalendar.description}</description> <location>{$ctx:googlecalendar.location}</location> <timeZone>{$ctx:googlecalendar.timeZone}</timeZone> </googlecalendar.createCalendar> <sequence key="removeResponseHeaders" /> <!--Extract the ID from the response and set it here.--> <property name="googlecalendar.calendarId" expression="json-eval($.id)" /> <!--On success, display the custom message with calendar details. --> <filter source="boolean(get-property('googlecalendar.calendarId'))" regex="false"> <then> <property name="apiErrorResponse" expression="json-eval($.error.errors[0].message)" /> <property name="message" expression="fn:concat('Failed to create the calendar: ', get-property('apiErrorResponse'))" /> <property name="id" value="{}" /> <!--Call the responseHandler template.--> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:id}" /> <with-param name="activity" value="googlecalendar_createCalendarForCanvas" /> <with-param name="status" value="Error" /> <with-param name="message" value="{$ctx:message}" /> </call-template> <loopback /> </then> <else> <property name="googlecalendar.calendarId" expression="json-eval($.id)" /> <property name="id" expression="fn:concat('Calendar ID:', get-property('googlecalendar.calendarId'))" /> <property name="message" value="Calendar is created successfully." /> <!--Call the responseHandler template.--> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:id}" /> <with-param name="activity" value="googlecalendar_createCalendarForCanvas" /> <with-param name="status" value="Success" /> <with-param name="message" value="{$ctx:message}" /> </call-template> </else> </filter> </then> </filter> <filter source="boolean(get-property('googlecalendar.calendarId'))" regex="true"> <then> <!--Retrieve all the users who are enrolled with the given course. --> <canvas.init> <apiUrl>{$ctx:canvas.apiUrl}</apiUrl> <accessToken>{$ctx:canvas.accessToken}</accessToken> </canvas.init> <canvas.listCourseUsers> <courseId>{$ctx:canvas.courseId}</courseId> <include>email,enrollments</include> </canvas.listCourseUsers> <sequence key="removeResponseHeaders" /> <property name="noOfUsers" expression="count(//jsonArray/jsonElement)" scope="operation" /> <property name="userIndex" expression="0" scope="operation" /> <!-- If there are no users registered to the course, display a custom error message.--> <filter xpath="get-property('operation', 'noOfUsers') = get-property('operation', 'userIndex')"> <then> <property name="messageType" value="application/json" scope="axis2" /> <property name="message" value="No registered users can be found for the given course." /> <call-template target="responseHandlerTemplate"> <with-param name="activity" value="canvas_shareGoogleCalendarWithCanvesUsers" /> <with-param name="id" value="{$ctx:canvas.courseId}" /> <with-param name="status" value="Skipped" /> <with-param name="message" value="{$ctx:message}" /> </call-template> <loopback /> </then> <else> <!--FOR EACH User: BEGIN--> <iterate continueParent="false" id="users" expression="//jsonArray/jsonElement" sequential="true"> <target> <sequence> <!--Store the user details--> <property name="userId" expression="//jsonElement/id/text()" /> <property name="userEmail" expression="//jsonElement/email/text()" /> <property name="userName" expression="//jsonElement/name/text()" /> <property name="userRole" expression="//jsonElement/enrollments[1]/role/text()" /> <property name="messageType" value="application/json" scope="axis2" /> <property name="roleScope" expression="fn:concat('{ "type": "user", "value": "',get-property('userEmail'),'" }')" /> <!--If the user's emailId is not set, provide the custom error message since the googleCalendar cannot be shared with such users.--> <filter source="boolean(get-property('userEmail'))" regex="false"> <then> <property name="messageType" value="application/json" scope="axis2" /> <property name="message" value="Failed to share the calendar since the user's email ID does not exist." /> <call-template target="responseHandlerTemplate"> <with-param name="activity" value="canvas_shareGoogleCalendarWithCanvesUsers" /> <with-param name="id" value="{$ctx:userId}" /> <with-param name="status" value="Error" /> <with-param name="message" value="{$ctx:message}" /> </call-template> </then> <else> <filter source="get-property('userRole')" regex="TeacherEnrollment"> <then> <!-- If the user is a teacher, provide the 'owner' role of the calendar.--> <property name="userRole" value="owner" /> </then> <else> <!-- If the user is not a teacher, provide the 'reader' role of the calendar.--> <property name="userRole" value="reader" /> </else> </filter> <!-- Share the Google calendar with the users. --> <googlecalendar.init> <apiUrl>{$ctx:googlecalendar.apiUrl}</apiUrl> <accessToken>{$ctx:googlecalendar.accessToken}</accessToken> </googlecalendar.init> <googlecalendar.createAcl> <calendarId>{$ctx:googlecalendar.calendarId}</calendarId> <role>{$ctx:userRole}</role> <scope>{$ctx:roleScope}</scope> </googlecalendar.createAcl> <property name="responseId" expression="json-eval($.id)" /> <!--On success, display the custom message with the user details. --> <filter source="boolean(get-property('responseId'))" regex="true"> <then> <property name="id" expression="fn:concat('canves_userId:', get-property('userId'))" /> <property name="status" value="Success" /> <property name="message" value="Calendar has been successfully shared" /> </then> <else> <property name="apiErrorResponse" expression="json-eval($.error.errors[0].message)" /> <property name="id" expression="fn:concat('canves_userId:', get-property('userId'))" /> <property name="status" value="Error" /> <property name="message" expression="fn:concat('Failed to share the calendar: ', get-property('apiErrorResponse'))" /> </else> </filter> <!--Call the responseHandler template--> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:id}" /> <with-param name="activity" value="canvas_shareGoogleCalendarWithCanvesUsers" /> <with-param name="status" value="{$ctx:status}" /> <with-param name="message" value="{$ctx:message}" /> </call-template> <property name="statusCode" expression="$axis2:HTTP_SC" /> <!--If the calendar is missing or if an authorization error occurs at the Google Calendar API, do not proceed but loopback. --> <filter source="get-property('statusCode')" regex="40[1,4]"> <then> <loopback /> </then> </filter> </else> </filter> <!--Increment the user count.--> <property name="userIndex" expression="get-property('operation', 'userIndex') + 1" scope="operation" /> </sequence> </target> </iterate> </else> </filter> <!--FOR EACH User: END--> <filter xpath="get-property('operation', 'noOfUsers') = get-property('operation', 'userIndex')"> <then> <loopback /> </then> </filter> </then> </filter> </inSequence> <outSequence> <property name="messageType" value="application/json" scope="axis2" /> <payloadFactory media-type="json"> <format>{ "Response":{ "process":"canvas_createAndShareGoogleCalendarWithCourseUsers", "activityResponse": [$1] } }</format> <args> <arg expression="get-property('operation', 'responseString')" /> </args> </payloadFactory> <send /> </outSequence> </target> <description /> </proxy>
{ "canvasApiUrl":"https://canvas.instructure.com", "canvasAccessToken":"7~5pA2tUv3iq22u5BqMI8T3FyId333J2atYt4e1KMNAptdFsfBqCEVrREg0I0hPTcv", "canvasCourseId":"902480", "googlecalendarApiUrl":"https://www.googleapis.com", "googlecalendarAccessToken":"ya29.zABfAfjrz5t38djHzFa4jG-7HQqDSnZbGQPGu1Zo1IXKuAhvsYOumBMmk9U1-sjg06wbNwJojQhRYA", "googlecalendarCalendarId":"boi0hvadfvqtbabqtk35c9cjck@group.calendar.google.com", "googlecalendarSummary":"CanvesTestCalendar", "googlecalendarDescription":"test calendar for canves", "googlecalendarLocation":"Colombo-Western Provice", "googlecalendarTimeZone":"GMT" }