Integrated chat system with feature phone on Nextcloud Talk

nextcloud
Reading Time: 4 minutes



My mother still uses feature phone, she have never used LINE or other SNS.

Mom
Mom

I am really satisfied.

And, there are some fraud using smart phone I hear on news.

I don’t want to be victim of cource…

Anyway I don’t want to use smart phone.



On the other hand young(?) generation like us feels, 

yatch
yatch

Communicating by email takes more efforts and time… 

I don’t want to track history from thousands of email in my mail box!

I want to communicate by chat like LINE, facebook messenger, or others.



However I can understand why she doesn’t want to use smart phone and it cannot be changed. 

Then I decided to make new system which has below features.

- My mother can use email the same as now.
- I can use chat system like LINE (but not limited)



I used Nextcloud Talk.
This is screen shot.



From my mother’s view she can use email as usual.
– “おっけい” means “OK” in Japanese.

System architecture

This is system architecture
-> From my mother to me
-> From me to my mother

I could realize this system by using existing service.
I didn’t create much program code, this was easy!

Workflow when my mother sends email

Originally my mother uses general email to communicate with me.
I added hook by Zapier

To do this you need to be premium member which is 19.99USD per month.
Someone feels this is high price, but I thought I can get more value than price.



This is trigger configuration which fires when email from my mother’s mail address.



This is action.
We can use REST API to post message to Nextcloud Talk room.



For more detail of REST API please refer this link.

Nextcloud Talk API documentation
None



Be careful!
This is what I faced error/trouble.

A. User name/Password should be specified by basic authentication.
   If you use 2 factor authentication, you need to create device specific password.
B. Content-Type: application/x-www-form-urlencoded is mandatory.
C. OCS-APIRequest: true is mandatory.



If you want to know how to do A, please refer this article.  

Workflow when I send message

I use Commands function in Nextcloud Talk.
– Now this is beta stage.

Commands (deprecated) - Nextcloud Talk API documentation



You can run your original command line when you post message with formatted style like
/m Hello
which should be “/<identifier> <argument>”.



This is how my Commands works.
The name gmail.py is a little bit strange? No problem!

Post "/m <message>" then python3 gmail.py will be executed.
 - Ex: /m Good morning!
gmail.py will do these.
 A. Sends email to my mother from my Gmail account.
    From: me
    To: my mother
 B. Posts to Nextcloud Talk chat room
    Where to post: chat room of me and my mother
    Who posts: me



This is configuration.
I set response as 0 to hide Commands execution on chat room.

sudo -u www-data php occ talk:command:list 
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see https://www.php.net/manual/en/book.pcntl.php
The current PHP memory limit is below the recommended value of 512MB.
Response values: 0 - No one,   1 - User,       2 - All
Enabled values:  0 - Disabled, 1 - Moderators, 2 - Users, 3 - Guests

+----+-----+-------+---------+------------------------------------------------------+----------+---------+
| id | app | name  | command | script                                               | response | enabled |
+----+-----+-------+---------+------------------------------------------------------+----------+---------+
| 1  |     | talk  | help    | help                                                 | 1        | 3       |
| 4  |     | gmail | m       | python3 /var/www/nextcloud_data/gmail.py {ARGUMENTS} | 0        | 3       |
+----+-----+-------+---------+------------------------------------------------------+----------+---------+



I referred this website how to send email by my Gmail account.
– Sorry this is Japanese site
You can find other site from internet!  

Gmail APIとPythonを使ってメール送信を自動化する方法
Gmail APIを使えばGmailの機能を自動で操作できます。さまざまな機能の中でも本記事ではメール送信を自動化する方法を解説。Pythonで簡単なプログラムを作り、ワンクリックでメールを送れるようになります。



I tested with some cases.
– ASCII
– Japanese
– Unicode
– Emoji
– Message with new line
I found no findings so I started to use as production!

Conclusion

How was it?

I guess someone has similar issue?

Comments

Copied title and URL