dailylog 8-09-20

1 minute read

PROBLEM:

We need a quick and easy way to schedule bookclub meetings that is

  1. Not intrusive
  2. Reliant on an additional app or technology
  3. Not part of a group chat or email, as those confuse some elderly members (however, the members DO understand text messaging!)

SOLUTION:

Investigate Automate The Boring Stuff with Python Chapter 16 “Sending Email and Text Messages”

PROBLEM:

We need credentials

SOLUTION:

Simply sign up for a twilio acccount and get those credentials!

V1

RESULT:

from twilio.rest import Client
accountSID = "MY_ACCOUNT_SID"
authToken = "MY_AUTH_TOKEN"
twilioCli = Client(accountSID, authToken)
myTwilioNumber = '+my-twi-numb'
myCellPhone = '+my-cell-numb'
message = twilioCli.messages.create(body="OH HI THERE!!", from_=myTwilioNumber, to=myCellPhone)

YAY!! This works!!

PROBLEM:

I can only send text messages to myself

SOLUTION:

A paid account! (Honestly, it’s not that expensive which was my main fear)

V2

RESULT: Same as above just with my friends’ numbers instead of my own. This was an EXCELLENT friend-troll for only $1.07. I texted all of them saying I was one of our cats. Huge win. Much joy.


Does this solve our original problem?

No, not yet.

PROBLEM:

When we respond to the twilio text, we get a janky auto-response that will definitely confuse The Olds of bookclub.

SOLUTION:

Quick express server on heroku to handle this webhook!!

HOW TO:

  1. Follow my own tutorial on how to make a quick express app
  2. yarn add twilio
  3. and add that code below
  4. Configure the webhook on Twilio’s end
const express = require("express");
const MessagingResponse = require("twilio").twiml.MessagingResponse;

const app = express();

app.get("/", (req, res) => {
  res.send("HELLO WELCOME TO OUR APP, NOW WITH MORE ROUTES!");
});

app.post("/sms", (req, res) => {
  console.log(req);
  const twiml = new MessagingResponse();

  twiml.message("Thank you for your response. Kendra will be in touch!");

  res.writeHead(200, { "Content-Type": "text/xml" });
  res.end(twiml.toString());
});

const port = process.env.PORT || 5000;
app.listen(port);

console.log(`App online and listening on ${port}!`);

VIOLA! We are now able to send and receive text messages from twilio.