Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mail component #178

Merged
merged 19 commits into from
Jun 27, 2024
Merged

feat: add mail component #178

merged 19 commits into from
Jun 27, 2024

Conversation

chuang8511
Copy link
Member

Because

  • we want users to be able to fetch mail and send mail through vdp

This commit

  • build mail component with send and read mail

Copy link

linear bot commented Jun 25, 2024

@chuang8511
Copy link
Member Author

chuang8511 commented Jun 26, 2024

e2e test

read email test
image

send email test
image

@chuang8511 chuang8511 marked this pull request as ready for review June 26, 2024 17:14

func initIMAPClient(serverAddress string, serverPort int) (*imapclient.Client, error) {

c, err := imapclient.DialTLS(serverAddress+":"+strconv.Itoa(serverPort), nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use fmt.Printf here

}
}

func includeSearchCondition(email Email, search Search) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about rename this to checkEnvelopeCondition?

return true
}

func includeSearchMessage(email Email, search Search) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about rename this to checkMessageCondition?

"title": "Search Subject",
"type": "string"
},
"search-from-email": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

search-from-email looks a little bit weird to me. How about we use search-from or search-email-from instead?

@@ -0,0 +1,471 @@
{
"$defs": {
"search-subject-text": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thinks search-subject should be enough.

}
}
if search.SearchFromEmail != "" {
if !strings.Contains(email.From, search.SearchFromEmail) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we perform an exact search here: email.From == search.SearchFromEmail. If the email address is [email protected] but you search for [email protected], things will go wrong.

Copy link
Member Author

@chuang8511 chuang8511 Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original design was to let the users able to search [email protected] through aaa.
But, I think your way will be better! So, I will modify it as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, in this case, fuzzy search it not suitable.

return emails, nil
}

func convertMailboxString(mailbox string) string {
Copy link
Member

@donch1989 donch1989 Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you convert the name of mailbox to the Gmail name. Does this mean that the current implementation can only be used with Gmail?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@donch1989
I miss to consider this point when I developed it. Thanks for pointing it out.
Now, I have 2 ideas for this.

  1. do not support mailbox field, and we fetch all emails from all mailbox.
  2. make mailbox as plain text, and we write the Gmail input as the example in Email Component Document

What do you think about this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can go with option 1 first. Will that have any side effects?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will that have any side effects?

It will take a longer time to scan all mailboxes.
For AI SDR demo, I think the speed of fetching emails & accuracy of the content would be the key to success.
By specifying the mailbox, it can increase the performance in terms of speed and accuracy.

Copy link
Member Author

@chuang8511 chuang8511 Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we go with option 2 in the current phase?
Is only searching one mailbox a damage for UX? If so, how about we set it as array:string?
Or, do you have other concerns that I miss?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will take a longer time to scan all mailboxes.

I'm not sure about the mechanism here. I remember you already set a limit on the number of emails, right?

array:string
I don't think array: string can work well on Console for now.

The problem with Option 2 is that users may struggle to type the correct mailbox name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the mechanism here. I remember you already set a limit on the number of emails, right?

Yes, the limit I set is the number to "scan", it will only scan a specific mailbox if the limit is smaller than the message number in a mailbox.
By the current design, it won't get the content for AI SDR usage if we make it scan INBOX first.

The purpose I specially design mailbox field is for the usage to get the sending mails specifically.

The problem with Option 2 is that users may struggle to type the correct mailbox name.

Yes, it is the purpose to design this field with enum.

Copy link
Member Author

@chuang8511 chuang8511 Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the limit I set is the number to "scan",

The reason of this design is that I have not found how to fetch emails through batch (query) way.
So, we have to fetch email one by one .

It makes the scanning takes time if we do not have limit here.
So, I added this field and set it 100 as default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I just check the imap package, it need the mailbox input. Then I think we can use Option 2 with a string plaintext.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I will add Gmail mailbox in the document as well.

"title": "Search To",
"type": "string"
},
"server-address": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we should put the server-address and server-port into setup.json. They should be in the same place as the user email and password.

application/email/v0/.compogen/extra-intro.mdx Outdated Show resolved Hide resolved
application/email/v0/.compogen/extra-send-mails.mdx Outdated Show resolved Hide resolved
application/email/v0/.compogen/extra-send-mails.mdx Outdated Show resolved Hide resolved
application/email/v0/config/definition.json Outdated Show resolved Hide resolved
"type": "string"
}
},
"TASK_SEND_EMAILS": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we only send one email, how about removing the "s"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I thought an email is like a message to a recipient.
The emails mean a message to several recipients.

I set it as recipients

So, I use plural here.
Should I change it to singular?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Send emails' sounds more like sending different content, but in this case, you're sending just one.

For App Password, please follow the steps below:
- 1. Please Sign in to your Google Account with link: https://myaccount.google.com/apppasswords
- 2. Create a new App Password and save it in a secure place.
- 3. Set it in Secrets in the Instill Platform.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 3. Set it in Secrets in the Instill Platform.
- 3. Add App Password as a new secret in the Instill Platform by navigating to **Console** > **Settings** > **Secrets**.

Copy link

@GeorgeWilliamStrong GeorgeWilliamStrong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (from a doc perspective)

Copy link
Member

@donch1989 donch1989 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@donch1989 donch1989 merged commit 04b19d0 into main Jun 27, 2024
8 checks passed
@donch1989 donch1989 deleted the chunhao/ins-5039 branch June 27, 2024 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 👋 Done
5 participants