Learn how easy it is to create an event-driven flow in App Connect Designer to classify the text from a Salesforce case. Then, after the text has been classified, automatically create a message in Slack identifying the type of case that has been raised and the case number.

Note: This tutorial assumes that you have signed up for free or trial accounts for Salesforce, Bluemix (for Watson Natural Language Classifier), and Slack, or that you have business accounts.

Scenario:

A travel company is using Salesforce for their CRM. A new case is created when customers phone, email, or send a question via the web. The travel company has a large international team with colleagues in different geographies and in different time zones. It’s a challenge to ensure that everyone knows what’s going on and is on top of all the customer queries coming in. For this reason, when a new case is created in Salesforce, they want App Connect Designer to automatically classify the case subject header. By classifying the case subject header they can work out whether the query is a complaint, inquiry or whether the customer is satisfied and just wants to show their appreciation. When the subject has been classified, a notification is raised in Slack with the case number and classification type so that the customer query can be dealt with efficiently by the correct team.

Screenshot of the "Classifying Salesforce cases and posting a message in Slack" flow tile
“Classifying Salesforce cases and posting a message in Slack” flow tile

Time required:
If you have already connected Salesforce, Watson Natural Language Classifier, and Slack to App Connect, the steps to create and test the integration flow in this tutorial should take only a few minutes.

If you have never used Watson Natural Language Classifier before, then the steps to create and test the integration flow in this tutorial will take approximately 25 minutes.

First, find or create everything you need:

  1. An App Connect subscription (Free or Personal).
  2. The name and password of your Salesforce account.

    Note: If you want to create a free test account in Salesforce rather than use your business account, make sure that you register for a Developer account from this URL: https://developer.salesforce.com rather than a Trial account. If you connect to App Connect with a Trial account, the Salesforce events do not work.

  3. Your team’s Slack URL.
  4. To classify text, you need to train the Watson Natural Language Classifier with sample text and classifications. We have provided some sample data for you to use.
    • Download the travel.zip, extract the travel.csv file, and save it to your preferred location.

    The sample contains two columns. The first column contains the text input with sample subject header text. The second column is the class for the text. There are three classes: Complaint, Inquiry, Satisfied.

  5. Depending on your experience with using the Natural Language Classifier, select one of the following options.

I’ve used Watson Natural Language Classifier before.

  1. Find the username and password associated with your Watson Natural Language Classifier account.
     

    If you’re not sure how to find these credentials, see How to use IBM App Connect with Watson Natural Language Classifier.

  2. Upload the travel.csv file that you saved earlier to the Natural Language Classifier. Forgotten how to upload a csv file to the Natural Language Classifier? Expand the following section and follow the steps in Create and train a classifier.

I’m completely new to Watson Natural Language Classifier.

  1. Go to the Bluemix Natural Language Classifier service and either sign up for a free Bluemix account or log in.
  2. After you log in, click Create. You have now provisioned the service and the service is displayed.
  3. Copy your credentials:
    1. On the service dashboard, in the Credentials section (by default you’re in the Manage tab) click Show Credentials.
    2. Copy the Username and Password values. These are required for creating a classifier as described below and connecting App Connect to Watson Natural Language Classifier when you create your flow.
  4. Create and train a classifier

  5. Open a cURL command line tool, for example cygwin.
  6. Issue the following command to upload the training data and create the classifier:
    • Replace {username} and {password} with the service credentials you copied earlier.
    • Replace {path_to_file} to point to the location where you saved the travel.csv file.
    • Notice the name of the classifier – TravelClassifier

    curl -i --user "{username}":"{password}" -F training_data=@{path_to_file}/travel.csv -F training_metadata="{\"language\":\"en\",\"name\":\"TravelClassifier\"}" "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers"

  7. The response includes a new classifier ID and status. For example:
    Cygwin command line tool displaying the results of the create classifier command
    Example of the classifier ID
  8. Training begins immediately and must finish before you can begin the tutorial.
  9. Check the training status periodically until you see a status of Available. With this sample data, training takes about 6 minutes.
  10. Issue the following command to retrieve the status of the classifier. In the following example, replace {username}, {password}, and {classifier_id} with your information:

    curl --user "{username}":"{password}" "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/{classifier_id}"

  11. When a status of Available has been achieved. You will be ready to begin the tutorial.
    Cygwin command line tool displaying the Available status
    The classifier status is available and ready to use

Next, create your flow:

Using IBM App Connect Designer, you can create your flow from the template “Classifying Salesforce cases and posting a message in Slack”, or by creating your flow from scratch.

Creating the flow from the template

This enables you to create the flow immediately, and then select each node in the flow to validate the node and select the application accounts that you want to use.

In App Connect Designer, complete the following steps:

  1. Select the Templates tab.
  2. On the Templates tab, click the tile “Classifying Salesforce cases and posting a message in Slack”.
  3. Click “Create flow”.

Creating the flow from scratch

This helps you to learn the sequence of steps used to create the flow, and to examine the nodes and fields as you go.

  1. Log in to App Connect Designer.
  2. From the Dashboard, click New > Event-driven flow.

    Hint: As you progress, App Connect automatically saves your changes. If you navigate away from the flow at any stage, the flow is saved as a draft flow that you can complete at another time.

  3. Enter a name that identifies the purpose of your flow, for example: Classifying Salesforce cases and posting a message in Slack
  4. Select Salesforce as your first application (source).
  5. Select Cases > New case as the Salesforce event that will trigger the action in Slack.
    Screenshot to show the Salesforce New case object
    Selecting the Salesforce New case object
  6. If you haven’t already connected a Salesforce account, click Connect to Salesforce and follow the instructions to allow App Connect to connect to your Salesforce account.
  7. Select IBM Watson Natural Language Classifier as your second application.
  8. Select Classify text.
  9. If you haven’t already connected a Watson Natural Language Classifier account, click Connect to Watson Natural Language Classifier and follow the instructions to allow App Connect to connect to your Watson Natural Language Classifier account.
  10. In the *Classifier: field, select the TravelClassifier that you created earlier.
  11. To choose the data that you want the Watson Natural Language Classifier to classify, click the Insert a reference icon , then select the Salesforce Subject object from the displayed list of objects.
    Screenshot to show the Salesforce Subject object
    Selecting the Salesforce Subject object
  12. Click the (+) and then select Slack as your third application (target).
  13. Select Message > Create Message as the Slack action.
  14. If you haven’t already connected a Slack account, click Connect to Slack and follow the instructions to allow App Connect to connect to your Slack account.
  15. Select the channel that you want to post the message to. For the purpose of this tutorial I have chosen General so that everybody can see the message. You can also choose to select a user or multiple users if you have them set up.
  16. Next, we need to decide what the message should read. To do this, complete the following steps:
    1. In the Text field, type Case:
      Tip: Note the space inserted after the colon.
    2. Click the Insert a reference icon .
    3. Click the arrow for Salesforce / New Case and select Case Number.
    4. Type received. Type:
      Tip: Note the spaces used in the Text field.
    5. Click the Insert a reference icon .
    6. Click the arrow for Watson Natural Language Classifier / Classify text and select Top class.
      Note: The Top class is the classification with the highest confidence score.
    7. Let’s highlight the top class so that users can quickly see what it is. To do this, click the Top class reference object and select Apply a function > $uppercase().
    8. Add a period to the end of the text. The Text field should look like the following example:
      Screenshot to show the text input for the Slack text field
      Slack text field example
  17. From the banner, open the options menu [⋮] and click Start flow. Then click Dashboard to exit the flow.

Finally, test your flow:

  1. Log in to Salesforce with the account that you configured in App Connect, then create a new case.
  2. In the Subject field type Lost Baggage.
  3. Fill in the rest of the form including all the mandatory fields, then save the case.
  4. You will receive a message instantly in Slack notifying you about the new case.

  5. Test it further by raising more cases. Try using your own questions or comments to see if Watson has classified it correctly.

Join The Discussion

Your email address will not be published. Required fields are marked *