Daily notify bot for Line group chat using Elixir/Phoenix LiveView — Proof of concept

Deniel Chiang
4 min readJul 3, 2023

--

Photo by Waldemar on Unsplash

The beginning of the story…

Recently my church is doing a bible reading plan until the end of Nov. this year. Need to pay 3 dollars to join this competition, and won’t get it back 🤨unless your whole team members read assigned book and chapter then paste one verse of that chapter into a Line group chat by the scheduled progress.

As a professional software engineer that so tied up all day every day, and also a father of lovely, energetic 3 years old kid that will 100% interrupt me once she got chances. I decided to make a reminder that help my families can be reminded by iPhone reminder with the info that contains today’s reading book and chapter.

Sounds great, and worked great too…

Until I saw group leader has to remind members every week and day, just in case someone doesn’t know which book and chapter need to read today. Then I start to think about sharing my “reminder template” but that is the issues come from.

Not everyone uses iPhone!

That lead me to redesign the solution again.

Since Line is consider THE popular SNS in Taiwan. Why don’t I use Line group chat message sending?

What if we can have a backend server that make Line message API calling. Then send a personal message to the group chat with picking up a random verse according to the assigned progress?

Nuh…. it works only for Line Official Account

Use the Messaging API to build bots that provide personalized experiences for your users on LINE.

You associate your bot with a channel on the LINE Platform. When you create the channel, the LINE Official Account will also be automatically generated.

And also I don’t think it’s a good idea that I cheating on reading competition. So let’s focus back to the legitimate mindset!

Legitimate solution starts…

TL;DR

I had serval conversation with chatGPT then it did give me one thing that I might interesting — LINE Notify.

LINE Notify definition from chatGPT

LINE Notify is a messaging API provided by LINE Corporation, the company behind the LINE messaging app. It allows developers to send notifications and messages from their own applications or services to users on LINE.

With LINE Notify, developers can integrate LINE’s messaging capabilities into their own applications, websites, or systems. It provides a simple HTTP-based API that allows you to send messages, images, stickers, and other media to LINE users or specific LINE groups.

Developers can use LINE Notify to send important updates, notifications, reminders, or any other kind of messages to their users via LINE. It’s a useful tool for various purposes such as sending notifications for events, weather updates, news alerts, application status, and more.

To use LINE Notify, developers need to create a LINE Notify account, obtain an access token, and make HTTP requests to the LINE Notify API endpoint with the necessary parameters to send messages.

Minimal proof of concept testing

Since it’s a just proof of concept, I created an individual group called “Java” just for testing, it just me and the LINE Notify bot in it.

Have to generate an access token to start using LINE Notify.

During the generate token process, I choose “Java” for now. And name this token “Test”.

Once you connect LINE Notify with your group, you will receive a message like this, otherwise you have to invite “LINE Notify” as your friend or into this group that you choose before.

Just search “LINE Notify” and add as a friend of yours or invite into the group chat.

Now, let’s verify the API call by now. According to the LINE Notify API now(this article publishing date), I am going to use this endpoint.

POST https://notify-api.line.me/api/notify

Nice! Sent and recieved! Let’s check the group chat “Java”.

Great! Even emoji works great too!

requirement def.

LINE Notify will send today’s reading target to the group chat 6am every morning.

tech tasks

  • Calendar view that can be added the reading book and chapter info in.
  • A backend server that running cron job and send message to group chat every day
  • Backend server will require to put today’s reading book and chapter inside the message content.
  • Call LINE Notify API with the message content.

tech stack decision

Let’s code this by using Elixir and Phoenix LiveView just for fun & fashion! Nope I am joking!!

Just for the developing speed and being lazy to use any other frontend frameworks to do so. After all, it just a tiny assistant task. Not going to spend more than 20 hours on this including deployment!

  • Elixir — 1.14.3-otp-25
  • Phoenix LiveView — 1.7.2
  • Fly.io

Fun time of coding LiveView now!

--

--

Deniel Chiang

Decades of yrs experience in software developing. Started from J2EE 1.4/EJB, currently doing Elixir developing for my own consulting workshop.