Trigger SMS Using the Twilio Connector

So far, you’ve gathered the opportunity, product, and order information. Your next step is to send an SMS with the details to notify the customer. For testing purposes, use your own phone number to send the SMS. To do this, format the message and pass it on to the Twilio connector in the format it prefers. 

  1. Open the Transform card to the left of the Twilio connector.
  2. In the left side (Input section), click the card options  next to payload, and set the Data Type to Order Tracking.
  3. Set the data type for OppDetails to Salesforce Opportunity.
  4. On the right side (Output payload section), double-click the To field and add your phone number with the country prefix (for example, a US phone number would look like 16667778888)
  5. Double-click the From field and use the phone number you obtained when you signed up for Twilio.
  6. Drag the OrderID field from Input to the Body field in the Output payload section.
    The transform card is expanded. The OrderID field from the input fields on the left side is connected to the Body field in the output field that is on the right side
  7. In the bottom bar, switch to the Script mode to see the Transformation script. MuleSoft uses a powerful data transformation language called DataWeave. The script tab contains autogenerated DataWeave code. Replace the Body: payload.OrderID with this code:
Body: "Order for " ++ vars.OppDetails.Name ++ " has been placed.
" ++ "OrderID: " ++ payload.OrderID as String ++ ", Tracking: "
++ payload.TrackingNo ++ ", ETA:" ++ payload.ETA as Date

In the preview, notice a message is constructed with dynamic variables, and also converting the ETA from a timestamp (2019-01-25T00:00:00.000Z) to date (2019-01-25). With DataWeave, you transform your data between formats like XML, JSON, CSV, and so on, and perform lookups and functions within your data. 

Now you’re all set to send SMS notifications when orders are placed. NTO customers do not have to call the sales rep to check on their orders. However, if someone does call, you want to make sure that the sales rep has the OrderID. In the next section, you use the Salesforce connector to update the opportunity record with the OrderID.

We won’t check any of your setup. Click Verify Step to go to the next step in the project.


Keep learning for
Sign up for an account to continue.
What’s in it for you?
  • Get personalized recommendations for your career goals
  • Practice your skills with hands-on challenges and quizzes
  • Track and share your progress with employers
  • Connect to mentorship and career opportunities