How to Build Chat into Ruby on Rails Applications
We build web applications for all kinds of projects. If you want to give support agents a way to communicate with customers, or provide your users with a place to share ideas, you might find yourself wanting to add messaging to your application. Let's use Twilio Programmable Chat and Ruby on Rails to build a full-featured chat application from scratch.
Creating a New Rails App
First we'll make sure we've got a recent version of Ruby installed, then we'll install Rails and create a new application.
gem install rails rails new twilio-chat
The last command will generate our Rails application in the
twilio-chatdirectory. If we move into our newly created directory and start our server, then visit
http://localhost:3000in our browser, we should see the default Rails server page.
cd twilio-chat rails s
Adding a Default Action
Now let's return to our terminal and stop our Rails ...
Verifying Phone Numbers in Ruby on Rails with Twilio's Verify API
In the public-facing world of apps, verifying that users are real people can be tough. This is where phone verification really becomes an asset, helping to mitigate fraud.
In this post, we will walk through integrating Twilio’s Verify API into a Ruby on Rails application to discover whether a user’s phone number exists, its type of line, and its carrier. We will then authenticate the user with Verify’s token verification.
We will build a simple login action, with phone verification. This walk-through will provide basic functionality that can be ported to new or existing Ruby/Rails applications.
At a high level, successful interactions will look something like:
- The user submits a phone number to the application.
- The phone number is verified as real, or not; and whether the phone is a mobile or a landline.
- If the number is a valid cell, the user is ...
Build a collaborative playlist over WhatsApp with Rails, Twilio, and Spotify
Sharing music over playlists is a great way to discover new and old music. Spotify has collaborative playlists, but I don't like how they let your friends re-order and delete songs from the list. We can fix this by building our own collaborative playlist that only allows additions using the Spotify Web API. With the Twilio API for WhatsApp we can let our friends send in a song whenever they are struck by inspiration.
In this post we are going to build a WhatsApp bot that can do all of the above using Ruby on Rails.
To build this application we will need a few things:
Adding Automated Speech Recognition for Phone Calls to Ruby on Rails Applications
With the advent of personal digital assistants and in-home, voice-controlled gadgets, voice technologies are on the rise. Working with voice and speech recognition technologies is a crucial skill to have, not just in emergent technologies, but also in robust, existing applications. In this tutorial, we will build an implementation of Twilio’s Automated Speech Recognition (ASR) service in a simple Ruby on Rails Application, in hopes of you being able to see the wide-reaching possibilities for other implementations in your own projects.
In this tutorial, we will build a simple “Feedback Service” that receives, responds to, and stores voice messages from user phone calls—using speech recognition—and then displays them for review at a later time.
Getting Started with Our Rails App
Generating Music with Sonic Pi and Ruby
Sonic Pi is an Integrated Development Environment (IDE) for writing music in Ruby. I write code with Ruby using the Sonic Pi IDE and sample myself screaming over it with Audacity under the artist name Messica Arson. The sound I create is very much inspired by the strange sounds of noise music combined with my screams I perfected while fronting a punk band.
In this tutorial we’ll walk through how to create this song together.
What is Sonic Pi?
With Sonic Pi we can interact with our computer as if we were using a synthesizer. Under the hood Sonic Pi is a Ruby wrapper for SuperCollider. There are samples and synthesizers loaded in that you can interact with in countless ways. You can also add your own samples as we will be doing in this tutorial.
Download Sonic Pi before moving on with the rest of the post. If ...
Add SMS Notifications to Your Rails App Using Twilio
Anyone living in NYC with a car knows the pain that is Alternate Side Parking rules. There’s the need to always to be conscious of which side of the street your car is parked on, to run out at the most inopportune times to move it to the other side of the street, and occasionally the opportunity to be blocked in by someone double-parking. All of these, and more, are part of what New York drivers have to put up with on a weekly cycle.
The idea hit on and followers kept coming in… but it had its limitations. First of all, most people aren’t glued to their Twitter feeds, and one tweet can easily ...
Better passwords in Ruby applications with the Pwned Passwords API
Here at Twilio we’re fans of using a second factor to protect user accounts, but that doesn’t mean we’ve forgotten the first factor. Encouraging users to pick strong passwords is still the first line of defence for their accounts.
After spending years collecting lists of passwords from publicly available data breaches at HaveIBeenPwned, Troy Hunt has made available an API to check whether a password has been used before. This post will show you how to encourage your users to use stronger passwords by checking against the pwned passwords API.
The Pwned Passwords API
In 2017 NIST (National Institute of Standards and Technology) as part of their digital identity guidelines recommended that user passwords are checked against existing public breaches of data. The idea is that if a password has appeared in a data breach before then it is deemed compromised and should not be used. Of ...
Send SMS Messages from Your Rails 5 Application with Twilio
In the burgeoning world of coffee, there are many varietals of coffee roasts from many regions of the world. Your boss has tasked you to create an application for them to Create, Read, Update, and Destroy (CRUD) different coffee roasts. They have also informed you that they want to be notified via SMS every time a new coffee roast is added to their website in order to prevent their competitors from putting in fake coffee roasts.
Today, we will create a very basic Rails 5 CRUD app entitled “Coffee Roasts” that will notify your boss via SMS whenever a new coffee roast is added to our website using Twilio’s SMS API.
Initializing Our Rails Project
First, let’s ensure that you have Ruby, Bundler, and Rails installed in order to set up a new project:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 curl -sSL https://get.rvm.io ...
Beat the Rush on Exclusive Twitter Deals with Node.js and Twilio SMS
I just couldn’t get online fast enough. You may know the feeling: someone or some business you follow posts a sale on Twitter and by the time you get online, you have either missed the tweet or the sale has ended. You could enable SMS notifications and get every tweet texted to you in a timely fashion, but this really doesn’t help as you start to tune out the texts when the volume exceeds several tweets within a short period of time. What if you could make an app that sends you an SMS notification only when the tweet matches a sale you are actually looking for?
This is where the Twilio SMS API comes to the rescue.
In my case, I am a big fan of Wes Bos (@wesbos). Wes is a developer who produces quality and fun online courses for learning web development, particularly in a ...
How to receive and respond to text messages in Ruby with Hanami and Twilio
If you’re building web applications with Ruby then you’re probably using Rails. Hanami is a young competitor focused on providing a full featured, modern web framework for Ruby developers that is fast, secure and flexible.
Hanami is a new web application framework for the Ruby community. It has been under development since 2014, initially under the name Lotus. Version 1 was released in April 2017 and version 1.1 was just recently released in October.
As the introduction to the Hanami guide says, “If you’ve ever felt you’re stretching against the ‘Rails way’, you’ll appreciate Hanami.” While this article isn’t a comparison of Hanami and Rails, as we build with Hanami you will see the ways in which they differ and be able to decide which approach you prefer.
Let’s investigate building a web application with Hanami with a tried and tested Twilio ...