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.

Original Article

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

Martin W Brennan Martin W Brennan is a co-founder of ViewPop, the social network that puts the creation of 3D photos and videos in the hands of anyone with a smartphone. For his day job, Martin is a copywriting consultant at We Write Words, learning about the world as he writes about it.
 

Comments