Page 1 of 1

incoming number -> getting more info from contacts

Posted: 12 Nov 2013 12:29
by jaffinio
hi all,

I've been struggling with extending my flow for auto reply with sms to an incoming call based on ringer state and time of day. The catch is that I would like to get more information than just variables coming from trigger 'incoming call'. I don't want to store specific numbers and names in globals, files, or any variables in fact. What I thought of is reading specific information from Contacts on my phone. More specifically getting user's assigned group or if he/she/it ( ;) ) has been made a Favorite Contact. That would simplify things a lot for me. I wouldn't have to edit my flow's variables in any way for making changes. The only thing would be adding contact to a group and voila, job done.

So far I have not been able to reach any specific conclusion if it's possible to achieve using only Automagic. Have you done something like this? I would appreciate your help/input on that matter.

cheers, Tom

[edit]

ok, so far I have found that file /data/data/com.android.providers.contacts/databases/contacts2.db stores all information. Tomorrow is the day I will look into it more closely. As far as I investigated I need to query 2 or 3 tables to get my information. I also found a neat tutorial about that file -> http://developer.android.com/guide/topi ... vider.html. All I have to do now is test Automagic's ability to execute sqlite3 query in order to get my information.

I really don't know how fast it will be executed upon trigger. If it's going to be fairly slow then I suppose I should think about periodic check executing query and storing it in a global. Or even better! Making an end call trigger that would refresh all contacts assigned to specific groups. Maybe that's the answer to making it user friendly.

Re: incoming number -> getting more info from contacts

Posted: 13 Nov 2013 19:38
by Martin
Hi,

I have added a new variable contact_groups to incoming/outgoing call and the SMS triggers to the next version of Automagic (experimental version is available in the EAP forum).
The variable contains the list of the group names assigned to a contact.
You could use following flow to check whether a starred contact calls:

-trigger Incoming Call: State: Ringing, Numbers: All
-condition Expression: containsElement(contact_groups, "Starred in Android")
--> true: action Vibrate

Note that I did not test the EAP version yet so this feature might not work at all on some devices.

Regards,
Martin

Re: incoming number -> getting more info from contacts

Posted: 18 Nov 2013 14:57
by jaffinio
Works like a charm. Used matches() with ".*Family*." and it returns correct boolean on incoming call from family members: True :)

Now all I have to do is making some advanced conditions (not sending auto reply to landline and unidentified callers, or foreign for that matter ;) ). Does {incoming_number} evaluate as string or int?