Receive and Respond to Text Messages with Server-Side Swift, Perfect, and Twilio
Perfect is a versatile open source server-side Swift framework and toolset that makes it easy for developers to quickly create server- and client-side apps. Let's see how easy it is to send SMS with Twilio and Perfect.
To follow along with this post we'll need
Install Perfect using the Swift Package Manager. Create a new project directory called
PerfectSMSand then on the command line in your project directory, run
swift package init --type executable swift package generate-xcodeproj
This generates a package with the same name as your current directory.
- Package.swift at the top-level of your project contains your package description and your package’s dependencies.
- Sources/ is home to all your Swift source files, including main.swift, which will be the entry point for your project. It currently prints hello, world to the Terminal.
- Tests/ will contain unit tests you can ...
Intro to Markov Models with Swift
Did you know PageRank, the algorithm Google uses to determine the order of search results, is a type of Markov chain? I first learned about Markov chains and Markov models in my Speech Synthesis and Recognition elective and was amazed at how they are used in speech recognition, music generation, and modeling sequential data to predict the outcome of a basketball game (or almost any competition.)
What are Markov Chains and Markov Models?
The most basic type of Markov model is a Markov chain, a model whose next state is only selected based on its current state. Markov chains are used in genetics, finance, economics, game theory, and other fields. An example of one would be predicting tomorrow's weather by looking only at today's weather, not yesterday's.
Wikipedia defines a Markov model like so:
In probability theory, a Markov model is a stochastic model used to model randomly changing systems ...
Intro to Speech Recognition in Swift via FlyoverKit
One of my favorite computer science electives was Speech Synthesis and Recognition because Natural Language Processing and Computational Linguistics are becoming more widespread (look at Siri!). In this post we will add speech recognition to select famous landmarks with FlyoverKit in Swift. If you haven't seen part one of this multi-part series, check it out on the Twilio blog here.
For this post you will need Xcode 10, a Mac, and a physical iOS device to test the speech recognition features. To follow along with this post make sure to clone the corresponding GitHub repo here as we'll be adding speech recognition capabilities to it. If you just want to make a simple speech recognition app in Swift, you can use the same code but just need to add a button to your ViewController. Name the button locButton, and create a label called placeLbl. Ignore the code in this ...
Travel the World with FlyoverKit in Swift
I was a bit jealous to see some of my peers visit multiple cities and countries after graduation. What if we could build an app that could take us to all those places instead? FlyoverKit is a Swift library that presents you with "stunning 360° flyover views of various monuments on a MKMapView." This post will go over how to see different sights with FlyoverKit by generating a random location at the click of a button. The Sagrada Familia and the Eiffel Tower (shown below) are just a few of the locales we'll be flying over in this post.
In part two of this multi-part series, we will go over how to travel the world with FlyoverKit with speech recognition in Swift.
This post uses Xcode 10 and a Mac which you will need to follow along. Preferably you will also have a physical iOS device to test ...
Parse HTML for Book quotes with Python, Beautiful Soup, and WhatsApp
My first real paid job was working at the local library in high school. This was perfect because I love reading. With a monthly book stipend company perk and more time to read in my post-grad life, I've started using Goodreads to find new books and to keep track of what I've already read.
This post will go over how to parse the Goodreads quotes page. We'll target popular book quotes and quotes with a specific tag received as input from a WhatsApp message and then send a random quote as an outbound WhatsApp message.
Setting Up Twilio API Sandbox for WhatsApp
At the moment, only approved business accounts can use Twilio's WhatsApp API so we need to use the Twilio API Sandbox for WhatsApp to play around. Let's go on over to the Sandbox in our Twilio console. To activate it we must choose a Sandbox number, agree to ...
Re-Introducing Twilio Developer Evangelist Lizzie Siegle
I was so fortunate to have the amazing opportunity to intern on the Twilio developer evangelism team last summer. That mind-blowing and fun experience made my post-graduation decision to join full-time easier so here are four reasons why I am beyond excited to be back at Twilio as a Developer Evangelist in San Francisco.
1. I learned a lot.
Sure, I was a big fan of Twilio intern activities like lunch with our CEO, but I also loved the work itself. I had a blast writing some of the first Haskell posts for the blog and diving into Twilio Video and ARKit in Swift. Speaking about how to make music with Node.js at QueensJS was probably the best talk I'd given and I smile thinking about how much I practiced the talk with my NYC evangelist teammate Sam and mentor Greg hours before.
2. The Evangelism Team
I remember ...
Dive into ARKit on iOS with Swift and Twilio Programmable Video
Augmented reality has is showing up everywhere these days. Apple’s release of ARKit in iOS 11 and Google’s ARCore APIs are guaranteed to accelerate this trend by making augmented reality development accessible to even more developers and users.
We’re especially excited about the combination of augmented reality and real-time communications. In this post we’ll dive into a simple example on how to combine Programmable Video and iOS’s ARKit to share an AR experience with another user. In upcoming posts, we’ll show how to add interactivity to your AR communications apps.
What You Need
All anyone needs to develop with ARKit is
- an Apple device with an A9 or later processor (iPhone 6s or later, iPhone SE, any iPad Pro, or the 2017 iPad)
- iOS 11
- XCode 9 (both of which you can download here.)
We’ll also be using Twilio Programmable Video so you ...
Build a Reddit Slack Bot in Haskell
Do you like Reddit? Do you like bots? If you answered yes to one, both, or neither of those, then you are in luck. This post will go over how to build a Reddit Slack bot in Haskell.
This is the second Haskell post here on the Twilio blog. So if you haven’t read the first one on setting up your Haskell developer environment, check that out here.
What are Slash Commands?
According to the Slack API site, messages beginning with “/” are treated differently from other messages: they “enable Slack users to interact with your app directly from Slack” and all send their messages “…to the configured external URL via HTTP POST.”
In this post, we’ll build a custom slash command that shares a trending programming post from Reddit about whatever you pass it as a command. For example, if you typed /redditbot python, it would return an ...
How to Send an SMS in Haskell
Functional programming languages are gaining in popularity so let’s hop on that Haskell bandwagon. With Haskell, you can write clean, concise, and expressive code. Don’t believe me just yet?
Now let’s dive into setting up your Haskell developer environment by
- configuring two package managers
- installing Haskell
- making a “Hello, World” program
- sending our first SMS with Twilio using Haskell (get a Twilio phone number here)
IDEs for Haskell
There is no complete Haskell IDE (so if you want to make one, the market is wide open.) Many Haskellers use Atom because it has the language-haskell and ide-haskell packages, whose syntax-highlighting of aspects like import statements make it stand out. They also help ...
Reading Excel Spreadsheets with Python, Flask, and Openpyxl
Data stored in Excel spreadsheets can be hard to read with anything other than Excel and it’s especially tough to compare two specific datasets within all that data. One possible solution is Python. It can do the dirty work of finding the information for us while also being pretty fun.
In this post we will read NBA statistics from a Microsoft Excel sheet using the Openpyxl library. How will we know which statistics to look for and return? Text a Twilio phone number two players and a type of basketball statistic (like total points or three-point-shot-percentage) and then the SMS response will look up the statistics of the corresponding players like so:
Want to skip the tutorial and jump right into the code? No problem, head over to the complete code.
Otherwise, let’s get started.
Getting the Data
This post uses data for each player from the 2016 ...