DEV Community

Cover image for Project Submission: cchat
Kelvin Wangonya
Kelvin Wangonya

Posted on


Project Submission: cchat

What I built

A terminal based chat application using twilio's programmable chat api. I also added some extra features like 2FA for registration using the Authy api and text messaging using the sms api.

Demo Link

Since this is a terminal based app, you'll have to run it locally.

Link to Code

GitHub logo wangonya / cchat

Cli chat app made with Python & Twilio's Programmable Chat REST API


A cli chat application made with Python & Twilio's Programmable Chat REST API.

How it works

This application provides a command line interface where registered users can chat on different channels.


  • User registration with 2FA using Twilio's Authy API
  • Terminal interface
  • Chat using Twilio's Programmable Chat API
  • Create and delete channels using the /+channel and /-channel commands
  • Receive system notifications when your username is @mentioned in a channel
  • Send sms to teammates right from the chat interface using the /sms command

Set up


  • Python 3
  • Linux / MacOs terminal
  • ngrok so we can expose our local port 8000 online for the chat webhook

Twilio Account Settings

Before we begin, we need to collect all the config values we need to run the application:

Config Value Description
Account Sid Your primary Twilio account identifier - find this in the Console.
Auth Token Used to authenticate - just

How I built it (what's the stack? did I run into issues or discover something new along the way?)

I built it with Python, using prompt-toolkit. At first I had used Click since it's what I was most familiar with, but I later figured out it wouldn't work out if I wanted to achieve a full interface.

I integrated the chat api with the sms api and authy to achieve the functionality.

The key thing I learned was multi-threading with Python. This is a feature I had never used before but I had to learn about it to have the server running and listening for connections from the webhook in the background and still keep the chat interface functional in the foreground without blocking.

As for issues, my laptop died along the way so I went like a week without making progress. I would have done a bit more if it weren't for this but oh well 🤷🏽‍♂️.

Additional Resources/Info

This app has only been tested in unix terminals (linux & mac). I don't have access to a windows machine so I was not able to test it for windows.

You cannot run two sessions of this app at the same time because the port 8000 will already be in use.
To test out chatting between different users, you can set up one of the starter apps with the same credentials in the .env so that the app is connected to the same service.

Below is an example of a chat session between two web clients and the terminal client.


Top comments (1)

rashidsalim profile image
Rashid Salim

This looks amazing! Great work!