PactSafe + Twilio: The TXT to Sign Revolution

Rarely do I get excited about building out a new integration. It’s not that I’m not up to the challenge, (because let’s be honest what self-respecting developer doesn’t get amped at building out a new feature!?), but the idea of having to dig through outdated documentation for an overly complex API that then requires three methods of authentication just to get in, well that just doesn’t sound like a fun afternoon.

Thankfully, Twilio was everything I had hoped and dreamed for in a partner integration. 

We already know that manual contract execution is going the way of the COBOL and even within the context of the new online paradigm, contracts are still sent by and largely exclusively by email. For us here at PactSafe, we wanted to take that a step farther. As the only contract execution platform, we knew we had to expand our channels. As we sat down to figure this out, it was decided that viewing and agreeing to contracts via text message seemed like the next best avenue!

PactSafe leverages a MEBN stack, substituting in Backbone.js for Angular. So after creating our test account and grabbing our credentials, we jumped right in with Twilio’s node module to get started:

var twilio = require('twilio');
Var client = new twilio("<accountSid>", "<authToken>"); 
function sendText(to, message, cb) {
var data = {
  body: message,
  to: to,
  from: "<sendingNumber>"
client.messages.create(data, cb);

And.. that’s it! As far as integrations go, I am always impressed when it takes no more than 10 minutes to start sending text messages from our system! Of course, sending messages from Twilio was only the first step in a fully functioning text-to-accept solution. In expanding our integration beyond a simple text-notification system, we’ve had to build out a url shortener and webhooks for handling text responses and delivery notifications. So sending out a message in our system looks more like:

function getShortenedLink(data.contractLink, function (err, shortLink) {
  if (err) console.error(err);
  else sendText(, message + shortLink);

For the sake of simplicity, we opted to send the shortened URL at the end of a message to take advantage of the native iOS link expansion capacities. The result enabled the user to receive and accept the contract - an action that looks like “Type ‘I Agree’ to accept this agreement” and a rich link to PactSafe to view the request in detail.

The responses from Twilio are super simple as well, and it made building out webhooks a breeze. We set up our text response handler webhook from within theTwilio console, and we set up our status webhook by adding an additional statusCallback property to the data object of the original sent message. In both cases, the Twilio response handled everything we needed at the top level of the body. 

Example message webhook body:

"From": "+1234567890",
"Body": "I Agree"


Example status webhook body:

"To": "+1234567890",
"SmsStatus": "failed" //queued, failed, sent, delivered, undelivered

Our text message functionality and feature work with Twilio is far from over. But for an afternoon of work? Not bad at all! As we move forward, we will continue to look for more new and creative ways to play with Twilio. But after working with it, it was time that we sung their praises.


About PactSafe: 

PactSafe is the only contract execution platform that automatically manages all of your contract data and enables custom processes that deliver seamless execution for your customers and internal teams to ensure confidence in your end-to-end contract experience.

Schedule a PactSafe Demo

Don’t miss out!

Want the latest news, tips and best practices for high-velocity acceptance? Subscribe to our newsletter.