Skip to content

slack-ruby/slack-ruby-bot-server-mailchimp

Repository files navigation

Slack Ruby Bot Server Mailchimp Extension

Gem Version mongodb postgresql rubocop

A lifecycle extension to slack-ruby-bot-server that subscribes new bot users to a Mailchimp mailing list.

Table of Contents

Usage

Add 'slack-ruby-bot-server-mailchimp' to Gemfile.

gem 'slack-ruby-bot-server-mailchimp'

Configure.

SlackRubyBotServer::Mailchimp.configure do |config|
  config.mailchimp_api_key = ENV['MAILCHIMP_API_KEY'] # defaults to ENV['MAILCHIMP_API_KEY']
  config.mailchimp_list_id = ENV['MAILCHIMP_LIST_ID'] # defaults to ENV['MAILCHIMP_LIST_ID']
end

Users that install the bot are automatically subscribed via bot server lifecycle.

Additional Member Tags

If your Team model responds to .tags, those will be attached to new subscriptions and appear as "tags" in Mailchimp. You can also supplement member tags for new subscriptions through member_tags configuration.

SlackRubyBotServer::Mailchimp.config.member_tags = ['my_bot']

This can be a function that accepts a team and callback options.

SlackRubyBotServer::Mailchimp.config.member_tags = ->(team, options) { [team.tags] }

Additional Profile Information

The default member profile information that appears in Mailchimp under "Profile Information" for each new subscriber contains the user's email address, first and last name from Slack. You can supplement this data with additional_merge_fields.

SlackRubyBotServer::Mailchimp.config.additional_merge_fields = { 'BOT' => 'MyBot' }

This can be a function that accepts a team and callback options.

SlackRubyBotServer::Mailchimp.config.additional_merge_fields = ->(team, options) { { 'TEAM' => team.name } }

Double Opt-In

This integration subscribes users with double opt-in by default. Configure member_status to disable double opt-in. See this doc for more details.

SlackRubyBotServer::Mailchimp.config.member_status = 'subscribed'

Copyright & License

Copyright Daniel Doubrovkine and Contributors, 2019

MIT License