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-chat directory. If we move into our newly created directory and start our server, then visit
http://localhost:3000 in 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 server …
We’re going to start with a simple React application that has just a few components for submitting and displaying messages. With git and npm installed, we can clone the repository, install the application’s dependencies, and start the application:
git clone https://github.com/kevinthompson/react-chat-interface cd react-chat-interface npm …
If you’re integrating a service like Twilio’s Programmable Chat into your website, you’re going to need an interface for users to interact with. Let’s use React and a suite of modern development tools to create an application for submitting and displaying chat messages.
Designing Our Interface
Before we begin building our chat interface, we should have an idea of what we want to create. Our chat application will have a container with a list of messages, and a form for writing and submitting messages. A simple design might look something like this:
As we build our our interface, we’ll identify any isolated piece of the UI that might contain its own state and behavior. Those will be our initial React components. In this simple design, the two most distinct areas are the message list and the message form.
Setting Up Our Development Environment
Developers working with React commonly use a …
In May, Twilio set up a massive 40-foot video wall for their SIGNAL conference and handed out hackable wireless badges to every attendee. Once you activated your badge by placing it in one of the podiums in front of the display, you could send commands to a short code that would affect your personal block on the video wall.
As attendees began activating their badges, you could see squares of the display post their “Ahoy, World!” message and identify their location. It didn’t take long for shapes, words, and large patches of color to begin taking shape on the wall. As soon as I saw what was possible, I had to find a way to draw pixel art on the display.
Sorting Out SMS Short Code Delivery
Knowing that all I needed to do was send text messages in order to move and colorize squares on the display, and being …