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.
- An App Connect subscription (Free or Personal).
- The username and password for your Gmail account.
- The username and password for your IBM Watson Tone Analyzer service. More info here â€“ How to use IBM App Connect with Watson Tone Analyzer
- 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:
- Select the Templates tab.
- On the Templates tab, click the tile “Email tone detector”.
- 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.)
- Log in to App Connect.
- From the Dashboard, click New > Event-driven flow.
- Enter a name that identifies the purpose of your flow, for example:
Email tone detector.
- Select Gmail as your first application (source).
- Select New message as the Gmail event that will trigger the flow.
- 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.
- Click the (+) icon and then select IBM Watson Tone Analyzer > Get tone analysis.
- 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.
- 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.
- Leave the other fields with the default values.
- 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.
- Click (+) > Toolbox.
- Select the Notification node.
- In the Title field, remove the default text and click the Insert a reference icon .
- Select IBM Watson Tone Analyzer / Get tone analysis / Tone / Dominant tones / Emotion Tone / Tone name.
- After the IBM Watson Tone Analyzer node, click (+) > Toolbox > Situation detector.
- Leave the Display name field with the default text.
- 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:
- Change the Trigger after the first field to 2.
- In the text field click the Insert a reference icon , and select Gmail / New message / mail / From.
&. (Notice the spaces before and after the ampersand).
- Click the Insert a reference icon , and select IBM Watson Tone Analyzer / Get tone analysis / Tone / Dominant tones / Emotion Tone / Tone name.
- Update the within a period of fields, to 10 minutes.
- So it should read:
Trigger after the first 2 instances of the same From & Tone name within a period of 10 minutes.
- Close the Situation detector node.
- 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.
- 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.
- In the Where do you want to post the message?: field, select the channel that you want to use from the list provided.
- Next, we need to decide what the message should say. To do this, complete the following steps:
- In the Text field type
Sender:. (Note the space used after the colon).
- Click the Insert a reference icon , and select Situation detector Trigger/ Array/ mail/ From.
Tone:. (Again, notice the spaces used before and after the word “Tone”).
- Click the Insert a reference icon , and select Situation detector Trigger/ Array/ Tone/
Dominant tones/ Emotion Tone/ Tone name.
- 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.
- In the Text field type
- You should have a flow that looks like the following:
- From the banner, open the options menu [⋮] and click Start flow. Then click Dashboard to exit the flow.
Finally, test your flow
- 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.
- In the App Connect UI, check the Notification tab to ensure that the IBM Watson Tone Analyzer has detected the correct tone.
- You will receive a message in Slack notifying you of the sender and tone.
- Return to the App Connect Dashboard and stop the flow.