Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Anchor
top
top


By setting up a web hook, TimeTap can send you notifications anytime your clients or staff members book an appointment for your business.


Our Push Notification service consists of a 3-step process:

  1.  A client or staff member books an appointment
  2.  TimeTap sends a notification with the appointment information as a JSON object to the cloud
  3.  Your Endpoint Application running on your webserver listens for the notification and processes when it comes through

Requirements:

  • A webserver running an endpoint application (*Note: endpoint applications can be written in various languages, such as PHP or JavaScript. See the Amazon Web Services SDK website for compatible languages).
  • A subscription to TimeTap's push notification service

In this guide, we'll cover the steps to:



Anchor
webserver
webserver

Setting up your webserver 

TimeTap uses Amazon's Simple Notification Service to handle push notifications. To get started receiving, you'll need the AWS SDK, and you'll need to create an endpoint application on your webserver that can handle HTTP(S) requests. The following example uses PHP, but you'll find support docs for other languages on the AWS SDK website.

To build our endpoint, we'll start with installing the AWS SDK for PHP using the recommended method: the dependency management tool Composer.

We'll install Composer on our webserver using the command line:

Code Block
languagebash
curl -sS https://getcomposer.org/installer | php


Then run the Composer command to install the latest version of the SDK:

Code Block
languagebash
php composer.phar require aws/aws-sdk-php


Finally, we'll include Composer's autoloader in our PHP file:

Code Block
languagephp
linenumberstrue
<?php
require 'vendor/autoload.php';


Return to Top


Anchor
php-example
php-example

Building your Endpoint Application

Your endpoint application will need to handle confirming your subscription to TimeTap's notification service as well as processing incoming notifications. The sample application below was written in PHP, but the AWS SDK supports multiple languages.

Using classes from the SDK, the code sample below shows how to:

  • Use the Message class to create a message object from the raw POST data
  • Use the MessageValidator class to validate that the message came from Amazon SNS
  • Handle a Subscription Confirmation using the SubscribeURL value 
  • Receive a notification and do something with it
  • Handle unsubscribing through the Unsubscribe Confirmation
Code Block
languagephp
titleindex.php
linenumberstrue
 <?php
 
// Include Composer autoloader
require 'vendor/autoload.php';
 
// Include Message and MessageValidator classes
use Aws\Sns\Message;
use Aws\Sns\MessageValidator;
 
// Instantiate the Message and Validator
$message = Message::fromRawPostData();
$validator = new MessageValidator();
 
// Validate the message and log errors if invalid
try {
	$validator->validate($message);
 
	// Handle Subscriptions using the SubscribeURL value in the incoming message
	if ($message['Type'] === 'SubscriptionConfirmation') {
	// Confirm the subscription by sending a GET request to the SubscribeURL
	file_get_contents($message['SubscribeURL']);
	}
 
	// Receive a Notification 
	// The message body will be a string, and it will hold whatever data was published to the SNS topic
	elseif ($message['Type'] === 'Notification') {
	// Do something with the message body and data
	echo $message['MessageID'] . ': ' . $message['Message'] . "\n";
	}
 
	// Unsubscribe from the topic using the UnsubscribeConfirmation message type
	elseif ($message['Type'] === 'UnsubscribeConfirmation') {
	file_get_contents($message['SubscribeURL']);
	}
} catch (InvalidSnsMessageException $e) {
	// Show 404 if message invalid
	http_response_code(404);
	error_log('SNS Message Validation Error: ' . $e->getMessage);
	die();
}
 

 
 


For more information on receiving SNS notifications in PHP, see this guide, or view the MessageValidator source code on Github.
























Anchor
subscribe-confirm
subscribe-confirm




Return to Top


Anchor
connect
connect

Subscribe to TimeTap's Notification Service

When you've finished building your endpoint application, you'll need to host it in a public-facing directory on your webserver. Once you've done that, simply contact us to provide the URL where your application is hosted, and we'll subscribe your account to our notification service.

Initially, your application will receive a subscription confirmation, which your application should handle, then you'll begin receiving appointment notifications in the form of JSON objects. The individual JSON object for each appointment will contain appointment information which you can parse and do something with or pass directly on to your CRM.


Here's an example of what the Appointment Notification JSON object looks like:

Code Block
languagexml
titleAppointment JSON Object
linenumberstrue
	{
			\"calendarid\":10390617,
			\"businessId\":20398,
			\"startTime\":800,
			\"endTime\":845,
			\"clientStartTime\":800,
			\"clientEndTime\":845,
				  
					\"professional\":{
						\"businessId\":20398,
						\"userName\":\"DrJones2\",
						\"email\":\"djones2@marshallcollege.edu\"

					\"timeZoneCode\":{
						\"timeZoneId\":78,
						\"timeZoneCode\":\"America/New_York\",
						\"timeZoneDesc\":\"America/New_York\",
					},
					\"location\":{
						\"locationId\":29945,
						\"locationName\":\"MyOffice\",
						\"businessId\":20398,
						\"locationType\":\"Office\"
					},
					\"reason\":{
						\"reasonId\":96439,
						\"businessId\":20398,
						\"visitMinutes\":45,
						\"reasonDesc\":\"Service3\"
					},
					\"client\":{
						\"clientId\":2530974,
						\"firstName\":\"jon\",
						\"lastName\":\"snow\",
						\"emailAddress\":\"jsnow@castleblack.mil\",
						\"city\":\"victoria\",
						\"notes\":\"\\u003cp\\u003ethis is a new client note from LSU1\\u003c/p\\u003e\",
						\"fullName\":\"jon snow\"
			}"