Automatically Tag Conversations in Front using Machine Learning

Automatically Tag Conversations in Front using Machine Learning

In this blog post, I’d like to show you how you can automate business workflows (either for support, sales or operations) that involve customer conversations by combining three tools: Front, MonkeyLearn, and Zapier.

Front will help us gather and manage conversations with customers from various different channels. MonkeyLearn will apply machine learning: automatically tagging conversations based on the content. Zapier will be the glue that sticks everything together.

Let’s do it!

About Front

Front is a beautiful application that allows your team to manage a shared inbox. Front is redesigning email for business, where collaboration is key.

Some of Front’s top features:

Centralize your communication channels into one place (e.g., email, texts, social and more).

Collaborate with your team behind-the-scenes (i.e., assign, comment on messages).

Handle messages faster with powerful automations (e.g., set up rules to automatically assign, remind and respond to messages based on tags and keywords).

Generate performance analytics and integrate with the rest of your business apps.

Front’s set of features is a nice fit for multiple use cases; support, sales, and operations being the most frequent.

Why are Tags and Rules so important in Front?

Tags are labels to help you keep track of conversations related to a given topic. Team Tags are visible to everyone on your Team. In analytics, admins can create reports based on tags. You can click the +tag button at the top of the message to apply a tag.

Rules save you time by automating repetitive processes. For example, you can create a rule to assign incoming messages to specific teammates, add tags to certain types of conversations, or always reply with a canned response.

By combining tags and rules in Front you can automate many of your workflows. These rules can help you handle repetitive tasks to save time and increase your team’s efficiency:

Automatic routing to assign messages to your team members based on tags such as topic or issue type.

Automatic prioritization to enrich incoming messages with additional context to help prioritize or triage based on tags such as urgency, sentiment or topic.

Automatic responses to trigger auto responses based on tags such as intent, issue type, topic, urgency, and sentiment.

Consistent analytics to build reports within Front or using external BI tools, with the aim to detect:

Why is Tagging a pain?

Tagging is important and has many benefits but at the cost of time and effort. Tagging every single message that comes in can be a pain for many teams:

It takes time; something your team is doing instead of actually replying to messages.

It must be consistent, ensuring the same criteria across your team as it scales, which is not easily done.

It is repetitive and boring, and it’s a part of the job that can lead to burnout.

The Solution

In MonkeyLearn we believe that manual repetitive tasks that involve text processing should be done by machines. By combining text classifiers and text extractors, MonkeyLearn can turn unstructured text data (such as emails, texts, and social media) into structured data, i.e., tags. Those tags can then be used to automate your business workflows as described above. Picture each MonkeyLearn model (classifier or extractor) as a dedicated robot working just for you, handling the repetitive stuff while you focus on the strategic.

Benefits

Save time by avoiding manual processing.

Ensure consistent tagging criteria without errors, real-time, 24/7.

Have a quick and consistent context on each conversation.

Make your team more efficient.

How Does it Work?

So far this sounds beautiful, doesn’t it? Let’s jump right in and show you how to set it up.

Connect MonkeyLearn to Front to tag every single message

One of the quickest ways to connect Front with MonkeyLearn is through Zapier, which will allow us to create a zap with the following steps:

1. Set a Trigger for when a “New Inbound Message” comes into Front. Then connect your Front account to Zapier (admin access in Front is required).

2. Add an Action from MonkeyLearn to Extract the relevant content from the message using the Email Cleaner model, this will remove last replies and email signatures. This is important because we will use the cleaned text for analysis in the next steps.

3. Add any additional classifiers or extractors as desired. For example, you could add a Sentiment Analysis model (Classifier) to detect if the message has a positive, negative or neutral sentiment (useful to detect priority). As you can see below, the text input will be both the message subject from step 1 and the cleaned message body from step 2:

4. Add a topic classifier. As an example, you can check out the E-commerce support classifier that is a generic way of determining what a message is about. You can build a custom classifier with tags that apply to your unique business context as well. This is useful to automate routing based on topic and skills. As you can see below, we selected a particular classifier by specifying a custom value for the classifier id.

5. Finally, the last step is to add a Python code snippet to send the tags to Front through the Front API. Not a technical user? Not to worry, it’s easy to add and you’ll be able to tell everyone you’re a hacker. I promise 🙂

First, you have to add three inputs, and fill them with the following info:

convo_id, which is the id of the triggered Front conversation from step 1.

write_key, which is your API token from Front that will allow Zapier to communicate with the Front API (you can get your API token here).

tags, which are the tags predicted by the models in each of the previous steps. If you have more than one model, just concatenate the results separated by a comma “,”.

Then, with the above filled out, you must copy the following Python code snippet in the Code field:

Python

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

fromdatetimeimportdate,datetime

importjson

fromrequests importsessions

_session=sessions.Session()

classSerializer(json.JSONEncoder):

defdefault(self,obj):

ifisinstance(obj,(date,datetime)):

returnobj.isoformat()

returnjson.JSONEncoder.default(self,obj)

classAPIError(Exception):

def__init__(self,status,code,message):

self.message=message

self.status=status

self.code=code

def__str__(self):

msg="[Error] {0}: {1} ({2})"

returnmsg.format(self.code,self.message,self.status)

defpatch(convo_id,tags,write_key):

"""Post the `kwargs` to the API"""

data={

'tags':tags

}

url='https://api2.frontapp.com/conversations/'+convo_id

data=json.dumps(data,cls=Serializer)

headers={

'Content-type':'application/json',

"Accept":"application/json",

"Authorization":'Bearer '+write_key

}

res=_session.patch(url,data=data,headers=headers,timeout=15)

ifres.status_code==200orres.status_code==204:

return"[Response]: OK"

try:

payload=res.json()

raiseAPIError(res.status_code,payload['code'],payload['message'])

except:

raiseAPIError(res.status_code,'unknown',res.text)

res=patch(input_data['convo_id'],

input_data['tags'].split(","),

input_data['write_key'])

output=[{'res':res}]

When your zap is set up and running, this is what a Front message will look like. You will see the automatically populated tags on the top of every message. Cool!

Set up rules in Front to automate your workflows based on tags

These are some cool rules that you can set up in Front to trigger when tags are automatically populated:

Routing

Auto Responders

You can also get some cool analytics based on your tags that can help spot trends in your messages and conversations:

Final Thoughts

With the above, we have quickly created a way to automate tagging incoming messages in Front using machine learning. Based on these tags, you can trigger even more automations within Front, such as assigning convos or replying with canned responses. Feel free to add, edit and experiment with more models and rules, and reach out to me if you have any questions or comments. Happy hacking!