How to Integrate GPM with Zapier
Prerequisites
This document is intended for an API professional or a person with extensive API coding knowledge. The below assumes you have extensive knowledge in working with API's.
It is not designed as a step-by-step FAQ on how to work with API's, Zapier or any programming language. The support team is unable to show you how to work with Zapier or any programming languages. It is designed as an example of linking Zapier to Gensolve for an API professional.
You should have knowledge on how to make API requests from Gensolve. API professionals please refer to How to Get Started using GPM's API
Solution
You can use our API documentation with Zapier to get data from GPM.Please refer to the following example which demonstrates how to create a flow between Zapier and GPM to get a list of new clients in an Excel spreadsheet.
Create an account
Authenticate your credentials
Get all vendors
Get all clients created yesterday
Create an account
- Go to https://zapier.com/ >> Fill the Work Email, First Name and Last Name
- Click on Get
Started Free
- Click on Make
a Zap
- Click on
to rename your Zap and enter Get new Client Appointments with Gensolve's API
Set up the trigger
- First you need to schedule how often do you want to automatically
create the spreadsheet, click on Schedule
- Select the Trigger
Event and click on Continue
- Select the Trigger On Weekends and Time Of Day.
- Click on time
zone settings
- Once the Profile is opened, select your Timezone.
- Click on Save
Changes
- Return to the previous tab and click on Test trigger
- Click on
Continue
Authenticate your credentials
- Click on
to create the second step
- Enter Code by Zapier on the search bar
- Click on Code
by Zapier
- Click on
>> Click on Rename step >> Enter Authenticate to Gensolve's API
- Select the Action
Event: Run Python and Click on Continue
- Add 4 inputs: OrganisationName, Password, SecretKey, UserName
- Copy and paste the following text in the Code text box
import requests
import json
url = "https://nzapi.gensolve.com/api/token"
payload = json.dumps({
"organisationName": input_data.get("OrganisationName"),
"password": input_data.get("Password"),
"secretKey": input_data.get("SecretKey"),
"userName": input_data.get("UserName")
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
- Click On Continue
Note: You need a user set with Api access. For more
information please refer to Allowed
Access Roles.
Note: The SecretKey can be taken from the API Configuration,
for more information please refer to Allowed
System Users.
- Click on Test
& Continue and be sure the Log is correctly retrieved
as follows
Get vendor
- Click on
to create a new step
- Click on
>> Click on Rename step >> Enter Get Vendor
- Select the Action
Event: Run Python and Click on Continue
- Add one Input Data AuthToken
and insert the 2.
Runtime Meta Logs
- Enter the following Code:
Note: IMPORTANT: Ensure you enter the name of your Gensolve Vendor where the below code is highlighted in yellow as INSERT NAME OF YOUR GENSOLVE VENDOR
import requests
import json
url = "https://nzapi.gensolve.com/vendors/get"
payload={}
headers = {
'Authorization': input_data.get("AuthToken")
}
response = requests.request("GET", url, headers=headers, data=payload)
vendors = json.loads(reponse.text)
vendorsData = vendors.get("Data")
for obj in vendorsData:
if obj.get("Name") == "INSERT NAME OF YOUR GENSOLVE VENDOR ":
print(int(obj.get("Id")))
Print (response.txt)
- Click on Continue
- Click on Test & Continue and be sure the Vendor
is correctly retrieved as follows
Get all clients created yesterday
- Click on
>> Click on Rename step >> Enter Get Clients Created
- Select the Action Event:
Run Python and Click on Continue
- Add the following inputs:
AuthToken: 2. Runtime Meta Logs
VendorId: 3. Runtime Meta Logs
- Enter the following Code
from datetime import timedelta
from datetime import date
import requests
import json
vendorId = input_data.get("VendorId")
dateTo = date.today()
dateFrom = dateTo - timedelta(days=1)
url = "https://nzapi.gensolve.com/clients/matching_clients?VendorId=" + vendorId + "&DateFrom=" +
dateFrom.strftime("%Y-%m-%d %H:%M:%S") + "&DateTo=" + dateTo.strftime("%Y-%m-%d %H:%M:%S")
payload={}
headers = {
'Authorization': input_data.get("AuthToken")
}
response = requests.request("GET", url, headers=headers, data=payload)
if response.status+code ==200:
clients = json.loads(response.text)
clientsData = clients.get("Data")
for obj in clientsData:
print(obj.get("FirstName"))
elif response.status_code == 400:
print(response.text)
elif response.status_code == 204:
print('No clients found')
- Click on Continue
- Push data to Active Campaign