Click here to Skip to main content
15,397,517 members
Articles / Hosted Services / Serverless
Posted 15 Jul 2017


1 bookmarked

Serverless Experiments with Google Cloud Platform: Part 3

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
15 Jul 2017CPOL3 min read
Connecting Functions with other web services

7.1. Calling Function by Timer

Let's imagine that you want to send a weekly newsletter. Assuming that you know how to automate its contents (what about to put your recent liked reads there?, after the first two parts of this series, writing Function which sends email shouldn't be a big problem.

But how to arrange regular calls of your Function? Of course, you still don't want to pay for full-time server which will call you whenever you want.

One of the cheap possibilities is use of or its alternatives.

IFTTT (IF This Than That) allows creating so called Applets by combining various Services.

Create free IFTTT account and being signed in go to your Applets

From there, create a New Applet.

Our Function will be triggered by Date & Time Service, which, except other possibilities (scroll down and click Date & Time triggers and actions), allows triggering (Trigger is This part of Applet) Every day of the week at the day and time you provide.

Click on This, find and choose Date & Time. Choosing Service first time usually needs to connect and setup it.

In the next step, Choose trigger Every day of the week at and fill its properties.

As that (Action part of Applet), use Webhooks' the only Action Make a web request.

As URL fill path to your Function (something like from the first lesson), Method POST and Content Type application/json (if your Function likes it). Than your Applet action's Body should look like this:

{"message": "Hello!"}

Because current trigger is Date & Time, URL or Body should contain also any of its properties (Add ingredient), for example:

{"message": "Hello, it's {{CheckTime}}!"} 

Every Applet has own log. Choose one from My Applets, go to its Configure (right-top gear icon) and click View activity log.

With correctly filled URL, after Applet run new entry will appear also in GCP Function's log.

Remember that example helloWorldFunction expects mandatory body.message:

if (req.body.message === undefined) {

  // This is an error case, as "message" is required.

  res.status(400).send('No message defined!');

Without posted message Applet should get into error state, sometimes already during its creation. In Applet's log instead of Applet ran appears Applet failed and after few minutes will IFTTT make one more attempt, also visible in both (IFTTT and GCP) logs.

7.1. Other Triggers

As could be seen during New Applet creation, triggering of Webhooks is not limited to Date & Time.

Trigger could be also mail (Email, Gmail, Office 365 Mail), so maybe you can use IFTTT instead of Mailgun from previous chapter.

Actual list contains services like RSS, Facebook, Twitter, Pocket, Calendar, GitHub, Weather or even Dishwasher, and grows.

Webhooks could be also a Trigger. This way, you can easily connect your Function with f.e. Twitter without knowing details of Twitter API or installing specific package knows it (For some services could exist more alternative packages.) Of course, connecting more servers means more delays and more possible failures. Anyway, it's worth trying it.

Looking at your Webhooks Settings and you will see a unique URL associated with it. It should look like Pushing Edit connection button will URL change.

Open your in web browser and you will see page with

Your key is: abcdefghijklmnopqrstuvwxyz

information and form for testing three available fixedly named optional parameters:

With an optional JSON body of:

{ "value1" : "", "value2" : "", "value3" : "" }

Knowing your key, open and you will see:

Congratulations! You've fired the makertest event

In log, it is visible this way:




June 41, 2017 at 27:98PM







Don't be fooled by log. Variable names start with small letters. Setting them in URL should be this way:


7.2. Alternative

Instead of IFTTT, you can try Zapier.

Applets are here named Zaps, timer is Schedule, Webhooks also Webhooks.

Connections to third party services work similarly to IFTTT's, but lists of them are not equal. Some features are in Free Plan limited.

What is unique is their email Parser. Emails send (forwarded) to parser-related email address (something like are compared with predefined pattern and selected parts could become text variables used into Zaps. Sometimes, it could completely eliminate the need of writing your own email parser as GCP Function.

End of Part Three.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Tibor Blazko
Software Developer (Senior)
Slovakia Slovakia
No Biography provided

Comments and Discussions

PraiseThanks for the information on Triggers. Pin
Member 1507871628-Jul-22 19:25
MemberMember 1507871628-Jul-22 19:25 
QuestionZapier's November 2017 Update Pin
Tibor Blazko26-Nov-17 5:21
MemberTibor Blazko26-Nov-17 5:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.