Google Fax

It was going to be a fairly normal evening. I was reading about the Pareto Distribution and the Long Tail when I decided to check my RSS feeds for anything new and interesting. And guess what….I saw something new and very interesting. There was an article on the GoogleEnterprise blog about Google Apps Script. I had heard about this from a friend this weekend, but had put off looking into it. The article got me very interested and I decided to check it out right away.

I first looked at the page for the language and then started watching the video on that page. Very cool! Simple, yes, but very cool. So I wanted to try it out. I went to my Google Docs page and created a new spreadsheet called Outgoing GFaxes.

I added 4 column headers: Fax Number, Recipient Name, From Name, and Notes. OK, so nothing really interesting so far, right. Just like any spreadsheet.

Then I created a form from the Form menu. Google Docs automatically recognizes the headings of my spreadsheet to created a form for me. All I had to do was change the Notes field to be a paragraph of text and make the Fax Number required.

So now I have a form that people can fill out so that makes things a bit interesting, but I’m not sending faxes yet. And I haven’t touched Google Apps Script. Don’t worry, it’s coming. I can decide the publish this form for people to fill out, say on my Google App Engine site, or my Google Sites site, or even on my non-google website since it can be published in an iframe. Optionally I can also lock down the spreadsheet so people cannot see the inner workings, but can fill out the form.

Now save and close the form and go to the Script Editor under Tools -> Scripts. Enter this script:

function onFormSubmit(e) {
var timestamp = e.values[0];
var faxnumber = e.values[1];
var recipname = e.values[2];
var notetext = e.values[4];

MailApp.sendEmail(“/fax=” + faxnumber + “/name=”+recipname
+”/@fax.otex.train”, notetext,””);
}

This script is basically collecting all the fields you entered, then sending an email to the SMTP fax domain you set up with SMTP integration in RightFax. From watching my videos and reading my blogs, you know that the /fax=faxnumber/name=recipient/@yourfaxdomain.com is the addressing scheme for a fax when using SMTP integration. Save the script. I saved it as SendFaxEmail. But this script isn’t going to work…not yet. You need to do one more thing.

The script as it is won’t send emails and wont respond to submitted forms until you add an installed event handler. To do that, go to Triggers -> Current Script’s Triggers and create a trigger. You want a trigger that looks like this:

You’ll have to accept a dialog that says you trust the script, but then thats it. When someone goes to the live form, they’ll be able to type in the information, click submit, and the fax will be sent.

I’ll be adding a bit more functionality to this in the next blog post. Be sure to come back to find see the next step. But it’s not going to be tomorrow. I am teaching a Rightfax class this week, so my schedule is going to be a bit tight and I’ll need a couple days to prep the next blog.

I hope you found this post interesting. If you have any questions or thoughts, leave them in the comments section below. You can also contact me through Twitter where I go by the name technovangelist.