IN THIS GUIDE, YOU’LL BE LEVERAGING THE WORK CREATED FROM GUIDES 1, 2, AND 3 OF THE QUICK START SERIES TO LEARN HOW TO USE ANYPOINT DESIGN CENTER’S FLOW DESIGNER TO:
- CREATE A SERVICE THAT RUNS ON A SCHEDULE.
- GATHER AND COMBINE DATA FROM TWO DATA SOURCES.
- PUSH ENRICHED DATA INTO ANOTHER SYSTEM TO BRING IT TO RELEVANT STAKEHOLDERS.
click Mulesoft training for experts in indestry
WHY INTEGRATE APIS WITH ANYPOINT DESIGN CENTER
FLOW DESIGNER IN ANY POINT DESIGN CENTER IS OPTIMIZED FOR IMPLEMENTING COMMON INTEGRATIONS IN A WEB-BASED, GRAPHICAL INTERFACE. SOME OF THE BENEFITS OF FLOW DESIGNER INCLUDE THE ABILITY TO:
- QUICKLY LEVERAGE CONNECTORS AUTO-GENERATED FROM AN API SPECIFICATION VIA REST CONNECT.
- EASILY CLICK AND ADD CONNECTORS TO SEND/RECEIVE DATA TO/FROM SYSTEMS.
- VISUALLY MAP DATA USING DATA SENSE.
- FAST AND EASY APPLICATION DEPLOYMENT TO CLOUD.
GET SET UP
- SIGN UP FOR A FREE 30-DAY ANYPOINT PLATFORM ACCOUNT IF YOU HAVEN’T DONE SO YET. YOU'LL NEED AN ACCOUNT TO ACCESS EXISTING ASSETS IN ANY POINT EXCHANGE AND CREATE MULE APPS IN FLOW DESIGNER.
- GET A SLACK API TOKEN
- SIGN UP FOR A SALESFORCE DEVELOPER ACCOUNT. TAKE A NOTE OF YOUR CREDENTIALS, WE WILL NEED THAT LATER.
- RESET YOUR SECURITY TOKEN FOR SALESFORCE. YOU WILL GET AN EMAIL WITH YOUR TOKEN. YOU WILL ALSO NEED THIS IN A LATER STEP.
BRIDGING APIS WITH DESIGN CENTER
WITHIN DESIGN CENTER, YOU CAN BUILD A MULE APPLICATION TO INTEGRATE TWO APIS TOGETHER AND DRIVE REAL BUSINESS PROCESSES EASILY. THE SERVICE YOU'RE ABOUT TO CREATE WILL PERFORM THE FOLLOWING TASKS ON A SCHEDULED DATE/TIME:
- RETRIEVE ALL LEADS FROM SALESFORCE.
- THESE LEADS WERE AUTO-GENERATED WHEN YOU SIGNED UP FOR THE DEVELOPER ACCOUNT.
- CALL THE PRODUCT API TO GET INFORMATION ABOUT A SPECIFIC PRODUCT.
- AGGREGATE LEADS AND PRODUCTS DATA, TO HELP MEMBERS OF THE SALES TEAM HAVE MORE CONTEXT WHEN ENGAGING PROSPECTS.
- CONVERT THE DATA TO A CSV FILE.
- UPLOAD THE DATA TO A SPECIFIC SLACK CHANNEL AND/OR INDIVIDUALS.
CREATING A NEW MULE APP
TO START OFF, NAVIGATE TO ANY POINT DESIGN CENTER AND CREATE A NEW MULE APPLICATION PROJECT:
- SELECT THE CREATE BUTTON?---> MULE APPLICATION.
- FILL OUT THE NAME FOR YOUR APPLICATION (E.G. "WEEKLY-PRODUCT-LEADS").
- PRESS CREATE.
Add caption
click Mulesoft online training for experts in industry
ADDING A SCHEDULER TRIGGER
AFTER YOU CREATE THE PROJECT, YOU'LL BE TAKEN TO THE CANVAS OF YOUR NEW MULE APPLICATION'S FIRST FLOW. IN THIS CANVAS, YOU CAN ADD DIFFERENT COMPONENTS TO PERFORM A VARIETY OF PROCESSES TO HELP ACCOMPLISH YOUR TASKS.
SINCE THIS MULE APPLICATION WILL BE RUNNING ON A SCHEDULE, ADD THE SCHEDULER COMPONENT AS YOUR TRIGGER:
- CLICK THE TRIGGER BUTTON TO ADD A NEW TRIGGER.
- SELECT SCHEDULER FROM THE MODAL THAT POPS UP.
- CONFIGURE YOUR SCHEDULER WITH THE FOLLOWING VALUES TO HAVE THE FLOW RUN IMMEDIATELY ONCE THE APP STARTS, AND CONTINUOUSLY RUN EVERY 5 MINUTES:
- SCHEDULING STRATEGY: FIXED FREQUENCY
- TIME UNIT: MINUTES
- FREQUENCY: 5
- START DELAY: 0
- CLICK THE X ON THE TOP RIGHT OF THE MODAL TO CLOSE AND SAVE.
ADDING A SALESFORCE QUERY
IN ORDER TO RUN A SALESFORCE QUERY OF ALL NEW LEADS, YOU'RE GOING TO ADD THE SALESFORCE CONNECTOR ONTO THE CANVAS, SELECT THE CORRESPONDING OPERATION, AND CONFIGURE IT. IN THE CANVAS:
- CLICK THE + TO ADD A NEW COMPONENT IN THE FLOW.
- SCROLL AND SELECT THE SALESFORCE CONNECTOR.
- SELECT THE QUERY OPERATION.
- THIS WILL PRESENT YOU WITH THE OPERATION CONFIGURATION WINDOW. CLICK THE SETUP LINK TO CONFIGURE THE CONNECTOR ITSELF FIRST.
- ENTER/SELECT THE FOLLOWING CONNECTOR CONFIGURATION:
- CONNECTION TYPE: USERNAME PASSWORD
- USERNAME: (USE CREDENTIALS FROM STEP 3 OF THE GET SET UP SECTION)
- PASSWORD: (USE CREDENTIALS FROM STEP 3 OF THE GET SET UP SECTION)
- SECURITY TOKEN: (USE TOKEN FROM STEP 4 OF THE GET SET UP SECTION
- CLICK TEST TO ENSURE THE CONFIGURATION IS CORRECT AND WORKS, THEN SAVE.
NEXT, YOU'LL NEED TO CONFIGURE THE SALESFORCE QUERY OPERATION BY ENTERING THE SOQL QUERY, WHICH WILL RETURN SEVERAL FIELDS FROM LEADS:
click Mulesoft certification for experts in the industry
ENTER THE FOLLOWING FOR THE FIELDS:
SALESFORCE QUERY:
LANGUAGE: SQL
SELECT ID,FIRSTNAME,LASTNAME,COMPANY,EMAIL,PHONE FROM LEAD WHERE CREATEDDATE = THIS_MONTH
PRESS THE X ON THE TOP RIGHT OF THE MODAL TO CLOSE AND SAVE THE CHANGES
ASSIGN A VARIABLE
TO CREATE AND SET A VARIABLE, YOU NEED TO ADD THE TRANSFORM MODULE AND CREATE A VARIABLE THAT CONTAINS ALL THE DATA YOU WANT TO EXPORT TO SLACK:
- IN THE CANVAS, CLICK THE + BUTTON.
- SELECT TRANSFORM.
- CLICK THE DOWN ARROW NEXT TO WHERE IT SAYS OUTPUT PAYLOAD, CLICK THE PENCIL ICON TO EDIT THE TRANSFORMATION TYPE.
- SELECT "VARS" FROM THE TYPE DROPDOWN AND FILL OUT THE FIELD:
- NAME: PRODUCT LEAD
- CLICK SAVE.
- CLICK THE SCRIPT TAB ON THE BOTTOM OF THE MODAL TO SET THE TRANSFORMATION CODE USING THE DATAWEAVE CODE BELOW:
Language: java
// Specify the language as DataWeave 2.0
%dw 2.0
// Define the output data type.
output application/csv
// Denote the end of header section and beginning of body where transformation code is written
---
// Initialize the variable as an empty list (array)
[]
HALFWAY CHECKPOINT
THE OUTPUT OF THE SALESFORCE CONNECTOR IS AN ARRAY OF LEADS, AND EACH ELEMENT IN THAT LIST OF LEADS CONTAINS THE FIELD "PRODUCT_PURCHASED__C," WHICH ACTUALLY CONTAINS THE PRODUCT ID THAT YOU NEED TO USE. THIS SETUP RESULTS IN THE FOLLOWING LOGICAL FLOW:
- ITERATE THROUGH THE LIST ONE AT A TIME AND LOOK AT EACH LEAD.
- GRAB THE PRODUCT INFORMATION FOR EACH LEAD USING THE PRODUCT API. FOR THIS GUIDE, WE WILL USE A STATIC PRODUCT WITH ID = “1295527D-D3C7-11E7-9C84-06BF056D193E”.
- MERGE THE PRODUCT INFORMATION AND LEAD INFORMATION INTO ONE ELEMENT.
- GO BACK TO THE FIRST STEP AND REPEAT UNTIL ALL LEADS ARE ITERATED THROUGH.
- PUSH THE ARRAY TO SLACK AS A CSV FILE.
ITERATING THROUGH LEADS
TO ITERATE THROUGH THE ARRAY (LIST) OF LEADS, YOU NEED TO ADD THE FOREACH SCOPE. SINCE THE VARIABLE THAT CONTAINS THE ARRAY OF LEADS IS "PAYLOAD" AND WE WANT TO GO THROUGH JUST ONE LEAD AT TIME, WE NEED TO ADD AND CONFIGURE THE FOREACH:
- IN THE CANVAS, ADD A FOREACH COMPONENT.
- APPLY THE FOLLOWING CONFIGURATIONS:
- COLLECTION: PAYLOAD
- BATCH SIZE: 1
- ROOT MESSAGE VARIABLE NAME: ROOTMESSAGE
- COUNTER VARIABLE NAME: COUNTER
REUSING EXISTING ASSETS
SINCE THERE IS ALREADY A PRODUCT API WITH PRODUCT INFORMATION AVAILABLE IN ANY POINT EXCHANGE'S PUBLIC REPOSITORIES (OR YOURS IF YOU'VE DESIGNED, DEVELOPED, AND DEPLOYED YOUR OWN ALREADY), YOU CAN DISCOVER THE API AND CONSUME THE SERVICE WITH MINIMAL WORK AND ALMOST NO CODE. THE NEXT STEP IS TO GET THE PRODUCT INFORMATION FROM THIS SERVICE:
- ADD THE COMPONENT "DEVREL-QUICK START PRODUCT API" INSIDE THE FOREACH SCOPE.
- CLICK THE SETUP LINK TO CONFIGURE THE CONNECTOR SERVICE BEFORE CONFIGURING THE OPERATION.
- LEAVE ALL THE FIELDS WITH THE PRE-POPULATED CONFIGURATIONS EXCEPT:
- USERNAME: MULESOFT
- PASSWORD: MULESOFT
- SAVE THE CONNECTOR’S CONFIGURATION.
AFTER YOU CONFIGURE THE CONNECTOR, YOU CAN NOW CONFIGURE THE GET PRODUCT BY PRODUCT ID OPERATION. IN ORDER TO DO THAT, YOU'LL NEED TO PASS IN THE PRODUCT ID VALUE. THE CURRENT LEAD IS CURRENTLY DESCRIBED BY THE VARIABLE PAYLOAD.
1, PASS IN THE STATIC PRODUCT ID INTO THE URI PARAMS.
- PRODUCT ID: 1295527D-D3C7-11E7-9C84-06BF056D193E (THIS IS THE PRODUCT ID OF “LION MANE COSTUME” PRODUCT FROM OUR PRODUCTS DATABASE)
SINCE THE VARIABLE “PAYLOAD” CONTAINS THE LEAD DATA THAT YOU NEED TO USE LATER, LET'S STORE THE PRODUCT DATA FROM THE PRODUCT API IN A NEW VARIABLE TO AVOID OVERWRITING THE LEAD DATA:
- CLICK THE ADVANCED TAB.
- ENTER THE FOLLOWING:
- TARGET VARIABLE: PRODUCT
- TARGET VALUE: PAYLOAD
click Mulesoft training in Hyderabad for experts in the industry
AGGREGATING DATA
AT THIS POINT, YOU HAVE ALL THE DATA YOU NEED TO TRANSFORM THE DATA INTO"KEY: VALUE" PAIRS THAT CAN EASILY BE CONVERTED TO "COLUMN: ROW" CSV FORMAT.
1, ADD THE TRANSFORM CONNECTOR TO THE CANVAS INSIDE THE FOREACH SCOPE.
CHANGE THE OUTPUT FROM PAYLOAD TO PRODUCT LEAD BY CLICKING THE PENCIL ICON AT THE TOP OF THE TRANSFORM CONNECTOR.
- TYPE: VARS
- NAME: PRODUCT LEAD
2, SELECT SCRIPT TO MANUALLY ENTER THE DATAWEAVE TRANSFORMATION CODE FROM BELOW:
Language: java
%dw 2.0
output application/csv
---
// This sets a default value of an empty array to vars.productLeads just in case it's not set. It will then append the object we want to it.
(vars.productLeads default []) ++ [
{
// This is a 1:1 mapping of values from the payload (contains lead data) and product variables
firstName: payload.FirstName,
lastName: payload.LastName,
company: payload.Company,
email: payload.Email,
phone: payload.Phone,
productModel: vars.product.model,
productPrice: vars.product.price.amount.currencyValue,
productCurrency: vars.product.price.amount.currency,
productDescription: vars.product.description
}
]
UPLOADING TO SLACK
THE LAST STEP BEFORE TESTING THE INTEGRATION IS TO ADD THE SLACK CONNECTOR AND CONFIGURE IT.
- CLICK THE + BUTTON ON THE RIGHT (OUTSIDE OF THE FOREACH LOOP).
- SELECT THE SLACK CONNECTOR.
- SELECT THE OPERATION FILE - UPLOAD.
- CONFIGURE THE SLACK CONNECTOR FIRST BY CLICKING THE SETUP LINK.
- SELECT THE CONNECTION TYPE YOU WISH TO USE. WE RECOMMEND SELECTING 1 - TOKEN CONNECTION FOR THIS GUIDE.
- GET THE TOKEN FROM SLACK (LINK IS EXTERNAL).
- PASTE YOUR TOKEN.
- CLICK SAVE.
NEXT, YOU'LL CONFIGURE THE FILE - UPLOAD OPERATION BY FILLING OUT THE FIELDS AS BELOW:
- CONTENT: VARS.PRODUCT LEAD
- CHANNELS: [“YOUR USER/CHANNEL HERE”]
- E.G. ["ACCOUNT_DEVELOPMENT","@XYZUSER"]
- FILE NAME: "PRODUCT-LEAD.CSV"
- TITLE: THIS WEEK'S PRODUCT LEADS
- INITIAL COMMENT:
- FILE TYPE: TEXT/CSV
Trying the integration
WITHIN THE SLACK CHANNELS OR DIRECT MESSAGE TO USERS (DEPENDING ON WHAT YOU CHOOSE), YOU'LL SEE A NEW MESSAGE SHOW UP WITH THE CSV UPLOADED AS AN ATTACHMENT. THIS WILL RUN EVERY 5 MINUTES, AS BELOW:
click Mulesoft online certification for experts in the industry
SETTING SCHEDULER TO CRON
NOW THAT YOU KNOW THAT THE MULE APPLICATION WORKS, IT'S TIME TO WRAP UP THE APPLICATION BY HAVING IT RUN AS A CRON JOB EVERY MONDAY AT 8AM IN YOUR TIME ZONE.
- CLICK SCHEDULER CONNECTOR TO OPEN THE CONFIGURATION SETTINGS.
- FIND A "CRON EXPRESSION BUILDER" USING YOUR FAVORITE SEARCH ENGINE AND PASTE THAT INTO THE EXPRESSION FIELD.
- WRITE YOUR TIME ZONE IN JAVA TIME ZONE FORMAT.
DEPLOYING YOUR APP
GREAT! YOUR APP IS READY FOR DEPLOYMENT. TO DEPLOY THE APP, IT'S ONLY A MATTER OF A FEW CLICKS TO HAVE THE SERVICE UP AND RUNNING IN OUR CLOUDHUB SERVICE.
- AT THE TOP OF FLOW DESIGNER, CLICK THE BLUE DEPLOY BUTTON.
- SELECT THE ENVIRONMENT TO WHERE YOU WANT TO DEPLOY THE APPLICATION (E.G. "SANDBOX").
- ENTER THE APPLICATION NAME OR LEAVE DEFAULT.
- CLICK NEXT.
- CHANGE ENVIRONMENTAL CONNECTOR SETTINGS IF YOU CHOOSE TO, OR LEAVE AS IS.
- CLICK DEPLOY!
NEXT STEPS
AND THAT’S IT, CONGRATULATIONS! YOU'VE BUILT AN INTEGRATION THAT PERIODICALLY TAKES DATA FROM TWO API SOURCES, CONVERTS THE DATA TYPES, AGGREGATES THEM TOGETHER, AND THEN UPLOADS THE DATA TO THE GROUP THAT NEEDS IT, WHILE BARELY WRITING ANY CODE! you become a mulesoft professional you must do mule training
Nice article I was impressed by seeing this blog, it was very interesting and it is Thanks for sharing all the information with us all.very useful for me. Igained more knowledge from your blog. Keep Doing..
ReplyDeleteoracle training in chennai
oracle training institute in chennai
oracle training in bangalore
oracle training in hyderabad
oracle training
oracle online training
hadoop training in chennai
hadoop training in bangalore