Skip to main content

DevStack, Messaging, Voice

Simulating love with Node, Express, and Bandwidth


March 3, 2016


March 29, 2023

"Text me", inside heart graphic.

It’s that time of the year again… A simple stop to the local pharmacy reminds you that you’re all alone. Well, fret not you unrequited lover, you. We here at Bandwidth love you and that’s why we wrote Heart-Text. Heart-Text is a simple NodeJS application written with the Express framework that shares the love. Simply text or call 732-iLoveBW (732–456–8329) and Bandwidth will respond with a Whole Lotta Love.

Now that I feel loved, how does this work?

Simple, we have a communication API that lets you control phone numbers programmatically. Pretty much every on-demand service (call-a-car, rent-a-room, borrow-a-dog, etc…) all use some sort of telecom API to power part of their business. Creating artificial love is only a few lines of javascript away.

Handling Text Messages

Everyone ❤s getting picture messages from the one they ❤. So heart-text will send a lovely stock-image when certain keywords are matched. But at it’s ❤, it mainly just auto-responds to the text.

Heart-Text Diagrams - Incoming Message (2)
Basic Flow

Putting this all together with express and node, all you need to do is extract the relevant query parameters and build the message to send to the Bandwidth REST API

How to respond to incoming text messages using the REST API

Handling Incoming Calls

image 2

But what if you want to call your computer lover? Heart-Text handles that equally as well using BXML instead of the REST API. Use BXML to play audio on incoming call Building the BXML and response is a few lines of code within the call handle express middleware
Respond to incoming calls with BXML

Want to build your own heart-text bot?

All you need is a Bandwidth account and then download the Repo hosted in Github.

image 3