text a number, get a sweet heart phrase
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
configs
readme_images
static
.gitignore
.jscsrc
.jshintrc
CODE_OF_CONDUCT.md
CONTRIBUTING.md
ISSUE_TEMPLATE.md
LICENSE
PULLREQUEST.md
PULL_REQUEST_TEMPLATE.md
README.md
app.json
index.html
index.js
package.json

README.md

Heart Text

text a number, get a sweet heart phrase

Screen Shot

Text one of these Special Phrases:

  • i luv u : get a valentines photo photo
  • hugs : get a bear hug!
  • kisses : get some candy!
  • bandwidth : ??

Deploy

Prerequisites

Deploy To PaaS

Env Variables Required To Run

  • CATAPULT_USER_ID
  • CATAPULT_API_TOKEN
  • CATAPULT_API_SECRET

Deploy

Once deployed, visit the site to view phone number!

How it works

Heart Text has two different catapult callback routes /msgcallback & /callcallback

Incoming messages

Basic Flow

app.get('/msgcallback', function(req, res) {
	var response = {
		to: req.query.from,
		from: req.query.to,
		text: getPhrase()
	};
	var text = req.query.text.toLowerCase();
	switch(text) {
		case 'i luv u':
			response.media = [getPhoto()];
			break;
		case 'hugs':
			response.media = [getBear()];
			break;
		case 'kisses':
			response.media = [getCandy()];
			break;
		case 'bandwidth':
			response.media = ['https://s3.amazonaws.com/bwdemos/vday/bw.jpg'];
			break;
		default:
			break;
	}
	console.log(response);
	bwApi.Message.send(response)
	.then(function (result) {
		console.log(result);
	})
	.catch(function (e) {
		console.log(e);
	});
	res.sendStatus(201); //Immediately respond to request
});

Incoming Calls

Basic Flow

app.get('/callcallback', function (req, res) {
	var response = new Bandwidth.BXMLResponse();
	response.playAudio('https://s3.amazonaws.com/bwdemos/vday/vday.mp3').hangup();
	res.send(response.toString());
});