## Description This PR introduces WhatsApp Embedded Signup functionality, enabling users to connect their WhatsApp Business accounts through Meta's streamlined OAuth flow without manual webhook configuration. This significantly improves the user experience by automating the entire setup process. **Key Features:** - Embedded signup flow using Facebook SDK and Meta's OAuth 2.0 - Automatic webhook registration and phone number configuration - Enhanced provider selection UI with card-based design - Real-time progress tracking during signup process - Comprehensive error handling and user feedback ## Required Configuration The following environment variables must be configured by administrators before this feature can be used: Super Admin Configuration (via super_admin/app_config?config=whatsapp_embedded) - `WHATSAPP_APP_ID`: The Facebook App ID for WhatsApp Business API integration - `WHATSAPP_CONFIGURATION_ID`: The Configuration ID for WhatsApp Embedded Signup flow (obtained from Meta Developer Portal) - `WHATSAPP_APP_SECRET`: The App Secret for WhatsApp Embedded Signup flow (required for token exchange)  ## How Has This Been Tested? #### Backend Tests (RSpec): - Authentication validation for embedded signup endpoints - Authorization code validation and error handling - Missing business parameter validation - Proper response format for configuration endpoint - Unauthorized access prevention #### Manual Test Cases: - Complete embedded signup flow (happy path) - Provider selection UI navigation - Facebook authentication popup handling - Error scenarios (cancelled auth, invalid business data, API failures) - Configuration presence/absence behavior ## Related Screenshots:      Fixes https://linear.app/chatwoot/issue/CW-2131/spec-for-whatsapp-cloud-channels-sign-in-with-facebook --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: iamsivin <iamsivin@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: Sojan Jose <sojan@pepalo.com>
52 lines
2.2 KiB
Ruby
52 lines
2.2 KiB
Ruby
class SuperAdmin::AppConfigsController < SuperAdmin::ApplicationController
|
|
before_action :set_config
|
|
before_action :allowed_configs
|
|
def show
|
|
# ref: https://github.com/rubocop/rubocop/issues/7767
|
|
# rubocop:disable Style/HashTransformValues
|
|
@app_config = InstallationConfig.where(name: @allowed_configs)
|
|
.pluck(:name, :serialized_value)
|
|
.map { |name, serialized_value| [name, serialized_value['value']] }
|
|
.to_h
|
|
# rubocop:enable Style/HashTransformValues
|
|
@installation_configs = ConfigLoader.new.general_configs.each_with_object({}) do |config_hash, result|
|
|
result[config_hash['name']] = config_hash.except('name')
|
|
end
|
|
end
|
|
|
|
def create
|
|
params['app_config'].each do |key, value|
|
|
next unless @allowed_configs.include?(key)
|
|
|
|
i = InstallationConfig.where(name: key).first_or_create(value: value, locked: false)
|
|
i.value = value
|
|
i.save!
|
|
end
|
|
redirect_to super_admin_settings_path, notice: "App Configs - #{@config.titleize} updated successfully"
|
|
end
|
|
|
|
private
|
|
|
|
def set_config
|
|
@config = params[:config] || 'general'
|
|
end
|
|
|
|
def allowed_configs
|
|
mapping = {
|
|
'facebook' => %w[FB_APP_ID FB_VERIFY_TOKEN FB_APP_SECRET IG_VERIFY_TOKEN FACEBOOK_API_VERSION ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT],
|
|
'shopify' => %w[SHOPIFY_CLIENT_ID SHOPIFY_CLIENT_SECRET],
|
|
'microsoft' => %w[AZURE_APP_ID AZURE_APP_SECRET],
|
|
'email' => ['MAILER_INBOUND_EMAIL_DOMAIN'],
|
|
'linear' => %w[LINEAR_CLIENT_ID LINEAR_CLIENT_SECRET],
|
|
'slack' => %w[SLACK_CLIENT_ID SLACK_CLIENT_SECRET],
|
|
'instagram' => %w[INSTAGRAM_APP_ID INSTAGRAM_APP_SECRET INSTAGRAM_VERIFY_TOKEN INSTAGRAM_API_VERSION ENABLE_INSTAGRAM_CHANNEL_HUMAN_AGENT],
|
|
'whatsapp_embedded' => %w[WHATSAPP_APP_ID WHATSAPP_APP_SECRET WHATSAPP_CONFIGURATION_ID WHATSAPP_API_VERSION],
|
|
'notion' => %w[NOTION_CLIENT_ID NOTION_CLIENT_SECRET]
|
|
}
|
|
|
|
@allowed_configs = mapping.fetch(@config, %w[ENABLE_ACCOUNT_SIGNUP FIREBASE_PROJECT_ID FIREBASE_CREDENTIALS])
|
|
end
|
|
end
|
|
|
|
SuperAdmin::AppConfigsController.prepend_mod_with('SuperAdmin::AppConfigsController')
|