Adding Group Chat Capability to your SMS Messaging Service

Feb. 1, 2016

This blog is a modified version of an article that was posted on the TextIt blog.

Group chat is one of the many applications you can build with RapidPro. Group chat can be used to coordinate and facilitate conversations about various topics. 

Here's an example of flow for group chat: 

Building a Group Chat Workflow

The first step in building a group chat workflow is to create a group for the chat. This creates the group to which each contact's message, sent by the Send a Message to Somebody Else action, will be delivered. Once sent, each contact's message will be delivered to the group. 

To protect privacy, you might consider allowing your contacts to provide an alias. This is also useful if your contact's names haven't yet been updated to your account. 

The steps above collect the contact's alias, update it to their contact profile, let both the contact and the rest of the group chat know that the group has a new member, and then adds the contact to the group. 

Once the contact has responded, they'll reach the "Wait for Command" RuleSet, which will evaluate each message sent by the contact for the word 'exit' - a command that will exit them from the group chat.

All other messages pass through the "other" category and are directed to the group chat using the Send an SMS to Somebody Else action, which contains the sender's name and response, represented by the @step.contact.name and @step.value variables. The @step. prefix allows us to reference the active contact in a message to the contacts who comprise the group, while the variable @step.value refers to the last message sent by the active contact. 

Placing a Remove from Groups action before the Send an SMS to Somebody Else prevents the active contact from receiving the message they just sent. After the message is sent, the contact is then placed back into the group using the Add to Groups action so that they may receive responses from their others in the group: