Unconscious Bias Project: Using Data for Awareness of Your Tone in Emails

You know how when you become comfortable with someone, you sometimes may become a little more blunt?

Sometimes we may not notice if the tone of our emails is overly positive or negative. It's important to occasionally stop and reflect that we are treating the people around us with respect. The Unconscious Bias project is a Windows universal application allows you to use data to analyze the sentiment of your emails to a given email address.


On April 13-14, 2016, I participated in hack.nyc.  I worked with James Sturtevant to develop “Unconscious Bias”.  We created a Windows universal application in which the user can specify an email address.  Then, we use the Office 365 APIs to access the user’s email and get messages that were sent to that email address.  The emails are analyzed for positive/negative sentiment by the Microsoft Cognitive Services Text Analytics service.  Then we display the average sentiment score of your emails to that email address, along with a chart of your sentiment over time.

Regarding the tech, Office graph development still has a huge startup cost with getting authentication configured correctly.  After that, it is pretty straightforward, with both REST APIs or a client SDK.  I like that they provided a “UniqueBody” which gave us the email body without all of the earlier replies if it is a long thread.  The Microsoft Cognitive Services are amazing and very easy to use.  We may add key phrase extraction later as well.  Finally, in the Windows/XAML world, I love RelativePanel so much.  So much easier to design a UI!  You can specify that a certain control should be placed (for example) below another control, and then it behaves accordingly on different form factors at different resolutions.

Our work is available on GitHub at https://github.com/jsturtevant/UnconsciousBias.

Here’s a quick walkthrough of the app.  The initial screen prompts you for the email address of the person with which to analyze your interactions.

Unconscious Bias Screenshot

After entering an email address and clicking the “Get Insights” button, you are prompted to enter your credentials to sign into your email account.  We did not have to write this code; this user auth dialogue box is provided by the APIs.

Unconscious Bias Auth Dialog

Enter your own email address and password so that the application can access your email.  Then, the text of the emails to that person are analyzed and your results are displayed.  (I added the blur effect; you will be able to see the email address that you entered.)

Unconscious Bias Results With Blur

We still need to make some improvements to the chart.  Smile  But you can see the idea of providing both overall sentiment score and a graph of the sentiment over time.



At a high level, we knew that we needed the inputs of the username/password to sign into email and the person’s email address on which you want to test sentiment, and we wanted to output sentiment analysis.  Our logic all lives in the Universal Windows Platform app (that calls out to several services); we could have instead hosted our logic in an Azure service.

As a Universal Windows Platform app, it runs on my Windows Phone too!


Office Development

Here are a couple of quick thoughts in brain-dump format to help you get up and running with the Microsoft Graph:

App registration screenshot


Here is the snippet of code in which we get the emails to the given email address.

var emails = await graphClient.Me


We chose to use “UniqueBody” because it contains just your latest message to the email address.  If you and the selected email address have a long thread back and forth, it will strip out all of the replies and only include the new, unique part of the message.

You need to explicitly select “UniqueBody” because it is duplicate information.  Using a default get-messages call won’t return it by default because all of the message is also in the “body” content.  The documentation of the parts of the message is at https://graph.microsoft.io/en-us/docs/api-reference/beta/resources/message.


Resources: Office Development

Office Developer Center: http://dev.office.com/

Get Started: http://dev.office.com/getting-started

Samples: http://github.com/OfficeDev

Microsoft Graph: http://graph.microsoft.io

Graph Explorer: https://graph.microsoft.io/en-us/graph-explorer


Resources: Text Analytics from Microsoft Cognitive Services

Text Analytics Features: https://www.microsoft.com/cognitive-services/en-us/text-analytics-api

Getting started: https://azure.microsoft.com/en-us/documentation/articles/cognitive-services-text-analytics-quick-start/

Try it: https://text-analytics-demo.azurewebsites.net/

Sample code: https://text-analytics-demo.azurewebsites.net/Home/SampleCode


Privacy Policy

Let’s assume that you want to gain knowledge around any unconscious bias and positivity/negativity you are displaying towards your colleague Jason.

The Unconscious Bias application will prompt you (the user) for the permissions it needs to access your email, and proceed only after it has consent.  Once you have authenticated to your email account, it will access your email account to get the latest 10 email messages that you have sent to Jason (only the unique last messages that you sent to him in the email thread, stripping out older back-and-forth responses between you and Jason).  It will access the internet to send these messages to the Microsoft Cognitive Services for sentiment processing.

The image, voice, video or text understanding capabilities of the Unconscious Bias app uses Microsoft Cognitive Services. Microsoft will receive the images, audio, video, and other data that you upload (via this app) for service improvement purposes. To report abuse of the Microsoft Cognitive Services to Microsoft, please visit the Microsoft Cognitive Services website at https://www.microsoft.com/cognitive-services, and use the “Report Abuse” link at the bottom of the page to contact Microsoft. For more information about Microsoft privacy policies please see their privacy statement here: https://go.microsoft.com/fwlink/?LinkId=521839.

Comments (0)

Skip to main content