AI-Powered Email Analysis Unleashed

AI-Powered Email Analysis Unleashed

TLDR;

AI-powered email analysis with ChatGPT revolutionizes customer service by effortlessly assessing language, sentiment, and urgency, leading to faster responses and happier customers. However, be mindful of potential security risks and data protection concerns when using third-party APIs.

Unleashing ChatGPT to improve Customer Support

Are you curious about how Large Language Models (LLMs) like ChatGPT can revolutionize customer service and support? Allow me to share a scenario with you that demonstrates the potential!

Imagine this - you're a support agent, and you're bombarded with a ton of emails every day. Some of them are complaints, some are queries, and some are just random chit-chat. How can you prioritize the most urgent issues or efficiently direct them to a colleague who speaks the same language? Better yet, how can you obtain this information effortlessly without any manual intervention? This is where AI come into play.

Incorporating the power of LLMs into the process of handling customer complaints can significantly streamline the management of incoming emails. By utilizing AI's ability to effortlessly analyze language, sentiment, and urgency in real-world complaint emails, we can prioritize cases and responses more effectively. This enables quicker response times to high-priority issues, which in turn leads to improvements in overall customer satisfaction.

I experimented with ChatGPT by providing it with a real-world complaint email for analysis. The results I obtained from a single prompt were fascinating. ChatGPT successfully detected the email's language, identified the sentiment and urgency of the content, and provided a concise one-sentence summary. Allow me to demonstrate how you can achieve this too!

How to Craft a GPT Prompt for Analyzing Inbound Emails

To enable quick experimentation, I prefer using a Jupyter Notebook to make requests to the OpenAI API. First, import the openai package, provide your API key, and define a simple function to call the API:

import openai
openai.api_key  = 'sk-Your-API-Key'

def get_simple_completion(prompt, model="gpt-3.5-turbo", temperature=0):
    messages = [{"role": "user", "content": prompt}]
    response = openai.ChatCompletion.create(
        model = model,
        messages = messages,
        temperature = temperature, # degree of randomness
    )
    return response.choices[0].message["content"]

Next, we need to obtain the contents of an email. To simplify this example, let's assume we have successfully extracted the subject and body of an email for further processing. To make things more interesting, I have chosen an example from the Consumer Complaint Database published by the US Consumer Financial Protection Bureau and translated it into German. Our extracted email reads as follows:

email_subject = "Problem mit einem Kauf auf Ihrer Abrechnung"
email_body = "Ich habe eine Belastung auf meiner Kreditkarte für eine Kreditkartenkontonummer, die mit XXXX endet, gemeldet. Ich hatte Sie angerufen und Sie haben mir versichert, dass Sie die Belastung entfernen werden. Allerdings haben Sie mein Konto geschlossen und die Belastung nicht entfernt, obwohl Sie gesagt haben, dass sie es tun würden. Mein Kredit-Score wird jeden Tag schlechter, weil die Belastung immer noch da ist. Ich habe sie mehrmals kontaktiert und sie haben mein Problem immer noch nicht gelöst."

Now for the most interesting part: the actual prompt. We will follow a simple prompt structure by first defining the task at hand, which is to identify the language, sentiment, and urgency of the email. Additionally, we will request a one-sentence summary in English, which will be useful for further processing tasks. From here, we simply add the email's subject and body as input and ask for the output as a JSON. All that remains is to pass this prompt into our previously defined function and display the response.

prompt = """
Task:
Analyze the email subject and body provided below for language, sentiment, and urgency. Also, provide the 1 sentence summary in English. Limit your response by only outputting information in the following structure as JSON:
Email Language: <Detected Language>
Email Sentiment: <Detected Sentiment>
Email Urgency: <Detected Urgency>
Email Summary: <1 Sentence Summary in English>

Input:
Email Subject: '{email_subject}'
Email Body: '{email_body}'

JSON Output:
""".format(email_subject=email_subject, email_body=email_body)

response = get_simple_completion(prompt)
print(response)

With this simple script, we have now accomplished multiple tasks at once: We transformed unstructured information from an email into structured information to assist with the initial assessment of an incoming case. We detected the language, allowing for automated routing. We identified the sentiment and urgency, helping us to better prioritize the task. We received a summary in English, independent of the original language used, providing us with additional opportunities to better analyze, track, and compare this request to others. All of this, with just one call, giving us the following result:

{
  "Email Language": "German",
  "Email Sentiment": "Negative",
  "Email Urgency": "High",
  "Email Summary": "Customer reports a problem with a purchase on their billing statement, stating that the charge was not removed as promised and their credit score is being negatively impacted."
}

Closing thoughts

This simple demonstration illustrates how incorporating large language models like ChatGPT into customer service processes can significantly enhance the management of inbound emails. By harnessing AI's capabilities to analyze language, sentiment, and urgency, support teams can prioritize cases more effectively, resulting in quicker response times and heightened customer satisfaction. With just a single API call, multiple tasks can be executed, converting unstructured information into actionable insights and streamlining the entire support process. Is there a catch, though?

Utilizing a third-party API and providing them with potentially sensitive data can be a cause for concern. By integrating an external API into the support process, businesses may inadvertently expose their customers' private information to potential security risks. This could include personal details, financial information, or other confidential data that should be handled with the utmost care. Therefore, it is essential for companies to thoroughly evaluate the security measures and data protection policies of any third-party API provider before integrating their services. In doing so, they can ensure that customer data remains secure while still benefiting from the enhanced efficiency and effectiveness that API-driven support processes can offer.

ChatGPT and other Large Language Models can help us generate ideas for transforming our business. However, it is sometimes worthwhile to explore alternative options to achieve similar results. Nonetheless, it's fun to push the boundaries in a responsible and controlled manner!