I managed to update .csv file using Tasker in phone (for every email notification from a specific sender), Next thing is to update that same .csv file in a different way using mitai2. In this way, I think I can skip using google sheet or other databases frequently and avoid quota limit issues.
But, since sqlite is free of cost, Il use that as well in part of the app needs.
NOTE: I used Tasker (One time payment around 3 usd), Autonotification plugin (free of cost if we watch a reward ad occasionally) and fairemail (free) for watching email notifications.
You could try the CloudDB, Is that what you need?
CloudDB is ai2's database in the cloud that is not stored on just one instance of the app, it is stored on everyone's instance.
If that is not what you want and you want a local database that is different for everyone's device, try TinyDB.
all of these use a key/value thing.
After spending lot of time, yesterday I completed the coding part of Tasker. Now, Tasker will do the following always.
If email notification recieved with keyword that start with prefix key in FAIR EMAIL, Tasker will parse complete notification and store it in text file.
I already have .CSV file with lot of keywords and onesignal id in the next column of it. If the keywords from notification is matched with CSV file, then Tasker will provide the row number where the keyword recived in notification is matched. This row number/index will be stored in another text file.
Now in mit ai2, il create an app that will parse the row/index value from that text file and collect the required data from CSV file( ie, onesignal id belongs to that row) using the row/index number.
This collected onesignal id will be put in a gloabal variable and a message will be triggered 'You Got A New Order'. So, the right user will get this notification.
Even though, using files may not be a good choice, I wish to proceed in this way for-now. After completing this, I will move from files to sqlite in future. Is it necessary to use SAF if i use download folder?
Since my text file has data 1,3,2. i can read it and store it in a variable but how can I pick each value one after other? I know it is possible to do, but I don't know how to do it.
A1: AutoNotification Query [
Configuration: Persistency Type: Both
Notification Apps: FairEmail
Get All Fields : true
Timeout (Seconds): 20
Structure Output (JSON, etc): On ]
A2: Write File [
File: Download/CSV File Viewer/hi.txt
Text: %antextbig()
Add Newline: On ]
A3: AutoNotification Cancel [
Configuration: Id: %anid
Notification Apps: FairEmail
Package Name: %anpackage (case ins)
Timeout (Seconds): 20
Structure Output (JSON, etc): On ]
A4: Read File [
File: Download/CSV File Viewer/hi.txt
To Var: %textfile
Structure Output (JSON, etc): On ]
A5: Variable Search Replace [
Variable: %textfile
Search: \bkey\w*\b
Store Matches In Array: %textkeys ]
A6: Variable Set [
Name: %GlobalTextKeys
To: %textkeys
Structure Output (JSON, etc): On ]
A7: Write File [
File: Download/CSV File Viewer/antextbig an.txt
Text: %textkeys()
Add Newline: On ]
A8: Read File [
File: Download/CSV File Viewer/antextbig an.txt
To Var: %textfilewithkeys
Structure Output (JSON, etc): On ]
A9: Variable Set [
Name: %newline
To:
Structure Output (JSON, etc): On ]
A10: Variable Set [
Name: %newspace
To:
Structure Output (JSON, etc): On ]
A11: Variable Search Replace [
Variable: %textfilewithkeys
Search: ,
Replace Matches: On
Replace With: %newspace ]
A12: Variable Search Replace [
Variable: %textfilewithkeys
Search:
Replace Matches: On
Replace With: %newline ]
A13: Variable Set [
Name: %text_data
To: %textfilewithkeys
Structure Output (JSON, etc): On ]
A14: Variable Split [
Name: %text_data
Splitter: %newline ]
A15: Read File [
File: Download/CSV File Viewer/2010.csv
To Var: %csv_data
Structure Output (JSON, etc): On ]
A16: Variable Set [
Name: %to_search
To: %text_data(+/)
Structure Output (JSON, etc): On ]
A17: Stop [ ]
If [ %csv_data.Header3(#?%to_search) eq 0 ]
A18: Array Set [
Variable Array: %indexes_of_matches
Values: %csv_data.Header3(#?%to_search)
Splitter: , ]
A19: Variable Set [
Name: %wrap
To: %indexes_of_matches(#)+1
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
A20: Variable Add [
Name: %Increment
Value: 1
Wrap Around: %wrap ]
A21: Variable Set [
Name: %Increment
To: 1
Structure Output (JSON, etc): On ]
If [ %Increment ~ 0 ]
A22: Variable Set [
Name: %next
To: %indexes_of_matches(%Increment)
Structure Output (JSON, etc): On ]
A23: Flash [
Text: %csv_data.Header3(%next)
Continue Task Immediately: On
Dismiss On Click: On ]
A24: Variable Search Replace [
Variable: %csv_data
Search: \Q%csv_data.Header1(%first_match),%csv_data.Header2(%first_match),%csv_data.Header3(%first_match)\E
Replace Matches: On
Replace With: $0,find ]
A25: Write File [
File: Download/177.txt
Text: %csv_data.Header3(%next)
Add Newline: On ]
And, the Blocks are:
Explanation:
The tasker code will run only if the text file is modified. Mit ai2 app will read the data/onesignalID/keyword from the text file and delete it. So, since the text file got modified, the tasker code will run and update the textfile with another onesignalID/keyword. The process continues.
Anyhow, I have to crosscheck if there is any possibility for errors in different situations. I may have to use clock in the blocks.
And, can I search the word in notifications using regular expression like this \bkey\w*\b , so, if there is any word with prefix key in notification, then some task will be done?
Okay, I shall correct that Json part as you explained.
I have to do one more thing in the above blocks I shared, ie, 'If no notification from Ecwid is recieved for more than 60 seconds, then run the whole blocks only once' .
If Ecwid notifications are coming within 60 seconds or at any time, then the whole blocks will run automatically with the help of Notification Listener. But, the whole blocks will not run if there is no new ecwid notification. So only, I decided to run the code only once after waiting for 60 seconds. By, doing this, the app will get the onesignal ID (that was stuck in a text file) from the text file that was stored earlier by Tasker after processing/analyzing the previous Ecwid notification.
Now both Mit ai2 app and Tasker are interconnected. If one app run then the other app will also run.
So, how can I set this 60 sec time limit in this mit ai2 app?