How Connecting first SaaS applications?  

 

0

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

  1. 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.
  2. GET A SLACK API TOKEN 
  3. SIGN UP FOR A SALESFORCE DEVELOPER ACCOUNT. TAKE A NOTE OF YOUR CREDENTIALS, WE WILL NEED THAT LATER.
  4. 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:

 

  1. RETRIEVE ALL LEADS FROM SALESFORCE.
  2. THESE LEADS WERE AUTO-GENERATED WHEN YOU SIGNED UP FOR THE DEVELOPER ACCOUNT.
  3. CALL THE PRODUCT API TO GET INFORMATION ABOUT A SPECIFIC PRODUCT.
  4. AGGREGATE LEADS AND PRODUCTS DATA, TO HELP MEMBERS OF THE SALES TEAM HAVE MORE CONTEXT WHEN ENGAGING PROSPECTS.
  5. CONVERT THE DATA TO A CSV FILE.
  6. 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:

 

  1. SELECT THE CREATE BUTTON?---> MULE APPLICATION.
  2. FILL OUT THE NAME FOR YOUR APPLICATION (E.G. "WEEKLY-PRODUCT-LEADS").
  3. 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:

 

  1. CLICK THE TRIGGER BUTTON TO ADD A NEW TRIGGER.
  2. SELECT SCHEDULER FROM THE MODAL THAT POPS UP.
  3. CONFIGURE YOUR SCHEDULER WITH THE FOLLOWING VALUES TO HAVE THE FLOW RUN IMMEDIATELY ONCE THE APP STARTS, AND CONTINUOUSLY RUN EVERY 5 MINUTES:
  4. SCHEDULING STRATEGY: FIXED FREQUENCY
  5. TIME UNIT: MINUTES
  6. FREQUENCY: 5
  7. START DELAY: 0
  8. 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:

 

  1. CLICK THE + TO ADD A NEW COMPONENT IN THE FLOW.
  2. SCROLL AND SELECT THE SALESFORCE CONNECTOR.
  3. SELECT THE QUERY OPERATION.
  4. THIS WILL PRESENT YOU WITH THE OPERATION CONFIGURATION WINDOW. CLICK THE SETUP LINK TO CONFIGURE THE CONNECTOR ITSELF FIRST.
  5. 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

 

  1. 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:

 

  1. IN THE CANVAS, CLICK THE + BUTTON.
  2. SELECT TRANSFORM.
  3. CLICK THE DOWN ARROW NEXT TO WHERE IT SAYS OUTPUT PAYLOAD, CLICK THE PENCIL ICON TO EDIT THE TRANSFORMATION TYPE.
  4. SELECT "VARS" FROM THE TYPE DROPDOWN AND FILL OUT THE FIELD:
  5. NAME: PRODUCT LEAD
  6. CLICK SAVE.
  7. 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:

 

  1. ITERATE THROUGH THE LIST ONE AT A TIME AND LOOK AT EACH LEAD.
  2. 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”.
  3. MERGE THE PRODUCT INFORMATION AND LEAD INFORMATION INTO ONE ELEMENT.
  4. GO BACK TO THE FIRST STEP AND REPEAT UNTIL ALL LEADS ARE ITERATED THROUGH.
  5. 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:

 

  1. CLICK THE ADVANCED TAB.
  2. 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.

 

  1. CLICK THE + BUTTON ON THE RIGHT (OUTSIDE OF THE FOREACH LOOP).
  2. SELECT THE SLACK CONNECTOR.
  3. SELECT THE OPERATION FILE - UPLOAD.
  4. 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.

 

  1. CLICK SCHEDULER CONNECTOR TO OPEN THE CONFIGURATION SETTINGS.
  2. FIND A "CRON EXPRESSION BUILDER" USING YOUR FAVORITE SEARCH ENGINE AND PASTE THAT INTO THE EXPRESSION FIELD.
  3. 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

 

Share:
Summary
Review Date
Reviewed Item
Forum
Author Rating
51star1star1star1star1star
  
Working

Please Login or Register