@postalsys/email-ai-tools 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,19 +24,28 @@ const USER_PROMPT = `
24
24
  Instructions:
25
25
  - You are an executive assistant scanning incoming emails to inform your superiors about what is important and what is not.
26
26
  - Your task is to monitor and analyze incoming emails, which consist of the message headers, a list of attachments, and text content
27
- - Describe the sentiment of the email using one word. Use either "positive", "neutral" or "negative". Include this value in the response as a "sentiment" property.
27
+ - Describe the sentiment of the email using one word. Use either "positive", "neutral", or "negative". Include this value in the response as a "sentiment" property.
28
28
  - Generate a one-sentence summary of the email. Include this value in the response as a "summary" property.
29
29
  - Does it seem like the sender of the email would expect a reply to this email? Include this information in the response as a "shouldReply" property with the value "true" if they expect it and "false" if not.
30
30
  - If this email is a reply to a previous email or a forwarded email, then extract the text content that only the email's sender wrote, and include this as a "replyText" property in the response.
31
31
  - Do not include message signatures in the extracted reply text
32
+ - If the email text mentions events, return these events as separate event objects in an "events" array
33
+ - In the event object, include "description" property that describes the event
34
+ - In the event object, include "location" property that defines the expected location of the event
35
+ - In the event object, include "startTime" property that includes a timestamp without a timezone for the start of the event
36
+ - In the event object, include "endTime" property that includes a timestamp without timezone for the expected end of the event if there is high confidence for the value
37
+ - Do not include the event in the "events" array if the confidence for it being an event is low
32
38
  - Respond with a JSON formatted structure. Do not write any other explanations.
39
+ - Always return the response in English
33
40
 
34
41
  Facts:
35
42
  - An email consists of message headers, an attachments list, and text content
36
43
  - The email to analyze is formatted in a JSON format
37
- - An email is a reply to a previous email only if it includes a "in-reply-to" header
38
- - An email is a forwarded email only if it includes the "references" header , but not the "in-reply-to" header
44
+ - An email is a reply to a previous email only if it includes an "in-reply-to" header
45
+ - An email is a forwarded email only if it includes the "references" header, but not the "in-reply-to" header
39
46
  - The email structure includes a property "headers" that contains an array of header values.
47
+ - For timestamps without timezone, use the "YYYY-MM-DD hh:mm:ss" format
48
+ - If the email uses relative dates, then use the date from the "date" header as the base value to calculate actual dates
40
49
  - Each header contains two properties, "key" as the header field key name and "value" as the header value without the key prefix
41
50
  - The email structure includes a property "attachments" that contains an array of attachments.
42
51
  - Each attachment includes a "filename" property that describes the file name, a "contentType" property that describes the Content-Type value of the attachment
@@ -193,6 +202,20 @@ ${JSON.stringify(content)}`;
193
202
  if (typeof values.shouldReply !== 'undefined' && typeof values.shouldReply !== 'boolean') {
194
203
  delete values.shouldReply;
195
204
  }
205
+ if (values && values.events) {
206
+ values.events = []
207
+ .concat(values.events || [])
208
+ .filter(event => event.startTime)
209
+ .map(event => {
210
+ let result = {};
211
+ for (let key of Object.keys(event)) {
212
+ if (event[key] !== '' && event[key] !== null) {
213
+ result[key] = event[key];
214
+ }
215
+ }
216
+ return result;
217
+ });
218
+ }
196
219
  } catch (err) {
197
220
  let error = new Error('Failed to parse output from OpenAI API');
198
221
  error.textContent = output;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postalsys/email-ai-tools",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Email AI tools",
5
5
  "main": "index.js",
6
6
  "scripts": {