Skip to content

Utilizing the Twillio API to be able to send messages to a collection of individuals concurrently.

License

Notifications You must be signed in to change notification settings

matthewharrilal/TowerFlow

Repository files navigation

Tower Flow ⚡️

Tower flow enables users to be able to message individual users concurrently 📲. Built upon Twillio SMS API and utilizing GORM (Go Object Relational Mapper) to persist data, this was and is an example of understanding concurrency in a real world context! This project is in active development and completely open source! If you have questions or ways to make this project better lets collaborate 👋! Either through a pull request or an email at [email protected] 📫!

Prerequisites

In order to interact with the Twillio API to send messages you will need proper authentication credentials 👮, Account SID and and Authentication Token.

Navigate over to the Twillio Console and create an application with SMS messaging capabilities 📲!

Once done doing so you should now have been issued an authentication token and account sid number. It should look a bit like this 🔥!

Account Credentials

HIGHLY suggest once you have obtained these credentials to place them in a .env file and stored in a git ignore 🤫.

Once you've added SMS capabilities to your application on Twillio you should have received a telephone number ☎️ that will act as the source of all outgoing messages! If you did not receive one navigate to phone numbers section of the Twillio console.

Installing

To install Tower Flow ⚡️ execute this command go get github.com/matthewharrilal/TowerFlow

What does a Message Object structure look like?
type Message struct { 
	gorm.Model // Embeds schema in db with auto incrementing ID, created at, updated at, and deleted at attributes

	DateCreated string `json:"date_created"`

	MessageDirection string `json:"direction"` // Whether we are receiving or sending

	AccountIdentifier string `json:"account_sid"` 

	MessageIdentifier string `json:"sid"`

	Body string `json:"body"` // Unique identifier corresponding to the message object from Twillio

	NumberOfSegments string `json:"num_segments"` // Number of components within message
}
How do I send messages then?
package towerflow

func main() {

        // Storing Account Credentials in .env file
	err := godotenv.Load() // First load environment variables file
	if err != nil {
		log.Fatal(err)
	}

        // Your choice as to whether you want to persist messages or not!
	
	// towerflow.ConfigureDatabase()


        // Supply the collection of telephone numbers that the outgoing message is going to be sent to!

	destinationNumbers := []string{"**********", "**********", "**********"}

        // Instantiate Channel that the formulated Message Objects are going to be sent through!
        messageChannel := make(chan towerFlow.Message) 

	// Pass in credentials that you were issued from the Twillio Console

	accountSID, authToken := os.Getenv("ACCOUNT_SID"), os.Getenv("AUTH_TOKEN")

	sourceNumber := os.Getenv("SOURCE_NUMBER") // Twillio Number that was issued

	// Your choice of client to execute the request used ... default is the http.DefaultClient

	clientManager := towerflow.NewClient(nil, sourceNumber, authToken, accountSID)
    
        // Construct Message Contents and then call the Send Messages method!

        messageContent := "Any message you want!"
	message := clientManager.SendMessages(destinationNumbers, messageContent, messageChannel)


	// If you decided to persist messages you can then call the function
	towerflow.PostMessage(&message, destinationNumbers)
}

Built With

  • GORM - Object Relational Mapper (With the use of an SQLite Database)
  • Twillio Services - API Contact and SMS Capabilities
  • GODOTENV - Used to store secrets such as Twillio authentication credentials and source number

Next Features

  1. Able to send a collection of messages to collection of telephone numbers concurrently! Be able to map specific message to corresponding number!

  2. Add intuitive API layer for the persistence of messages

  3. Formulate more robust testing!

Authors

  • Matthew Harrilal - Looking For Software Engineering Internships!! - LinkedIn

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Special thanks to my backend instructor who has done an excellent job of teaching us golang and inspiration/application for this utility! Shoutout to Droxey

  • Shoutout to Subosito for how to formulate the Client structure which contains relevant information toward the authenticity of the client!

About

Utilizing the Twillio API to be able to send messages to a collection of individuals concurrently.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages