ActiveCampaign Hackathon Highlight: Postmark and AI
ActiveCampaign Quarterly Hackathon #
Each quarter at ActiveCampaign the Tech and Product teams host a company-wide hackathon. It is an opportunity for everyone to take a small time to focus on a project, pet-peeve, or proof of concept they have been thinking about. As this is a highly collaborative event, non-engineers are encouraged to participate as well. The event takes place over three days, the first two being "hack days" with presentations on the final day. Several hackathon projects have even made it to production!
For this quarter's hackathon the unofficial theme was AI. Although it was not required, "bonus points" were awarded for incorporating AI into projects developed for this hackathon. This theme led to several creative project ideas including a data science playground, a proof of concept for a self-hosted AI chat-bot, improved asynchronous automation, improved code searching, and many more. The ActiveCampaign developer relations team also participated in the hackathon, and we developed a proof of concept for an app that uses Postmark and AI to parse incoming messages and analyze the message content.
Here is a demo of the full project in action:
Project Overview #
The project that we built for the hackathon utilizes Postmark’s Inbound Webhook to parse incoming messages, which are then passed along to two AI models for further analysis.
Although this was a proof of concept, there are many potential use cases. It can be used in a support ticketing system to provide additional insight into the tickets that are being created. It would also be useful in the sales process, using AI to automatically create follow-up tasks based on inbound message content.
This project utilized four main technologies:
Postmark Inbound Webhook to parse incoming messages and pass data along to the AI models
Python’s Natural Language Toolkit (NLTK) to provide a best guess as to whether the message content’s sentiment leaned towards positive or negative (or neutral).
ChatGPT to summarize message content and provide actionable tasks
Pipedream to tie all these steps together and for data persistence, allowing analysis over time
Postmark Inbound Webhook #
![Postmark](https://craft-assets-staging.postmark-testing.com/blog/postmark-logo.png)
The Inbound Webhook allows you to process and parse emails that are sent to your server’s inbound email address, or to your configured inbound forwarding domain. The JSON result of the parsed email is sent as a POST request to your specified webhook endpoint.
For the purposes of this project, the Inbound Webhook made it easy to parse incoming messages and pass the message content along to our AI tools for analysis.
Pipedream #
![Pipedream](https://craft-assets-staging.postmark-testing.com/images/pipedream-resize.png)
Pipedream is an integration platform that allows developers to quickly connect APIs, either via built in workflows or through custom code. Pipedream’s webhook support allowed us to set up the Inbound Webhook in just minutes without writing any code.
We also used Pipedream as a host for our Python NLTK and ChatGPT code and for data persistence. The data persistence allowed us to store data about multiple inbound messages from a single email address, allowing us to track a compound sentiment for that sender as well as tracking sentiment over time.
Python NLTK #
![Python NLTK](https://craft-assets-staging.postmark-testing.com/images/python-nltk.png)
The Natural Language Toolkit allows developers to write Python programs to work with human language data. The NLTK platform has existed for over a decade and has robust documentation and community resources, making it friendly to work with for developers of all backgrounds.
We used the NLTK to detect the sentiment of the message content received by our Inbound Webhook. Sentiment is represented on a scale from -1 (negative sentiment) to +1 (positive sentiment) with 0 being neutral.
Using Pipedream’s data persistence saved sentiment results based on the sender’s email address. This allows us to track things such as the current compound sentiment or the direction that the sender’s sentiment is trending over time.
ChatGPT #
![ChatGPT](https://craft-assets-staging.postmark-testing.com/images/chatgptlogo-resize.png)
ChatGPT is an AI model that has been trained to interact in a conversational way. The model takes an instruction or “prompt” and provides a detailed response. The conversational format also allows the model to understand follow-up questions.
For this project, we used ChatGPT to take in the email content and create a one sentence summary of the message, as well as two suggested tasks that can be done to follow up on this email. Specifically, the prompt that we used was: “Create a response with two sections: The first is a one sentence summary of the email and the second is two tasks to address this email.”
The Results #
Although we only spent two days working on this Hackathon project, everything came together very quickly and we were able to produce a working proof of concept.
Setting up the Inbound Webhook endpoint in Pipedream took only a few minutes and no code was required. We simply used Pipedream’s built-in HTTP trigger feature to act as our endpoint. This feature can automatically parse incoming test data, making it easy to choose the relevant pieces which can be passed along for further analysis.
The sentiment analysis and ChatGPT code were also hosted as an HTTP trigger within Pipedream. This made it easy to test directly during development using Postman without having to trigger a full inbound email flow.
The endpoint would take in the message content and sender, and perform both AI analyses. Then it would save the results in Pipedream’s data storage. We also created a second endpoint that allowed us to retrieve either a single message analysis or all messages for a sender including a compound sentiment analysis.
Here are some examples of the data passed to and returned from the API:
Example Request:
{
"text": "<div dir=\"ltr\"><pre class=\"gmail-c-mrkdwn__pre\" style=\"box-sizing:inherit;margin-top:4px;margin-bottom:4px;padding:8px;font-size:12px;font-variant-ligatures:none;line-height:1.50001;white-space:pre-wrap;word-break:normal;border-radius:4px;overflow-y:hidden;color:rgb(29,28,29);font-family:Monaco,Menlo,Consolas,"Courier New",monospace\">Dear Matt,\n\nI hope this email finds you well. I am writing to express my deep frustration regarding the arduous process of purchasing Disney tickets. As an avid Disney enthusiast, I expected a smooth and efficient ticket-buying experience. However, my recent attempts have been nothing short of exasperating. The website navigation is convoluted, with confusing options and endless redirects. Additionally, the limited availability of tickets and the ever-changing reservation system have further exacerbated the difficulty. I implore you to address these issues promptly, as they tarnish the otherwise magical experience that Disney promises. I sincerely hope that you will take my concerns seriously and work towards improving the ticket purchase process.\n\nThank you for your attention to this matter.\n\nSincerely,\nGreg</pre><div><br></div><span class=\"gmail_signature_prefix\">-- </span><br><div dir=\"ltr\" class=\"gmail_signature\" data-smartmail=\"gmail_signature\"><div dir=\"ltr\"><br><table style=\"color:rgb(136,136,136);font-family:Times;border-spacing:0px\"><tbody><tr><td valign=\"top\"><img src=\"https://d226aj4ao1t61q.cloudfront.net/cy3nisxfd_ac_logo-circle.png\" style=\"margin-right:12px\"></td><td valign=\"top\"><div style=\"line-height:1.1em\"><div style=\"font-family:Helvetica,sans-serif\"><font color=\"#356ae6\"><span style=\"font-size:14px\"><b>Greg<br></b></span></font><span style=\"color:rgb(95,102,126);font-size:13px\">ActiveCampaign / Developer Relations</span></div><div style=\"font-family:Helvetica,sans-serif;font-size:13px;color:rgb(95,102,126)\"></div><div style=\"font-family:Helvetica,sans-serif;font-size:13px;color:rgb(95,102,126)\"><a href=\"mailto:\" style=\"color:rgb(17,85,204)\" target=\"_blank\"></a></div></div></td></tr></tbody></table> </div></div></div>\n",
"email": "greg@example.com",
"date": "Tue, 9 May 2023 06:46:10 -0400",
"summary": true
}
Example Response:
{
"date": "Tue, 9 May 2023 06:46:10 -0400",
"given": "<div dir=\"ltr\"><pre class=\"gmail-c-mrkdwn__pre\" style=\"box-sizing:inherit;margin-top:4px;margin-bottom:4px;padding:8px;font-size:12px;font-variant-ligatures:none;line-height:1.50001;white-space:pre-wrap;word-break:normal;border-radius:4px;overflow-y:hidden;color:rgb(29,28,29);font-family:Monaco,Menlo,Consolas,"Courier New",monospace\">Dear Matt,\n\nI hope this email finds you well. I am writing to express my deep frustration regarding the arduous process of purchasing Disney tickets. As an avid Disney enthusiast, I expected a smooth and efficient ticket-buying experience. However, my recent attempts have been nothing short of exasperating. The website navigation is convoluted, with confusing options and endless redirects. Additionally, the limited availability of tickets and the ever-changing reservation system have further exacerbated the difficulty. I implore you to address these issues promptly, as they tarnish the otherwise magical experience that Disney promises. I sincerely hope that you will take my concerns seriously and work towards improving the ticket purchase process.\n\nThank you for your attention to this matter.\n\nSincerely,\nGreg</pre><div><br></div><span class=\"gmail_signature_prefix\">-- </span><br><div dir=\"ltr\" class=\"gmail_signature\" data-smartmail=\"gmail_signature\"><div dir=\"ltr\"><br><table style=\"color:rgb(136,136,136);font-family:Times;border-spacing:0px\"><tbody><tr><td valign=\"top\"><img src=\"https://d226aj4ao1t61q.cloudfront.net/cy3nisxfd_ac_logo-circle.png\" style=\"margin-right:12px\"></td><td valign=\"top\"><div style=\"line-height:1.1em\"><div style=\"font-family:Helvetica,sans-serif\"><font color=\"#356ae6\"><span style=\"font-size:14px\"><b>Greg<br></b></span></font><span style=\"color:rgb(95,102,126);font-size:13px\">ActiveCampaign / Developer Relations</span></div><div style=\"font-family:Helvetica,sans-serif;font-size:13px;color:rgb(95,102,126)\"></div><div style=\"font-family:Helvetica,sans-serif;font-size:13px;color:rgb(95,102,126)\"><a href=\"mailto:\" style=\"color:rgb(17,85,204)\" target=\"_blank\"></a></div></div></td></tr></tbody></table> </div></div></div>\n",
"nltk": {
"neg": 0.451,
"neu": 0.549,
"pos": 0,
"compound": -0.8934
},
"summary": "Greg is writing to express his frustration with the process of buying Disney tickets.\n\n1. Respond to Greg kindly offering to help resolve his issues.\n2. Examine the process for buying Disney tickets to see where it can be improved."
}
While this was just a proof of concept developed during a short hackathon, we are truly excited about the potential. Learning from inbound messages to improve customer experience is something that can be implemented in many scenarios, from a support system to a sales process. We are also excited to continue exploring other opportunities to combine AI and Postmark in new and unique ways.