When you haven’t got the time to keep checking whether certain events have happened or when you only want to be notified when something has taken place more than once, you can use the “Situation detector” node in an App Connect flow. You may want to be alerted when you receive more than three emails from the same customer who is annoyed and complaining about customer service. You may want to be alerted when the number of attendees to your Eventbrite event reaches a certain number and those attendees are from the same location so that you can offer and provide transport.

The situation detector node allows you to relax after you set up a flow because it will collect this data for you. Use it with the Notification node to be notified when the data you requested has been collected and you can remain confident that you won’t miss out.

In the following example we’re going to use the Situation detector node to detect when two emails from the same email address with the same sentiment (be that negative or positive) are received within 10 minutes. This can be useful to respond quickly to irate customers or reward satisfied customers. In this tutorial we’re using two emails within 10 minutes so that we can see the results quickly when we test the flow. In a real world situation however, you may want to increase the time span to a few hours or days.

First, find or create everything you need:

Note: This tutorial assumes that you have signed up for free or trial accounts for Gmail, IBM Cloud (for IBM Watson Tone Analyzer), and Slack, or that you have business accounts.

  1. An App Connect subscription (Free or Personal).
  2. The username and password for your Gmail account.
  3. The username and password for your IBM Watson Tone Analyzer service. More info here – How to use IBM App Connect with Watson Tone Analyzer
  4. Your team’s Slack URL.

Next, create your flow:

Using IBM App Connect Designer, you can create your flow from the template “Email tone detector”, 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 “Email tone detector”.
  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.

(App Connect automatically saves your changes as you go. If you move away from the flow at any point, the flow is saved as a draft flow that you can come back to later.)

  1. Log in to App Connect.
  2. From the Dashboard, click New > Event-driven flow.
  3. Enter a name that identifies the purpose of your flow, for example: Email tone detector.
  4. Select Gmail as your first application (source).
  5. Select New message as the Gmail event that will trigger the flow.
  6. If you haven’t already connected a Gmail account, click Connect to Gmail and follow the instructions to allow App Connect to connect to your Gmail account.
  7. Click the (+) icon and then select IBM Watson Tone Analyzer > Get tone analysis.
  8. If you haven’t already connected an IBM Watson Tone Analyzer account, click Connect to IBM Watson Tone Analyzer and follow the instructions to allow App Connect to connect to your IBM Watson Tone Analyzer account.
  9. We want Watson to analyze the text in the body of the email. To do this, click inside the *Text field, click the Insert a reference icon , and select Gmail / New message / Body.
  10. Leave the other fields with the default values.
  11. After the IBM Watson Tone Analyzer node we’re going to add a Notification node to verify the evaluated tone. This way we’ll receive a notification for each processed mail along with the detected tone.
    1. Click (+) > Toolbox.
    2. Select the Notification node.
    3. In the Title field, remove the default text and click the Insert a reference icon .
    4. Select IBM Watson Tone Analyzer / Get tone analysis / Tone / Dominant tones / Emotion Tone / Tone name.
  12. After the IBM Watson Tone Analyzer node, click (+) > Toolbox > Situation detector.
  13. Leave the Display name field with the default text.
  14. Next, we need to specify the conditions to collect. We want to know when two emails from the same sender with the same emotional sentiment are sent within the space of 10 minutes. To do this, update the Situation condition section as follows:
    1. Change the Trigger after the first field to 2.
    2. In the text field click the Insert a reference icon , and select Gmail / New message / mail / From.
    3. Type & . (Notice the spaces before and after the ampersand).
    4. Click the Insert a reference icon , and select IBM Watson Tone Analyzer / Get tone analysis / Tone / Dominant tones / Emotion Tone / Tone name.
    5. Update the within a period of fields, to 10 minutes.
    6. So it should read:

      Trigger after the first 2 instances of the same From & Tone name within a period of 10 minutes.

    7. Close the Situation detector node.
  15. Once this data has been collected, we want to receive a message in Slack that tells us who the sender is and the emotional tone of the email. So, after the Situation detector node click (+) > Slack > Create message.
  16. If you haven’t already connected a Slack account, click Connect and follow the instructions to allow App Connect to connect to your Slack account.
  17. In the Where do you want to post the message?: field, select the channel that you want to use from the list provided.
  18. Next, we need to decide what the message should say. To do this, complete the following steps:
    1. In the Text field type Sender: . (Note the space used after the colon).
    2. Click the Insert a reference icon , and select Situation detector Trigger/ Array/ mail/ From.
    3. Type Tone: . (Again, notice the spaces used before and after the word “Tone”).
    4. Click the Insert a reference icon , and select Situation detector Trigger/ Array/ Tone/
      Dominant tones/ Emotion Tone/ Tone name
      .
    5. Notice that both of these selections contain an array that will be converted to a string. As we do not want to receive a string in our response click How can I resolve this? and select the first option to select the first instance of ‘From’ and ‘Tone name’ in the array then click Done.
  19. You should have a flow that looks like the following:
  20. From the banner, open the options menu [⋮] and click Start flow. Then click Dashboard to exit the flow.

Finally, test your flow

  1. Play the role of a happy customer and send two emails to the Gmail account you specified in the flow. Emails must be sent from the same account. You could use the following as an example:

    Dear Sir/ Madam

    I’m extremely pleased with the service I received from your support team today and I look forward to using your services again.

  2. In the App Connect UI, check the Notification tab to ensure that the IBM Watson Tone Analyzer has detected the correct tone.
  3. You will receive a message in Slack notifying you of the sender and tone.
  4. Return to the App Connect Dashboard and stop the flow.

Join The Discussion

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