You are here

How to Build a Text Message Group Chat with the Nexmo SMS API and PHP

Cloud communications provider Nexmo offers a set of APIs that allow organisations of any size to enhance their applications with simple Integration of reliable communication services.

As an example, Nexmo’s Number Insight API provides real-time intelligence on global numbers to protect against fraud and spam. The Verify API offers confirmation that a phone number is valid and accessible to improve communication efficiency, and the Voice API enables the easy integration of text-to-speech capabilities to build interactive voice response systems.

In this tutorial on the Nexmo blog, Tim Lytle explains how to build a text message group chat with the Nexmo SMS API and PHP. The simple script will allow users to text JOIN and their name to a phone number that represents a ‘group’, and all inbound messages to the group will be sent to all members of the chat.

Followers should begin with the Nexmo client Library and set up a simple Mango database on one of the free tiers before installing the Mango driver for PHP. Lytle then writes a script that accepts inbound Webhooks from Nexmo and processes the incoming messages. The inbound requests are used to create inbound messages, which the client library creates an object for with a createReply method that uses the inbound webhook data to build a reply by inverting the to and the from.

The author goes on to explain how to process commands by writing queries and setting up collections, before discussing how to handle actual messages from users to complete the script. All relevant code is available for cloning in the Nexmo SMS Group Chat repository, and Lytle is planning on writing a follow-up post to create a Web interface where users can see a log of the group’s messages.

Be sure to read the next Chat article: How to Build A Simple AI Chatbot With Web Speech API and Node.js

Original Article

Building Text Message Group Chat with the Nexmo SMS API and PHP