For Wufoo, we have a main email account with Gmail that we use for support. We do this so that any one of us can access and reply to the support questions, and so that we have a web based archive of the data. We also have a custom account management system that handles issue related to billing, database problems, account information, etc. In our ideal world, we would like to be able to go to our account manager and also see a record of all email conversations we have had with that account. In order to merge these two systems, we had to make use of libgmailer. So, let’s get started with a quick guide on how to get up and running with Gmail integration.

Depending on what language you write in, you will have to find an open source class out there to help see you through. Of course, you could write everything from scratch, but that is not the road for we’re going to take. To get up and running with the basics, in PHP, follow these steps.

  • Read the requirements for libgmailer and then download the source. Place the .php file into your web directory.

  • Get familiar with the documentation, but mainly learn how to open the connection to your Gmail account.

  • Build your query. I am not positive about the exact rules for querying Gmail, but I have found that most tips for searching Google still apply. For example, the following query could be sent to Gmail.

    $gmailer->fetchBox(GM_QUERY, ‘To:ryan@particletree.com OR From:ryan@particletree.com’, 0);

The query above would find all emails with To or From containing the string 'ryan@particletree.com'. Once you have a query, the next step is to process the results. Using getSnapshot(), you can get a handle on the results that match the query set with fetchBox().

$snapshot = $gmailer->getSnapshot(GM_STANDARD);

The variable $snapshot is now an object containing all of the data you need. To see the structure of this object, check out this tutorial over at Ricksmuseum. Once you understand the structure, you can then parse it and display it to your page. For example, you could loop through all matching emails and display their date with the code below:

for($i = 0; $i box); $i++) {
    echo $snapshot->box[$i]['long_date'];
}

The last bit of functionality we needed was a link to the actual email. With the help of Netvibes, I was able to build the email structure. It looks like this:

'<a>box[$i]['msgid'].'&amp;view=conv"&gt;[More]</a>'

And that’s about it. For our use, we just query Gmail with the account holders email, and check for any sent or received messages with that email. All matches are then displayed in our custom account manager, so that we have a quick look at the conversations and history we have had with each customer.

HTML Form Builder
Ryan Campbell

Integration With Gmail by Ryan Campbell

This entry was posted 4 years ago and was filed under Notebooks.
Comments are currently closed.

· 11 Comments! ·

  1. Fernando · 4 years ago

    Great article, and great to know that Google has this sort of complex API that other services don’t.

  2. John Topley · 4 years ago

    Are you allowed to use Gmail for commercial use now then?

  3. Ian Landsman · 4 years ago

    Ryan when you guys get to the point where you need to assign emails and so on you should take a look at my product, HelpSpot. You could still use your gmail account with it of course.

    Great job with Wufoo btw. Way off topic, but one suggestion is that you guys should make it more prominent what can be done with it. I don’t think most normal people think of ‘building forms’ when they want to accomplish something. They think of the result they’re looking for like giving a survey or whatever. I suspect most people who think in terms of forms already know how to build their own. You guys need to reach the masses who want results but don’t know how to get there. My 2 cents anyway.

  4. Chris Campbell · 4 years ago

    Hey Ian,

    We’ll take a look at HelpSpot. That might be what we need, especially when more employees are added.

    I’m pretty sure we’re on the same page with most normal people not understanding what can be accomplished with building forms. We definitely have some ideas in store for how to better explain the various ways forms can be used to collect information and organize your life.

  5. Ian Landsman · 4 years ago

    Sounds great Chris. I think a nice clean app like this has been needed for a long time. I used to work in higher education and there’s literally 10 uses for this I can think of off the top of my head where Wufoo would have let me avoid IT along with saving thousands of dollars of development costs. Not to mention allowing faculty/staff to develop their own little apps with no dependence on others, which is of course the biggest plus.

    One other thought is that over on my blog we recently had a discussion about JotSpot needing and now having a self hosted version. I think the same thing would be great for you guys. Lots of IT shops are simply not going to let their users build forms on your service because of security concerns. Letting them buy a self hosted version would give them a powerful new tool and I think make you guys some nice $$$.

  6. vivpuri · 4 years ago

    Signup for google hosted and you might get a email in fews or months :( https://www.google.com/hosted

  7. Nicolas · 4 years ago

    @Fernando

    If I don’t sell gmail account, but use mine to respond my customers, am i using commercially?

  8. Nicolas · 4 years ago

    @Fernando

    If I don’t sell gmail account, but use mine to respond my customers, am i using commercially?

  9. Nicolas · 4 years ago

    srry about double posting.

    And the messge was for John Topley, not for Fernando.

    Please edit and delete comments :)

  10. prakash · 4 years ago

    I am looking for a programmer, to help me integrate gmail into my custom small business CRM.

    I can then click the Mail Icon and send emails to my customers via gmail.

    Any professional programming help will be appreciated.

    Please feel free to contact me.

    prakash.sankara at gmail

  11. prashant · 4 years ago

    I always wondered how netvibes and other site integrated gmail with their site. Hope this will answer my question