IFTTT 自動發 LINE 訊息 (免寫程式) – 以美元匯率為例

本站搬家到 GitHub 了, 新網址是 https://dennys.github.io/tw/doc/ifttt/line-robot-send-currency-exchange-rate-ifttt/

需求

用 LINE Bot 機器人每天自動發一個 LINE 訊息到群組, 要包含以下資訊.

  1. 匯率
  2. 一些連結到各銀行的匯率網站
  3. 一些匯率的歷史圖表

做法: 使用 IFTTT

IFTTT 是個免費的服務, 他的名字是 if this then that 的縮寫. 以這個應用來講, 我們要的是, IF 拿到一個匯率, THEN 發一個 LINE 訊息, 作法如下:

1. 在 IFTTT 建立一個新的 Applet

2. 新增一個 “If This"

3. 選擇 “Finance" service, 這個服務目前是由 Yahoo 提供的

4. 選擇"Today’s exchange rate report"

5. 在這裡輸入你需要的幣別和通知 (發 LINE) 的時間

6. 新增一個 “Then That"

7. 選擇 “LINE" service

8. 目前他只有一個功能就是 Send message, 就選這個

9.1 這時 IFTTT 會需要取得和 LINE 做整合的權限, 請選 Connect

9.2 這裡請使用 LINE 的帳號密碼登入

9.3 這時請回到手機上輸入認證碼, 權限就會開通了

以上 9.1~9.3 的部分只有第一次和 IFTTT 整合需要, 以後就不需要這個動作了.

10. LINE, 建立一個群組, 譬如我這裡的 TEST1, 然後把 LINE Notify 加進這個群組

11. 設定好你要發訊息的群組 (Recipient) 還有內容

12. 之後 IFTTT 就會自動每天發訊息了

注意

  1. IFTTT 好像沒辦法手動 trigger, 而且每天只會發一次, 所以每次修改完, 得等第二天才知道結果, 這個不像 Zapier 可以直接測試, 得再看看有沒有好的解法.
  2. 似乎只能發到群組, 他雖然有個 1 對 1 的訊息, 但我發到那個是沒用的
  3. 如果沒有把 LINE Notify 加到群組, 他就會發個訊息告訴你

實際範例 (LINE)

設定好後, 每天在你設定的時間, 就會收到一個 LINE 訊息 (實測是會有 1~2 分鐘的延遲)

實際範例 (手機通知)

其實很方便, 每天就會有個手機通知, 想看細節再點連結進去.

實際範例 (電腦版 LINE 的截圖)

IFTTT

這是這個 IFTTT applet 的連結: https://ifttt.com/applets/pC2DyG9z-line

Use IFTTT to send currency exchange rate mail daily

Requirement

I want to have a daily mail including currency exchange rate information.

  • Mail subject: include the exchange rate in the mail subject.
  • Mail content:
    1. Has some links to banks’ exchange rate page.
    2. Include some exchange rate history chart.

Solution: use ifttt.com

  1. Create a new Applet on IFTTT

2. Add a new “If This"

3. Choose “finance" service

4. Choose “Today’s exchange rate report"

5. Choose the input/output currency and trigger time.

6. Add a new “Then That"

7. Choose a “gmail" service

8. If you just want to send yourself an email, you can click the right button. If you want to send to several recipients, you can click left button.

9. This is an example to send your self an email.

9.1 This is my email body

As of {{CheckTime}}, 1 {{InputCurrency}} equals {{ExchangeRate}} {{OutputCurrency}}.<br>
<br>
via {{InfoUrl}}

<b>美元匯率:</b>
<ul><li>
<a href="https://rate.bot.com.tw/xrt?Lang=zh-TW">即時</a>(台銀)&nbsp;
<a href="https://rate.bot.com.tw/xrt/quote/day/USD">當日</a>(台銀)&nbsp;
<a href="https://www.xe.com/currencycharts/?from=USD&to=TWD&view=1W">1周</a>(XE)&nbsp;
<a href="https://www.xe.com/currencycharts/?from=USD&to=TWD&view=1M">1個月</a>(XE)&nbsp;
<a href="https://rate.bot.com.tw/xrt/quote/ltm/USD">3個月</a>(台銀)&nbsp;
<a href="https://rate.bot.com.tw/xrt/quote/l6m/USD">6個月</a>(台銀)
</li><li>
<a href="https://rate.bot.com.tw/xrt/quote/l1y/USD">1年</a>(台銀)&nbsp;
<a href="https://www.esunbank.com.tw/bank/personal/deposit/rate/forex/exchange-rate-chart?Currency=USD/TWD">1年</a>(玉山)&nbsp;
<a href="https://www.xe.com/currencycharts/?from=USD&to=TWD&view=1Y">1年</a>(XE)&nbsp;
<a href="https://rate.bot.com.tw/xrt/quote/l3y/USD">3年</a>(台銀)&nbsp;
<a href="https://www.xe.com/currencycharts/?from=USD&to=TWD&view=5Y">5年</a>(XE)&nbsp;
<a href="https://www.xe.com/currencycharts/?from=USD&to=TWD&view=10Y">10年</a>(XE)&nbsp;
<a href="https://fxtop.com/en/historical-exchange-rates.php?A=1&C1=USD&C2=TWD&DD1=&MM1=&YYYY1=&B=1&P=&I=1&DD2=03&MM2=03&YYYY2=2099&btnOK=Go%21">1983~現在</a>(FXTOP)&nbsp;
</li><li>
<a href="https://historical.findrate.tw/USD/">1個月+1年+10年</a>(FindRate)
</li></ul><br/>

<b>2022/1/1~2022/12/31:</b><br/>
<img src="https://fxtop.com/php/imggraph.php?C1=USD&C2=TWD&A=1&DD1=&MM1=01&YYYY1=2022&DD2=&MM2=12&YYYY2=2022&LANG=en&CJ=0&MM1Y=1&LARGE=&TR=OFF"><br/>
<b>2021/1/1~2022/12/31:</b><br/>
<img src="https://fxtop.com/php/imggraph.php?C1=USD&C2=TWD&A=1&DD1=&MM1=01&YYYY1=2021&DD2=&MM2=12&YYYY2=2022&LANG=en&CJ=0&MM1Y=1&LARGE=&TR=OFF"><br/>
<b>2020/1/1~2022/12/31:</b><br/>
<img src="https://fxtop.com/php/imggraph.php?C1=USD&C2=TWD&A=1&DD1=&MM1=01&YYYY1=2020&DD2=&MM2=12&YYYY2=2022&LANG=en&CJ=0&MM1Y=1&LARGE=&TR=OFF"><br/>
<b>2000/1/1~2022/12/31:</b><br/>
<img src="https://fxtop.com/php/imggraph.php?C1=USD&C2=TWD&A=1&DD1=&MM1=01&YYYY1=2000&DD2=&MM2=12&YYYY2=2022&LANG=en&CJ=0&MM1Y=1&LARGE=&TR=OFF"><br/>

Mail result

IFTTT

This is my IFTTT applet: https://ifttt.com/applets/SxPJ2fpv-

About the exchange rate history chart

I only find 2 websites provides exchange rate chart to embed in the mail content.

  1. https://fxtop.com/, it provides PNG format chart, I already include it in my IFTTT applet.
  2. https://www.currencyconverterrate.com/, it provides SVG format chart (ex: https://www.currencyconverterrate.com/currencycharts/usd/usd-twd-exchange-rates-history-chart-7-day.svg), but I cannot find a solution to show SVG in gmail. If you find a solution, please let me know, thanks.