CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Google Summer of Code »
  • Gsoc '16 --- Integrating CiviCRM with Zapier
Pages: [1] 2

Author Topic: Gsoc '16 --- Integrating CiviCRM with Zapier  (Read 2347 times)

merci

  • I’m new here
  • *
  • Posts: 24
  • Karma: 2
  • CiviCRM version: 4.7.3
  • CMS version: Drupal 7.4
  • MySQL version: 5.6.28
  • PHP version: 5.6.11
Gsoc '16 --- Integrating CiviCRM with Zapier
March 22, 2016, 05:04:39 am
Hello Everyone,
                          I a female tech enthusiast interested in open source development, I have potential skills in the following technologies:php, javaScript, html and css, node.Js and I am familiar with Zapier and I heard about Gsoc on CiviCRM from a friend who seeks to implement this platform to solve local community problems since i was told its the 'best' CRM platform which most organization actually recommend

 I am aware of Zapiers ease of integration with many platforms such as Google sheets, MailChimp and why not supporting based on its popularity that CiviCRM be integrated too.

From my experience, Creating Triggers and Actions of CiviCRM on zapier has already been well simplified and from my perspective I think it can simply be done.

my main focus on this project is to adding CiviCRM API whcih can allow us to be able to makes such calls from CiviCRM which could do a Zap,Get and create Actions and Triggers and also how the Triggers and actions created on the Zap can be manipulated both on Zapier and on CiviCRM with the same data as data integrity is vital with such integration though that is handled by Zapier Already.

I request for the soonest possible help as i roundup with my proposal on this Gsoc Project.

Thanks for your soonest regards
Cheers,
Merci
« Last Edit: March 22, 2016, 05:09:05 am by merci »

ilja

  • I’m new here
  • *
  • Posts: 11
  • Karma: 2
  • A passioned fundraiser and a data analytics freak
  • CiviCRM version: 4.2
  • CMS version: Drupal 7.15
  • MySQL version: MySQL 5.5.25
  • PHP version: PHP 5.3.14
Re: Gsoc '16 --- Integrating CiviCRM with Zapier
March 22, 2016, 07:14:19 am
Hi,

Thansk for you interest, please do read the comments to the other post on this issue under
CiviCRM Community Forums » Discussion » Developer Discussion » Google Summer of Code » Integration of CiviCRM with Zapier GSOC_2016

You might exchange with uour other colleague, and come up with a joint project.

Ready to help,
Ilja

merci

  • I’m new here
  • *
  • Posts: 24
  • Karma: 2
  • CiviCRM version: 4.7.3
  • CMS version: Drupal 7.4
  • MySQL version: 5.6.28
  • PHP version: 5.6.11
Pre-tasks For Community Boding Period
April 23, 2016, 07:05:44 am
Hi Erik,
             I will be carrying out today,

-- Re-install development environment ( Not Wp but Drupal)

-- Download and configure buildkit on environment

-- Explain the Authentication ( key/ api_key ) process on CiviCRM and the importance on auth in Zapier


merci

  • I’m new here
  • *
  • Posts: 24
  • Karma: 2
  • CiviCRM version: 4.7.3
  • CMS version: Drupal 7.4
  • MySQL version: 5.6.28
  • PHP version: 5.6.11
Accomplished Work and Issues
April 23, 2016, 08:20:42 am
** installed Drupal
** Successfully installed CiviCRm on Drupal

 Issues Faced::
-- could not install CiviCRM
have the following error Notice: Undefined index: description in drupal_check_module() (line 1233 of /var/www/html/drupal/includes/install.inc).
(Currently using CiviCRM settings does not exist CiviCRM settings file does not exist. It should be created by CiviCRM  ( SOLVED)


TASKS FOR TOMMORROW

-- explain authentication ( key /api_key )
-- request for account on zapier
-- initial scope redesign preparation
-- Provide Daily report of tasks performed


« Last Edit: April 23, 2016, 02:49:08 pm by merci »

merci

  • I’m new here
  • *
  • Posts: 24
  • Karma: 2
  • CiviCRM version: 4.7.3
  • CMS version: Drupal 7.4
  • MySQL version: 5.6.28
  • PHP version: 5.6.11
Zapier Authentication Process Using Key and API key
April 23, 2016, 02:46:21 pm
 While using REST API, CiviCRM requires authentication for security purposes to return the data which was requested in the Get URL

 The same thing happens for Zapier,

    The Concept Here is that for every action which is created correspondingly in Zapier, We could as well use a get request to verify with the server on which the instance of CiviCRM is running and the security means be specified.

Specifically, The API key CiviCRM could be used in the get request to authenticate actually the API call of the user account which made the request and also the SITE_KEY in the civicrm.settings.php file in /drupal/sites/default directory will be used to identify the instance of the server where the get request is sent.

Locally I have tested that on my installation and this is how i did it.

- I created a new CM user specifying all the details

- I used the query to edit the the contact and add an API key to the newly created contact

" update civicrm_contact set api_key="123456789" where id = 203;"

- I obtained the site key from the civicrm.settings.php file

Using the above i modified the REST url of a Get Action to send the same request to be able to confirm that the authentication works perfectly

 Note:: without these two the server eventually returns an error message saying that authentication failed

The request now looks like this ::http://localhost/drupal/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=get&id=203&api_key=123456789&key=15df9066014102eb2d5edbc8002049d8&json={%22sequential%22:1}

and it return the contact details for the contact with id=203

NOW THE QUESTION IS HOW IS THIS APPLICABLE TO ZAPIER?

- Zapier makes use of the get requests to verify data and to communicate between servers and uses authentication methods such as API_key so if we choose and authentication method we make the request security ensured ( I concur )

- This same request can be specified under a trigger and then used to test for the returned data if data is successfully returned then Zapier both servers can communicate ( I am 60% sure it can happen )

- If this works then we may have to create a full trigger to test the validity of the get request and why not many API actions

- With  this done we can hence test actions by ensuring that the corresponding applications which have to react to this requests do exactly what they are expected

WHAT DO WE NEED TO START?

- Before Applying i had a free account which got expired before i could finish testing all of these: so i think a zapier account is needed ( i will do what you asked me @Erik)

- Access to online drupal instance of civiCRM to test request amongst servers online after testing the requests offline .

-  Install the API key extension on the online install, so as to generate api_keys for users for the requests

- Access to The site key for the standard drupal demo version for constant testing

WHAT WILL I DO NEXT?
 - I will contact the zapier helpdesk to request for an account for the testing  ;)
 - While waiting on that i will propose the scope as a advice given me by the mentor

merci

  • I’m new here
  • *
  • Posts: 24
  • Karma: 2
  • CiviCRM version: 4.7.3
  • CMS version: Drupal 7.4
  • MySQL version: 5.6.28
  • PHP version: 5.6.11
What I did Yesterday And what I intend to do Today
April 25, 2016, 02:13:50 am
YESTERDAY
-- I Read followed the Link on Wikipedia given me to read on OAuth

-- Learned About SCRUM and all the particular aspects which we will use for this project

-- Contacted the Zapier HelpDesk for Additional Trial Account ( which was extended to a month)

TODAY

-- Spend time on planning steps for the project
   ** Draft Plan With respect to timeline
   ** Create plan document on Google Docs and share with mentor

-- prepare points for project planning and scope On Tuesday Morning
« Last Edit: April 25, 2016, 05:09:47 am by merci »

merci

  • I’m new here
  • *
  • Posts: 24
  • Karma: 2
  • CiviCRM version: 4.7.3
  • CMS version: Drupal 7.4
  • MySQL version: 5.6.28
  • PHP version: 5.6.11
Accomplished Work and Issues
April 25, 2016, 07:00:19 am
WORK ACCOMPLISHED

--Read the proposal to know how i can carve out the plan not to make it too deviated
-- revisited Time-line for Gsoc to be able to fit plan time period to avoid conflicts
-- created a draft plan on Google Docs
-- shared draft plan with mentor
-- prepared a few points for project planning and scope On Tuesday Morning

DIFFICULTIES

-- since i dont know the scope it was a little difficult to plan
-- dont yet know exactly how all the components will fit so tomorrow during discussion with mentor, i will ask all neccessary questions to be clarified

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Gsoc '16 --- Integrating CiviCRM with Zapier
April 25, 2016, 11:09:13 pm
User stories:

  • As a fundraiser I want to automatically send a survey to every donor that donates 50 USD or more so that I am sure that every donor gets a survey and I can judge further steps by the results
  • As a fundraiser I want to quickly see all surveys that have been completed today so I know which surveys to check

Rough outline of user story 1:
  • a CiviCRM install is required
  • CiviCRM needs to be set up so that a contact can add a donor and receive contributions.
  • A Zapier account is required, as well as a Surveypal account (at least I assume)
  • A survey needs to be set up at Surveypal
  • A CiviCRM API needs to be available that can send data and requests to Zapier (Entity Zapier Action Create
  • The extension CiviRules (https://civicrm.org/extensions/civirules) needs to be installed and configured so it calls the Zapier Create API whenever a contribution (financial type Donation Status Completed) is greater than 50. The request should be passed to Surveypal on Zapier so a Survey will be sent.

Rough outline of user story 2:
  • a CiviCRM install is required
  • A specific activity type Survey Received needs to be configured on CiviCRM
  • A Zapier account is required, as well as a Surveypal account (at least I assume)
  • A survey needs to be set up at Surveypal
  • When they survey has been completed, the CiviCRM API Activity Create should be requested from Zapier, adding the Survey Received activity to the CiviCRM installation.

The overall objective of the project is to proof that CiviCRM can integrate with Zapier and understand what is required for the process, and estimate what time it takes to integrate one action when the configuration is done. This will enable potential funders to decide if it is worthwhile to fund a complete integration.
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

merci

  • I’m new here
  • *
  • Posts: 24
  • Karma: 2
  • CiviCRM version: 4.7.3
  • CMS version: Drupal 7.4
  • MySQL version: 5.6.28
  • PHP version: 5.6.11
What I did Yesterday And what I did Today
April 27, 2016, 07:10:09 am
WHAT I DID YESTERDAY

-- Had a meeting with the mentor to plan the scope of the project

-- Reviewed user story 1

-- Re-planned user stories starting with user story 1

-- Created a new plan on Google Docs for planned user story and shared again with mentor

-- Read Zapier documentation
     * Getting started
     * Platform
     * App life cycle
     * Example App with OAuth authentication

WHAT I WILL DO TODAY

-- Read the dcumentaion on CONTRIBUTIONS on book.civicrm.org

-- Explored CiviContribute Module to come out with the vital information from the user story 1

-- Added Contributions on local installation using CiviContribute

-- used the ApI explorer to test for the presence of the Donation like that described in user story one ( returned some data)

-- Built sample GET request and tested on online CiviCRM for the same contribution ( http://civicoop.s700.sureserver.com/ehgsoc/sites/all/modules/civicrm/extern/rest.php?entity=Contribution&action=get&api_key=XXXXXXX&key=XXXXXXXXX&json={%22sequential%22:1,%22return%22:%22contact_id%22,%22contribution_status_id%22:%22Completed%22,%22total_amount%22:{%22%3E%22:50},%22financial_type_id%22:%22Donation%22,%22contact_id%22:203,%22api.Contact.get%22:{%22id%22:%22203%22}}&json=1&json=1

*** using the API key and the site key provided by the mentor 
*** the Json sample is here http://pastebin.com/m7W1jnbj

-- installed CiviRules extension as requested by mentor

-- verified get url on Zapier to test validity

PROBLEMS FACED

-- server returned a 403 error ( May be permission issues)

-- Contacted Zapier team, they took long to reply ( not as usual)

TO ADDRESS THESE DIFFICULTIES

-- i contacted the zapier help desk and explained the issues i faced

-- I pointed the team to the REST API documentation of  CiviCRM

-- Also I contacted the mentor telling him all what i have done so far

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Gsoc '16 --- Integrating CiviCRM with Zapier
April 28, 2016, 12:08:47 am
Overall you are on the right track checking the contributions in CiviCRM.

For the first user story I do not think you need to do a GET action with the API from Zapier? I would expect you have to create a new CiviCRM API with the relevant data which can link into the way Zapier uses the REST hooks? Before you start on the next steps, can you explain in detail how the Zapier integration would work in user story 1?
I have found this on line tutorial, not sure if it is what you need: http://resthooks.org/profiles/how-zapier-uses-rest-hooks/ but it seems to make sense.

The important thing here is that if Zapier would use a standard get, it would need to know what data to pull from CiviCRM and I do not think it can do that in user story 1. CiviCRM knows what needs to happen and what data needs to be sent to Zapier. So I think you need to check the 'Sending Hooks' part of the Zapier documentation. And you probably also need to check what data is required for the Surveypal link and how you can access that from your API call(s)?

My advice is to really describe this process of sending data to Zapier in detail after you have completed 'Added Contributions on local installation'. And I would really go for a description like:
  • this happens in CiviCRM
  • then this API is sent to Zapier: ...............
  • Zapier will then take this data ........ and pass it to Surveypal

Understanding this part is vital for the project, and vital for any further development on this after your project.
« Last Edit: April 28, 2016, 12:18:00 am by Erik Hommel »
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

merci

  • I’m new here
  • *
  • Posts: 24
  • Karma: 2
  • CiviCRM version: 4.7.3
  • CMS version: Drupal 7.4
  • MySQL version: 5.6.28
  • PHP version: 5.6.11
How the Zapier integration would work in user story 1
April 28, 2016, 07:40:59 am
RECALL: As a fundraiser I want to automatically send a survey to every donor that donates 50 USD or more so that I am sure that every donor gets a survey

1. THIS HAPPENS IN CIVICRM

- A Contribution is entered, with all the necessary information ( donor , Financial type, Amount  etc)

## The API is used to query for the existing records on the contributions which meet the criteria specified in user story 1 ( donors with total amount >= 50 USD)##

- CiviRules will be used to get the data on through by querying the API for the the donations which meet the criteria for user story 1



- A rest API is created which will be used to send this same request.

- The result is obtained and then the contact_id(s) are obtained from the returned Json or XML result

- with this id(s) we can still do an api call now to get the contact information to get the data using the contact id(s) thereby helping us to know the donors by ( name , email , etc)

- An endpoint should be specified that will be used to provide this data to Zapier in a bundle ( may be Json or XML preferably) since Zapier will almost always convert JSon data into array format which is best understood

2.WHAT IS SENT TO ZAPIER

-  The bundled data ( contact details) is sent to Zapier  ( THIS SHOULD BE THE DATA REQUIRED TO CREATE A NEW SURVEY ON SURVEYPAL)

3. WHAT DOES ZAPIER DO WITH THAT

-The Authentication means is setup too ( probably API key of user requesting for resource )

- In zapier, A trigger is set with the Data source as a REST Webhook which will be used by Zapier to handle the subscriptions through CiviCRM REST API

- Zap is therefore configured with with SurveyPal by specifying both the CiviCRM account and the surveypal account

- The action is configured, to create a new survey with the data which was received from the REST Hook ( sort of )

-** Expecting that a new Survey be created, then should login to the survey pal account to verify the survey

** Zapier Does all of these with the help of its powerful REST Hooks
« Last Edit: April 29, 2016, 02:52:11 am by merci »

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Gsoc '16 --- Integrating CiviCRM with Zapier
April 29, 2016, 12:44:56 am
A couple of remarks on your post:
Quote
- The API is used to query for the existing records on the contributions which meet the criteria specified in user story 1 ( donors with total amount >= 50 USD)
No, that is not what will happen in the end. The CiviRules extension will check each contribution that is entered in CiviCRM, and if it meets the condition criteria (financial type is donation and amount is 50 or more) it does the next step. So in the end solution you will create a CiviRules action to start the Zapier stuff. But that is in the future, let's get the communication rolling first. So as a test you could do it this way.

The rest looks good to me!
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

merci

  • I’m new here
  • *
  • Posts: 24
  • Karma: 2
  • CiviCRM version: 4.7.3
  • CMS version: Drupal 7.4
  • MySQL version: 5.6.28
  • PHP version: 5.6.11
What I did Today
April 29, 2016, 11:09:16 am

WHAT I DID TODAY


 ** Installed the CiviRules extension on the online install

 ** Read CiviRules Cookbook at https://wiki.civicrm.org/confluence/display/CRMDOC/CiviRules+Cookbook

  -  Wenr through the cookbook examples (

    CiviRules Basic Example Immediate Processing
    CiviRules Basic Example Scheduled Processing
    CiviRules Example Donor Classification
    Field Value Comparison Condition
)  on local install Detaily to understand how CiviRules extension can apply to user story 1

 ** Read on how Zapier support webhooks here https://zapier.com/help/how-get-started-webhooks-zapier/
 
  -Documented new findings and shared and shared with mentor ( will be posted tomorrow if deemed necessary )





merci

  • I’m new here
  • *
  • Posts: 24
  • Karma: 2
  • CiviCRM version: 4.7.3
  • CMS version: Drupal 7.4
  • MySQL version: 5.6.28
  • PHP version: 5.6.11
What I did on Friday, Yesterday
May 01, 2016, 05:15:34 am
FRIDAY 29th April 2016

- Read the CiviRules Cookbook

- Practically Followed all the example to understand how the extension works

- U used CiviRules locally to automate user story 1

- Read Introductory documentation on how Zapier Handles Webhooks and what scripting is all about in Zapier

- Reviewed the stack Exchange and answered a question as requested by the mentor

SATURDAY 30th April 2016

- Understanding how Zapier receives data ( the format )

- Studying more about how Zapier handles webhooks

- Finding out a possibility of generating requests which have not been defined

- Trying to answer the question of Confirmation ( " How Do you know your data was sent successfully " )

- Read on how to get data from webhooks ( payloads )  and how to handle these payloads

- Visited the Zapier scripting API to have a clue on what it does and how it can be used

- Evaluating how Zapier receives webhooks.

- Sent my findings to the mentor for review, Will be posted (ALL) if the mentor considers its worth and classifies it as important and it aligns with the scope of the project

- Answered a question on stack Exchange
« Last Edit: May 01, 2016, 07:24:32 am by merci »

merci

  • I’m new here
  • *
  • Posts: 24
  • Karma: 2
  • CiviCRM version: 4.7.3
  • CMS version: Drupal 7.4
  • MySQL version: 5.6.28
  • PHP version: 5.6.11
BASIC AND IMPORTANT FINDINGS
May 05, 2016, 04:08:02 am
FINDINGS
============

- Zapier understands data in these formats :


form-encoded   ---------  first_name=Bryan&last_name=Helmig&age=27

JSON ----
{
    "first_name": "Bryan",
    "last_name": "Helmig",
    "age": 27
}


XML ----

<first_name>Bryan</first_name>
<last_name>Helmig</last_name>
<age>27</age>


 HOW ZAPIER HANDLES WEBHOOKS
============================

When you create a new Zap with a webhook enabled trigger, a brand new URL is generated such as https://zapier.com/hooks/catch/n/Lx2RH/

This URL is provided to a triggering APP ( CiviCRM  in our case ). with this zapier should start receiving payloads as soon as the triggering app sends them

Note: Zapier also has the possibility of doing the reverse :: A URL is provided to zapier where it pushes the payloads so that CiviCRM can understand



QUESTION:: DOES CIVICRM IMPLEMENT WEBHOOKS AND HOW IS THAT DONE ?


GENERATING YOU OWN REQUESTS
===========================
This section entails triggering zapier webhooks without involving a third party app  (( this is done with the help of  "curl"  and "hurl" )  hurl is foudn here https://www.hurl.it/

 This comprises sending a post request with JSON payload

EXAMPLE using curl

curl -v -H "Accept: application/json" \
        -H "Content-Type: application/json" \
        -X POST \
        -d '{"first_name":"Bryan","last_name":"Helmig","age":27}' \
        https://zapier.com/hooks/catch/n/Lx2RH/

HOW DO WE KNOW THAT THE REQUESTS ARE SENT?
=======================================

A app like " Request bin "  here (http://requestb.in) which just takes the request and prints the payload content to the screen for us to verify that the request works actually

Therefor webhooks should be made available for the data set we require

CATHING WEBHOOKS
=================

This has to do with how we get payload from the webhooks sent by Zapier So this is also a vital step

for example if the payload type is json, it could be handled like this

<?php
$data = json_decode(file_get_contents('php://input'));
echo $data['path_to_file'];
echo $data['file_size'];
echo $data['hello'];
?>

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Google Summer of Code »
  • Gsoc '16 --- Integrating CiviCRM with Zapier

This forum was archived on 2017-11-26.