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] 📫!
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 🔥!
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.
To install Tower Flow ⚡️ execute this command go get github.com/matthewharrilal/TowerFlow
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
}
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)
}
- 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
-
Able to send a collection of messages to collection of telephone numbers concurrently! Be able to map specific message to corresponding number!
-
Add intuitive API layer for the persistence of messages
-
Formulate more robust testing!
- Matthew Harrilal - Looking For Software Engineering Internships!! - LinkedIn
This project is licensed under the MIT License - see the LICENSE.md file for details