Using ChatGPT To Answer Incoming Emails

With ThinkAutomation you can create a web chat bot that can answer questions using a local knowledge store. This article describes this in more detail.

One of the benefits of ThinkAutomation is you can use the same knowledge store to also provide automated responses to incoming emails (or SMS messages). ThinkAutomation can receive emails from Office 365, Gmail, Imap etc.

The Automation responding to these will be very similar to the Web Chat Automation - but with some subtle differences.

First - we cant use the %Msg_Body% built-in variable as the prompt text. The reason is that if a user replies to a bot email, then the new incoming email will contain the whole thread. We cant send the whole thread to ChatGPT each time - since the knowledge base search wont be as targeted and the text may go above the token limit. The conversation context will already have the previous email related context anyway.

Instead we can use the %Msg_LastReplyBody% built-in variable. This field is automatically set to the email body WITHOUT all previous quoted replies.

The other main difference is the default context. This needs to be something like:


Your name is 'Kryten' and you are a very enthusiastic ThinkAutomation representative working at Parker Software answering emails about ThinkAutomation. Given the provided sections from the ThinkAutomation knowledge base, answer the question using only that information, outputted in markdown format.

If an answer cannot be found in the information provided, respond with 'I cannot help with that' only. Do not try and answer the question if the information is not provided.

Add a friendly greeting and sign off message to your response. Your email address is 'kryten@parkersoftware.com'.

My email address is %Msg_FromEmail%


We tell ChatGPT that it is answering emails - and we tell it to add a friendly greeting and sign off message. We also tell it what its name is.

Responses will then be more like:


Hi {Name},

{response}

Best regards
Kryten


Alternatively you could use the same default context as with Web Chat forms and add the greeting and sign off/footer in the Send Email Action.

After receiving the response from ChatGPT you would then send an email back to the sender, with the message body set to the ChatGPT response.



Creation date: 14/07/2023 12:47      Updated: 18/07/2023 10:28