###前提・実現したいこと
はじめまして!
現在Slack Botを作成していてどうしても解決できなかったので、質問させていただきます。
**チームに新しくメンバーがジョインした時、そのメンバーにダイレクトメッセージを送信するbotを作成しております。**が、ダイレクトメッセージを送信方法がわからず困っています。いかに点どなたかご教授いただければと思います。
- エラーメッセージの第2引数をどこから引張てくるのか。
- そもそも、team_joinのイベントのみでやりたいことを実現できるのか
よろしくお願いいたします。
###発生している問題・エラーメッセージ
エラーメッセージ Unhandled rejection SlackRTMError: invalid channel id
###該当のソースコード
introduction.js
1var RtmClient = require('../lib/clients/rtm/client'); 2var token = process.env.SLACK_API_TOKEN || 'xxxxxxxxxxxxxxxxxxxxxx'; 3var MemoryDataStore = require('@slack/client').MemoryDataStore; 4var RTM_EVENTS = require('@slack/client').RTM_EVENTS; 5 6var rtm = new RtmClient(token, { 7 // Initialise a data store for our client, this will load additional helper functions for the storing and retrieval of data 8 dataStore: new MemoryDataStore(), 9 // Boolean indicating whether Slack should automatically reconnect after an error response 10 autoReconnect: true, 11 // Boolean indicating whether each message should be marked as read or not after it is processed 12 autoMark: true 13}); 14 15rtm.start(); 16 17rtm.on(RTM_EVENTS.TEAM_JOIN, function(team_join) { 18 //userオブジェクトを取得 19 var joined_user = team_join.user; 20 //userの名前を取得 21 var name = joined_user.name; 22 //userのidを取得 23 var id = joined_user.id; 24 rtm.sendMessage(name+'さん!こんにちは!このslackは〜〜〜です。', id); 25}); 26 27 28
###参考になりそうなレファレンス
https://api.slack.com/types
https://api.slack.com/events
###補足情報(言語/FW/ツール等のバージョンなど)
仕様ライブラリ
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。