LoginSignup
1
5

More than 5 years have passed since last update.

googleカレンダーに指定した文字列が含まれる本日の予定をchatworkで通知する

Last updated at Posted at 2018-06-30

方法

1. googleカレンダーに通知したい文字列が含んだ予定を登録する。

2. カレンダーIDの取得

googleカレンダーの設定でF5をクリックして「カレンダー ID」を入力すれば見つかります。
idCalendar = 'aaaaaaaaa@gmail.com';

3. グループチャットIDの取得

chatwork URLの********の部分
https://www.chatwork.com/#!rid********

4. google apps script でchatwork のライブラリを使用する方法

参考URL http://c-note.chatwork.com/post/69590585422/chatworkapi-gas-library

5. google apps script を実行する

google apps script の使い方
参考URL https://qiita.com/rf_p/items/0535ec495df8f9d2b894

参考コード

function runApp()
{
  idCalendar = 'aaaaaaaaa@gmail.com'; // カレンダー ID
  value = '買い物';
  var dataCalend=CalendarApp.getCalendarById(idCalendar); // IDを指定してカレンダー情報を取得する
  var events=dataCalend.getEventsForDay(new Date(), {search: value}); // 本日の日付と取得したい予定に含まれる文字列の指定

  for (var i=0;i<events.length;i++) {
    var description = events[i].getDescription();
    var title = events[i].getTitle();
  }

  var body = 'message: '+description;

  msgChatwork(body);
}

function msgChatwork(body)
{

  /* チャットワークにメッセージを送る */
  var cwClient = ChatWorkClient.factory({token: 'プロジェクトキー'}); //チャットワークAPI
  cwClient.sendMessage({
    room_id:********, // chatworkのグループチャットのIDを指定する。個人のチャットワークのIDでも可
    body: body
  });
}
1
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
5