top of page

An application that sends an SMS message when the user is driving

Build your own app today!

Follow the instructions on this screen and follow them in the MIT App Inventor. Try to follow each instruction yourself. 

This tutorial will teach you how to build an app that sends an automatic response when an SMS is received while the user is driving. The app will allow the user to write the automatic message that will be sent.

In this tutorial you will learn to use Texting,  A component that allows you to process SMS messages  Log in and send messages.

Application design

When the app is ready it should look like this:


Women notice what components it consists of:

- A text box with user instructions, called PromptLabel.

- A text box with the message you want to send is called ResponseLabel.

- Texting , a component that controls the reception and sending of messages, which will appear  In the area of hidden components.

We will start by dragging the appropriate components to our screen, give them the appropriate names and change the text that appears on them as we wish.

Note that the Texting component is in the Social category on the left side of the screen.

Application programming

We'll go to the Blocks screen, there  We will define how the application will behave.

We want that when a message is received on the device, the text displayed in the ResponseLabel will be sent as an SMS message to the sender.

How do we do that?

When an SMS message is received on the phone, the texting component we added will be called  MessageReceived. The reading will be accompanied by a number  The sender's phone (will be called number) and the content of the received message (will be called messageText).

Using the texting component we can also send a message to the sender. In order to do this, we will need to define to which number to send the message and what will be the content of our message.

The number to which we want to send the message will be the same number as the number from which the original message was received, and the text will be the one we set in the ResponseLabel.

The if block will prevent the app from sending a message if the content of the message received is the same as the text in the ResponseLabel. Try to think - why should such a situation be avoided?

We will try to build the appropriate blocks ourselves:

  1. Block that receives the texting.MessageReceived call.

  2. A condition that checks whether the content of the message received is the same as the text in the ResponseLabel.

  3. Set the phone number in the Texting component to be the number from which the message was received.

  4. Define the content of the message in the component  The Texting to be the text in the ResponseLabel.

Eventually the block should look like this:

Well done,  You've finished building an app that sends SMS while driving!

If there is still some time left for the lesson, move on to the bonus phase .

If the lesson is nearing completion,  Click here to go to instructions for saving the phone app .

Once you have saved the application, you can check that it works by activating it on one device, and sending an SMS to the same device from another device.

bottom of page