• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

SMS autorespond with mulitple levels

EdNerd

Well-Known Member
Feb 2, 2011
182
6
I know there are SMS (text message) autoresponder apps, but generally they only go to one level: a text comes in, and one pre-set message goes back. I'd like to see this expanded to work on multiple levels.

In my mind, it works like this:
-- When I active the app, it begins to scan every text message I receive. When a message matches the First Level keyword, it sends a response.
-- The app knows what response to send because I can create small files containing keywords and responses and store them in a directory. This allows me to customize responses as required.
-- When the app sees the First Level keyword, it begins a log for that incoming phone number and starts a timer. That number has a set amount of time (maybe 60 or 90 seconds, maybe 2 or 3 minutes - would be great if it were adjustable) to reply to the autoresponse with the next level keyword. If the timer expires, that phone must start all over again with the First Level keyword.
-- The log also allows the app to track which level of keyword a specific incoming phone has reached, so it knows which level of keyword to search for next.

Let's say I have a plumbing service. At any given point, a serviceman in the field can text PLUMBCRZY to a certain nubmer. THis would be the First Level keyword that would start everything.

Let's say the response is: EMP NUMBER?
Reply: 123456
Response: JOBS? LUNCH? HELP?
Reply: JOBS
Response: JOBS 20120301: MARTIN; SMITH; JONES; GARCIA
Reply: SMITH
Response: ARRIVE? PARTS? HELP? LEAVE?
Reply: LEAVE
Response: LEAVE SMITH 1305. COMP? INC? IF INC, WHY?
Reply: INC PARTS

And so forth. I do some VB stuff and I can see this all mapped out in nested IFs and SELECT CASE statements. But I don't know all that would be required for an Android app.

Sound fun to anyone?
Ed
 
This app doesn't have the levels that you are talking about. However, it can respond to multiple phrases in a single incoming text message. You could cut out a lot of the back and forth and just send one text message for a response. Try out the lite version to see how it works first.

Thanks for that link. But the levels would be important. For instance, in the example --

Reply: 123456
Response: JOBS? LUNCH? HELP?
Reply: JOBS
Response: JOBS 20120301: MARTIN; SMITH; JONES; GARCIA
Reply: SMITH
Response: ARRIVE? PARTS? HELP? LEAVE?
Reply: LEAVE
Response: LEAVE SMITH 1305. COMP? INC? IF INC, WHY?
Reply: INC PARTS

-- a response automatically takes you down to the next level, where details could change depending on the text file you save for that day, week, month, etc.

(I actually have a totally different use in mind - kind of an SMS game, where the first response randomly assigns a number 1-9, so if two or three are doing it together, they can get completely different outcomes.)

Also, if you had the option to add in something like UP to the automated response, you could back up a level or two without having to start all over --

Response: JOBS 20120301: MARTIN; SMITH; JONES; GARCIA <UP>
Reply: SMITH
Response: ARRIVE? PARTS? HELP? LEAVE? <UP>
Reply: LEAVE
Response: LEAVE SMITH 1305. COMP? INC? IF INC, WHY? <UP>
Reply: UP
Response: ARRIVE? PARTS? HELP? LEAVE? <UP>
Reply: UP
Response: JOBS 20120301: MARTIN; SMITH; JONES; GARCIA <UP>
Reply: GARCIA
 
Upvote 0
EdNerd, it appears what you are looking for is some sort of branched query structure.

It would probably work best using some sort of state transition/state machine design, since what you describe are distinct "states" (levels of the dialog) and "transitions" (inputs). I can probably help to design such a thing, although I'm very new to Android APIs and might need some help with the layout.

It also needs to be able to manage separate conversations based on phone # and have timeouts, so the dialog doesn't hang forever w/o input. That way, you don't have to worry about the app eating up memory and battery.
 
Upvote 0
I don't know anything about the Android OS or Java code. I do VBA macros to make Word and Excel talk to each other. I could do this whole thing in a macro, but I have no clue how to translate it into Android code. Especially when you're talking interfacing with the SMS stream for multiple simultaneous sequences!

But yes I did envision a time-out at each level - the use has just so many seconds to respond or it times out and resets back to the absolute beginning.

Ed
 
Upvote 0
You are correct. So a lot of Android apps that claim to do is doing it via un-documented API or gain access via root. But to end users they are more focused on getting the features they want. Is it official API does not bother them.

Well, I've already found an API that is documented and works perfectly in an android 2.2 simulator. I should have it finished in a week or two -- depending on how busy I am with other things.
 
Upvote 0
Well, I've already found an API that is documented and works perfectly in an android 2.2 simulator. I should have it finished in a week or two -- depending on how busy I am with other things.

If you read the previous poster mention SMS inbox. The API allow us to intercept SMS as they come in but that is not Inbox isn't it ? Inbox to me is the SMS came in and sit inside the Inbox. Then the app attempt to open this Inbox and read off the SMS inside.
 
Upvote 0
If you read the previous poster mention SMS inbox. The API allow us to intercept SMS as they come in but that is not Inbox isn't it ? Inbox to me is the SMS came in and sit inside the Inbox. Then the app attempt to open this Inbox and read off the SMS inside.

Ah, my mistake. It's very possible there is no way to access the SMS inbox programatically; but that is not necessary if you're able to receive a broadcast whenever an sms is received.
 
Upvote 0
Here's an update on what I've got:
- Working decision structure editor (currently only allows 1 decision structure -- meaning you won't be able to enter different responses for monday, tuesday, etc.)

- Working auto-reply and session timeout.

The app is set up so you can create a "Decision". A Decision has a Name, and a Response. When the Decision's name is received, it's response is automatically issued.

For example, if you create a single Decision with the name "plumbxyz" and the response "no one is home right now", then anytime someone texts "plumbxyz" the response "no one is home right now" will be given.

If the Decision named "plumbxyz" has a two child Decisions named "jobs" and "help", then you could change plumbxyz's response to "jobs? help?" and when you receive the text "plumbxyz" it will provoke the response "jobs? help?".

You then text "jobs" to cause the "jobs" decision's response to be sent.

Its a working model -- I have back and forth communication set up in two android 2.1 simulators, and its looking great.

I just need to work on persiting the Decision structure to a database. I'll work on adding multiple decision structures depending on the day of the week and such at a later time.

If you have any questions on what I've got, or would like something changed, please ask :)
 
Upvote 0
rektiphyr, you are awesome!!

What got me thinking along these lines was the SMS shortcode services. For instance, TextMarks.com provides a code for texting a state and getting information back ( Send text messages - Broadcast SMS API -{{ STATEINFO: Lookup information about US States (demo Contextual Response feature). }}- TextMarks - Shared short code and http://lite.textmarks.com/dev/docs/etc/stateinfo/). I realize this is web-driven. But I saw other "auto-response" Android apps on the market and wondered if they could be expanded to something more like the contextual response.

Knowing nothing about the Android system, I didn't think that the the autoreposnder might simply be a reponse to "SMS incoming" and the actual text might not be accessible.

I can also see it getting quite cumbersome with multiple and even overlapping Decisions and Responses after just a few levels. If it won't work with more than 5 or 6 levels without overwhelming the phone or the system, then it might be a good but impractible idea.

If you're familiar with Visual Basic, there is a Select Case statement, in which the one input is compared to multiple options to return the correct response, and all within one statement without multiple nested IFs. Don't know if anything like this is available or useful in Java?

Ed
 
Upvote 0
I can also see it getting quite cumbersome with multiple and even overlapping Decisions and Responses after just a few levels. If it won't work with more than 5 or 6 levels without overwhelming the phone or the system, then it might be a good but impractible idea.

Actually the way it's designed means that moving from one level to the next is very easy. Simply reassign a variable:
Code:
if( child.getName().equals(msg) ) 
{
     lastDecision = child;
     sendMessage(lastDecision.getResponse());
                        
     if( lastDecision.getChildDecisions().size() < 1 )
          return false;
                        
     return true;
}

I don't think the program would ever be the bottleneck, more likely the device's ability to send and receive texts would slow down the process.

Also, the messages are entirely contextual, so there's no overlapping decisions. Simply, a Decision can not have two child Decisions with the same name, but the same Decision name may occur in the child list of all Decisions without causing a problem.

The following structure would work fine:

Code:
jobs -
       - jobs - 
                - jobs -
                         - jobs (response="no jobs")

And another update:
I finished the database portion today. The Decision tree is now saved to a local sqlite database on the device. Next I'm going to fiddle with getting the responder service to start on boot :)
 
Upvote 0
Wow! Again, I must say AWESOME!

Just wondering if there might be a chance that a response could include a math calculation. Of course, this would require a numberical input, and error handling if the anticipated input wasn't a number. And some way for the user to indicate that a numerical input was expected at a certain level of response.

Or maybe that would be in the Pro version! :8>)

Ed
 
Upvote 0
Wow! Again, I must say AWESOME!

Just wondering if there might be a chance that a response could include a math calculation. Of course, this would require a numberical input, and error handling if the anticipated input wasn't a number. And some way for the user to indicate that a numerical input was expected at a certain level of response.

Or maybe that would be in the Pro version! :8>)

Ed

Hm... you mean something like this?

user: plumbxyz
auto: jobs? help? prices?

user: prices
auto: Pizza? Cheeseburger?

user: pizza
auto: Number of pizzas?

user: 2
auto: $20.00

It would certainly be possible to allow the user's message to be interpreted as a number is that's what the response expects. The response could be set as something like:
"# * 10"
Meaning interpret the user's message as a number, and multiply by ten.

If I've understood you correctly, that's definitely something I'll implement. However, I haven't decided if I'm going to split the app into free/paid yet, so we'll see how it goes.

Anyways, I've just finished making some changes that will allow the app to start on boot, and I added an option for the user to turn that feature on and off. I've also added a log on the main app screen, so at any time the user can check what's been happening with the auto responder. I also changed a couple of backend things to make everything more smooth, and added some dialogs to stop the user from doing bad things (like trying to add a Decision with a blank name field).

I'm starting to run into a bit of a roadblock with the emulator though -- it's very difficult to test the service starting on boot. The emulator is constantly losing it's connection to the debugger if I force-close it, but the built-in shutdown option just hangs indefinitely. So, I'm going to try and get a device to test on for the next few days. As a result, development may slow down until I get one :(
 
Upvote 0
Umm ... need a beta tester??? :D
I've got a Samsung fascinate running 2.1.

Sure :) -- I'm going to change the logging system a bit so the user can view logs based on phone number. After that its ready for more extended testing.

This'll be my first submission to the market place so I'm not sure if there's a taboo about putting beta apps on the market... Unless someone reads this thread and tells me otherwise, I'm going to do it :p

So I'll post a link probably sometime later tonight.

And thanks for all the encouragement :)
 
Upvote 0
Well that took a lot longer than I expected. I had some design issues with the logger; specifically letting the logs be stored in the database, but also update the log viewer in realtime if the service is running. It works now though :) -- The other issue was making an icon and taking some screenshots.

It's all worked out now though, and without further adieu, Version 1.0

If you have any feedback, or feature requests keep posting em :) -- Oh, and please submit error reports for anything that goes wrong so I can fix it :)
 
Upvote 0
Works great!!! Again, this is awesome!

Suggestions:
-- Put a quick "About" or "How to use" screen on the Menu key
-- Is it possible to include an option to turn off notifications for autoresponses?
-- Include the possible decisions in the response, maybe set off some how:
[REPLY Yes|No|Done ]
-- If the possible decisions can be included, would it make sense to: limit the number of characters allowed for the decision area? provide a count of how many characters used and available in the response area? set limits like 140 characters for response and 20 characters for decisions? I'm thinking to keep everything within 160 characters per text message. (While my Android can receive novel-length texts, my other phone breaks them up into multiple posts.) Or would you think this is not an issue?

Question: will a hyperlink entered into the reponse automatically parse out as a clickable link?

All in all, an excellent app!!! This one should go to the Business Productivity reviewers!

Ed
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones