-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Labels
Description
I am trying to create a simple bot for greetings. According to the instructions in the Slack API, I need to process the "team_join" event. But while processing it, I get the error:
12:49:21 web.1 | E, [2020-12-28T12:49:21.032375 #2829] ERROR -- : Slack::Web::Api::Errors::SlackError: invalid_array_arg
12:49:21 web.1 | /home/deadalice/.rvm/gems/ruby-2.7.2/gems/slack-ruby-client-0.15.1/lib/slack/web/faraday/response/raise_error.rb:16:in `on_complete'
12:49:21 web.1 | /home/deadalice/.rvm/gems/ruby-2.7.2/gems/faraday-1.1.0/lib/faraday/response.rb:12:in `block in call'
12:49:21 web.1 | /home/deadalice/.rvm/gems/ruby-2.7.2/gems/faraday-1.1.0/lib/faraday/response.rb:65:in `on_complete'
12:49:21 web.1 | /home/deadalice/.rvm/gems/ruby-2.7.2/gems/faraday-1.1.0/lib/faraday/response.rb:11:in `call'
12:49:21 web.1 | /home/deadalice/.rvm/gems/ruby-2.7.2/gems/faraday-1.1.0/lib/faraday/response.rb:11:in `call'
12:49:21 web.1 | /home/deadalice/.rvm/gems/ruby-2.7.2/gems/faraday-1.1.0/lib/faraday/request/url_encoded.rb:25:in `call'
This is the code I use to process event:
SlackRubyBotServer::Events.configure do |config|
config.on :event, ['event_callback', 'team_join'] do |event|
client = Slack::Web::Client.new(token: team_token(event[:event][:team]))
user = client.users_info(user: event[:event][:user])
unless user[:user][:is_bot] || team.users.exists?(user_id: event[:event][:user])
team.users.create(user_id: event[:event][:user], user_name: user[:user][:name])
#event.answer(blocks: WelcomeMessage.blocks) unless debug?
event.logger.info "team_join #{event[:event][:user]} #{user[:user][:name]}"
end
nil
end
endPlease ignore the commented line: this is my simple wrapper to quickly respond in events and in both cases it was commented out.
It is interesting that by copying the same code into the "member_join_channel" handler, everything works good.
Reactions are currently unavailable