This topic was automatically generated from Slack. You can find the original thread here.
Hi Team,
I am trying to use tool calling to create draft in my gmail. Below is the snippet I am trying to use:
from pipedream import Pipedream
from infrastructure.config.settings import get_settings
def create_draft(user_email: str, to: str, subject: str, body: str):
try:
settings = get_settings()
pipedream_client = Pipedream(
client_id=settings.pipedream_client_id,
client_secret=settings.pipedream_client_secret,
project_environment=settings.pipedream_environment,
project_id=settings.pipedream_project_id
)
accounts = pipedream_client.accounts.list()
account = next((account for account in accounts if account.external_id == user_email), None)
execute_tool_response = pipedream_client.actions.run(
id="gmail-create-draft",
external_user_id=user_email,
configured_props={ "to": to, "subject": subject, "body": body, "from_email": user_email, "gmail": {
"auth_provision_id": account.id
}
},
)
except Exception as e:
return str(e)
return execute_tool_response
And here is the connected account screenshot:
But, when executing the actions.run, it’s giving me 401. By looking into the error message, it looks like that token it’s generated expires on “Mon, 01 Jan 1990 00:00:00 GMT”. Please help fixing the issue. Thanks in advance. ALso attaching the full error message json.
Hey , my suggestion is that you can try to use Pipedream Connect with Pipedream Typescript SDK first to understand how it works first. Then you can switch to Python once you understand everything.
Thanks , to test the connect functionality do I have to test it all in the UI? Can I not add a user from nextjs UI and then invoke the tool as a python function? I am trying to highlight::
Why the token is having expiry in 1990? What can cause this? Is it a bug in python API?
PS: In the snippet I attached, pipedream_client.accounts.list() works. But, pipedream_client.actions.run gives me the error and the actions run is the python equivalent of what is found at: One SDK, thousands of API integrations
Few more pointers:
I am in Pipedream free plan.
If I need to upgrade to another plan, just to test out Pipedream will work form my usecase or not, what is the plan I need to go for?
I wonder if the connected account for Gmail is maybe not working, since it doesn’t sound like you’re getting a 401 from Pipedream, it sounds like the 401 is maybe coming from Gmail. Can you also try listing that account and checking account.healthy and account.dead for that Gmail account?
Thanks Danny, but I am currently using curl command to invoke the action and it works. Which proves no issue with my gmail/outlook account. I keep getting 401 when using python api only.
I have tried gmail and outlook find mail and create draft actions which work using curl but not using the python scripts: The details mentioned here: Slack
Interesting, I can reproduce your issue. I cannot however reproduce it across all actions, for example actions.run() works for me for google_sheets-list-worksheets, so I’m trying some other Gmail actions now