PipedreamHQ / pipedream

Connect APIs, remarkably fast. Free for developers.
https://pipedream.com
Other
8.32k stars 5.27k forks source link

[ACTION] Update Signatures For Organization Gsuite #4801

Closed JugaadiTek closed 1 year ago

JugaadiTek commented 1 year ago

Is there a specific app this action is for?

gmail in gsuite

Please provide a link to the relevant API docs for the specific service / operation.

https://developers.google.com/gmail/api/guides/alias_and_signature_settings#managing_signatures https://googleapis.dev/nodejs/googleapis/latest/gmail/classes/Resource$Users$Settings$Sendas.html#patch

vunguyenhung commented 1 year ago

I can confirm that currently there's no action for this

image

And I've also added the API doc that uses Google APIs Node.js lib: https://googleapis.dev/nodejs/googleapis/latest/gmail/classes/Resource$Users$Settings$Sendas.html#patch

dylburger commented 1 year ago

Thanks for the request! Did you know that anyone can author and publish their own Pipedream actions? Would you be interested in helping out with that? We're happy to answer any questions or support you in any way.

If you don't have the time, would you be willing to reach out to the app provider to see if they're interested in building these? When we work with an app partner, it improves the quality of the integration, and it helps when this kind of request comes from a customer like you.

andrewjschuang commented 1 year ago

Currently we don't have the required scopes for this method. As seen in the docs, one of these is necessary:

@dannyroosevelt is adding one of these scopes be viable?

dannyroosevelt commented 1 year ago

Sorry for the delay on this -- both of those are restricted scopes, which have an unreasonably high bar to get approval for, from Google.

The best solution right now would be to build out the action for the Gmail Developer app.

@Modocosm have you seen the Gmail Developer app? It uses your own custom client ID and secret from a Google Cloud Project, instead of Pipedream's app, in order to work around Google's onerous requirements. Is that a viable solution for you?

andrewjschuang commented 1 year ago

Confirmed it works with the action being developed in Gmail Developer App, just be sure the add the scope https://www.googleapis.com/auth/gmail.settings.basic when authenticating your account in Pipedream.

Screenshot 2022-12-12 at 10 38 27 AM Screenshot 2022-12-12 at 10 38 52 AM
JugaadiTek commented 1 year ago

Sorry for the delay on this

😄 (no worries at all) 😄

The best solution right now would be to build out the action for the Gmail Developer app. @Modocosm have you seen the Gmail Developer app? It uses your own custom client ID and secret from a Google Cloud Project, instead of Pipedream's app, in order to work around Google's onerous requirements. Is that a viable solution for you?

Most Probably,

the google GCP Account in question is very recently setup though. No idea if that impacts that scope.

Confirmed it works with the https://github.com/PipedreamHQ/pipedream/pull/4816 in Gmail Developer App, just be sure the add the scope https://www.googleapis.com/auth/gmail.settings.basic when authenticating your account in Pipedream.

Epic! Thanks Y'all!

Really appreciate the solution :) Will give it a shot later today.

Will Confirm then

vunguyenhung commented 1 year ago

Hello @Modocosm @andrewjschuang, I've tested this action and verified it working 12 26 10 - 13 - 12 - 2022

Some notes regarding the usage,

  1. I need to add both scopes https://mail.google.com https://www.googleapis.com/auth/gmail.settings.basic in order for the Oauth flow to work

    Screen Shot 2022-12-13 at 12 28 26
  2. You might need to format it as HTML 12 26 10 - 13 - 12 - 2022

JugaadiTek commented 1 year ago

I have it working when targetting self.

But not (as org owner/admin) targeting anyone other org emails. 🤔

vunguyenhung commented 1 year ago

But not (as org owner/admin) targeting anyone other org emails. 🤔

@Modocosm May I ask what is your usecase for this? Is it possible for you to have Pipedream connect to that specific org account?

I searched through the internet and find an article here to set Org's default footer: https://www.techrepublic.com/article/how-to-set-a-gmail-signature-for-your-organization/

Is it fulfill your need?

vunguyenhung commented 1 year ago

But not (as org owner/admin) targeting anyone other org emails. 🤔

@andrewjschuang, on another note, I think we can update this line right here to have it use a prop to update other org email. Though I have not tested it since I don't have org admin email

JugaadiTek commented 1 year ago

@Modocosm May I ask what is your use case for this? Is it possible for you to have Pipedream connect to that specific org account?

I searched through the internet and find an article here to set Org's default footer: https://www.techrepublic.com/article/how-to-set-a-gmail-signature-for-your-organization/

Is it fulfill your need?

Footers are assigned/enforced specifically for compliance disclaimers. mostly unstyled. Sigs separately would take user variables and enforce branding consistency in (especially) external communications. Universally, the whole team is in favor of this. As the brand evolves, it would help reduce redundant, data entry busy work.

andrewjschuang commented 1 year ago

@andrewjschuang, on another note, I think we can update this line right here to have it use a prop to update other org email. Though I have not tested it since I don't have org admin email

@vunguyenhung email in this line is an optional prop that the user can type in to change the signature for another email. Though I have not tested for the same reason

vunguyenhung commented 1 year ago

@andrewjschuang, per this Gmail API doc here, it allows us to set the userId as email in order to set signature for other org email.

image

I think we can use the existing Email prop, we just need to pass the email to the userId field when it is set by user, or me if it is not set.

What do you think?

andrewjschuang commented 1 year ago

@vunguyenhung from my understanding of this doc, the parameter sendAsEmail is the one that configures another email to have the signature set

vunguyenhung commented 1 year ago

Hello @andrewjschuang, @Modocosm have tested the Email prop, but it is not working for other org email for his case. Is it possible to try pass the email to userId param for him to test if it works?

I'm sorry for back-and-forth communication 🙏 I'd love to have it work for @Modocosm.

andrewjschuang commented 1 year ago

@vunguyenhung np, can you please test this branch? - gmail-update-signature-test

vunguyenhung commented 1 year ago

Thank you @andrewjschuang! Hello @Modocosm, since I don't have the Gmail Org account to test.

Could you do the following steps to deploy the action to your account to test on your side?

  1. Start the Pipedream development environment on Gitpod, following the guidelines here https://pipedream.com/blog/building-a-custom-pipedream-action-component-with-gitpod/
  2. On Gitpod, paste your Pipedream API Key (can be acquired from your Pipedream setting page) into the terminal image
  3. Then publish the new Update Signature action code by @andrewjschuang by adding the following commands to the terminal:
    
    # Checkout the git branch
    git checkout origin/gmail-update-signature-test

Publish the Update Signature action

pd publish components/gmail_custom_oauth/actions/update-signature/update-signature.mjs


4. Finally, you can add the Pipedream action from `My Action` section
<img width="822" alt="Screen Shot 2022-12-14 at 08 59 01" src="https://user-images.githubusercontent.com/18277920/207486503-e622a9f2-5f17-4a35-aa91-258d83f5a322.png">
<img width="821" alt="Screen Shot 2022-12-14 at 08 59 38" src="https://user-images.githubusercontent.com/18277920/207486586-0f8d7499-7b0d-4e7d-a693-601794d98cbb.png">
vunguyenhung commented 1 year ago

Hello @Modocosm, we figures that to update the signature for other org email, you'll need to use other kind of authentication which is Google Cloud Service account with delegated domain-wide authority Addresses other than the primary address for the account can only be updated by service account clients that have been delegated domain-wide authority.

So we have updated the Update Signature action to use Google Cloud authentication. The new code is available in the branch checkpoint-gmail now, could you test it following the below steps?

  1. Start the Pipedream development environment on Gitpod, following the guidelines here https://pipedream.com/blog/building-a-custom-pipedream-action-component-with-gitpod/
  2. On Gitpod, paste your Pipedream API Key (can be acquired from your Pipedream setting page) into the terminal image
  3. Then publish the new Update Signature action code by @andrewjschuang by adding the following commands to the terminal:
    
    # Checkout the git branch
    git checkout origin/checkpoint-gmail

Publish the Update Signature action

pd publish components/gmail_custom_oauth/actions/update-signature/update-signature.mjs


4. Finally, you can add the Pipedream action from `My Action` section
<img width="822" alt="Screen Shot 2022-12-14 at 08 59 01" src="https://user-images.githubusercontent.com/18277920/207486503-e622a9f2-5f17-4a35-aa91-258d83f5a322.png">
<img width="821" alt="Screen Shot 2022-12-14 at 08 59 38" src="https://user-images.githubusercontent.com/18277920/207486586

Thank you so much for your support @Modocosm!
JugaadiTek commented 1 year ago

Alrighty, im back, sorry for the delayed response and thank you for the detailed walkthrough! Much appreciated :)

Ill give it a shot shortly and let you know.

JugaadiTek commented 1 year ago

Correction! Its working :D

Thanks @andrewjschuang @vunguyenhung! 🥳

andrewjschuang commented 1 year ago

@Modocosm That's great to hear, thanks for testing it out! @vunguyenhung I'll create another PR so this gets published to the official registry. Thanks for kindly insisting on this feature, turned out great!