Question

Upload Attachments from Gmail to CRM Affinity

  • 15 June 2022
  • 5 replies
  • 106 views

Userlevel 1
Badge

Hello,

 

I want to create a zap that has multiple attachments, but I need to upload them in Affinity.

I set the triggers as New Email Matching Search in Gmail:

But I am failing in finding all attachments, only shows one.

Additionally, I would like to receive some hints on how to upload in Affinity. I can upload files that have a URL, but the ones that come in the email, they are usually pdf and excel files.

 

Thank you!


5 replies

Userlevel 1
Badge

Is there a way to transform the files uploaded in Google Drive in URL?

Userlevel 1
Badge

Thanks Aaron! I did this changes in the organization_id, but for pdf and xlsx files, which are the ones I receive from emails, I can’t make it work yet.

 

Here is the original copy of the code. Somewhere along the lines, ‘org_id’ should be ‘organization_id’. Cheer! Feel free to reach out to me at support@affinity.co.

 

 

# Download the file / hydrate the file
f_downloaded = requests.get(input_data['file_url'])

# Get the full url of the file
url = input_data['file_url']

# Get the file name
filename = url[url.rfind("/")+1:]
filename_small = filename.replace(".", "_small.")

# Post request to upload the file
response = requests.post('https://api.affinity.co/entity-files', auth=('',input_data['api_key']), params=({'organization_id': input_data['org_id']}), files={'file': (filename_small, f_downloaded.content, f_downloaded.headers['content-type'])})
print(response.json())

# Output the response
output = [{'download status': f_downloaded.status_code, 'upload status': response.status_code, 'file name': filename_small}]

 

Userlevel 1
Badge

I changed the trigger for New attachment in Gmail, so it will have a trigger for each attachment, which suits better our workflow.

I am still having troubles with uploading the file:

 

 

Userlevel 1
Badge

Hello again,

Here is the link to the Zap: https://zapier.com/editor/159152613/draft/159152613/sample

 

 

 

Can someone give an input why I am not able to upload the files?

If there are more than one file, in any excel format, should I add another step, with file_csv, file_xlxs?

Thank you!!

Reply