Skip to content

feat(integrations): add FormyChat create lead action#167

Open
RishadAlam wants to merge 6 commits into
mainfrom
feat/formyChat
Open

feat(integrations): add FormyChat create lead action#167
RishadAlam wants to merge 6 commits into
mainfrom
feat/formyChat

Conversation

@RishadAlam
Copy link
Copy Markdown
Member

Description

This PR adds a new FormyChat action integration to Bit Integrations, including backend API routes, execution logic, and full frontend setup/edit flows. Users can now connect FormyChat, select a widget, map fields (including custom values), and create leads from automation flows.

Motivation & Context

FormyChat users need a native way to send captured conversation/form data into automation workflows without manual glue code. This change introduces first-class support so lead creation can be configured directly in Bit Integrations with field and meta mapping support.

Related Links: (if applicable)

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📚 Documentation update
  • ⚡ Improvement
  • 🔄 Code refactor

Key Changes

Backend

  • Added FormyChat controller endpoints for authorization check, widget refresh, and widget field refresh.
  • Added widget field preparation logic, including support for custom dropdown insertion and normalized field options.
  • Added FormyChat record execution helper to build request payloads from mapped fields and meta mappings.
  • Added action execution via formy_chat_create_lead hook with integration logging for success/error outcomes.
  • Added FormyChat routes for formy_chat_authorize, refresh_formy_chat_widgets, and refresh_formy_chat_widget_fields.

Frontend

  • Added new FormyChat integration creation flow with 3-step UI (authorize, map, save).
  • Added edit flow support for existing FormyChat integrations.
  • Added widget and widget-field refresh helpers with loading state and error/success feedback.
  • Added field mapping UI with support for form fields, custom values, and smart tags.
  • Added meta mapping UI (meta key + value) including custom value support and validation.

Integration Registry & Navigation

  • Added FormyChat to integration selection list in new flow action picker.
  • Added FormyChat integration wiring in new integration, edit integration, and integration info screens.
  • Added FormyChat entry to backend integration name registry.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Tests added/updated
  • Documentation updated if needed
  • README updated if needed

Changelog

  • New Actions: FormyChat integration now supports creating leads from automation flows (Pro).
  • Feature: You can select FormyChat widgets and map form fields directly to FormyChat lead fields.
  • Improvement: Optional meta key mapping is now available to pass extra structured lead data to FormyChat.

- Implemented FormyChat integration in the frontend, including components for editing and configuring the integration.
- Added FormyChatController and RecordApiHelper in the backend to handle authorization and widget management.
- Created routes for FormyChat actions.
- Introduced common functions for handling FormyChat-specific logic.
- Added necessary UI components for field mapping and integration layout.
- Included FormyChat assets and static data for integration actions.
Copilot AI review requested due to automatic review settings May 19, 2026 10:43
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new integration for FormyChat, including backend controllers, API helpers, and a complete frontend UI for authorization and field mapping. The review feedback identifies critical issues regarding PHP 8.0+ compatibility, specifically the need to validate potential WP_Error objects using is_wp_error() before accessing them as arrays or objects to prevent fatal errors. Additionally, the feedback suggests adopting more defensive programming patterns by using null coalescing operators when handling field mapping data to avoid undefined property warnings.

Comment thread backend/Actions/FormyChat/FormyChatController.php
Comment thread backend/Actions/FormyChat/RecordApiHelper.php Outdated
Comment thread backend/Actions/FormyChat/RecordApiHelper.php Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new FormyChat "Create Lead" action integration. Backend introduces a controller (with authorization/widget/field refresh endpoints), a RecordApiHelper that builds the request payload and dispatches via a formy_chat_create_lead filter hook, and route registrations. Frontend wires up the new integration into the action picker, NewInteg, EditInteg, and IntegInfo dispatchers, and provides Authorization, Layout, FieldMap, MetaFieldMap, common helpers, and Edit components.

Changes:

  • Backend FormyChat controller, RecordApiHelper, routes, and trigger-name registration.
  • Frontend FormyChat integration suite (auth, layout, field/meta mapping, common helpers, edit screen).
  • Registration of FormyChat in SelectAction, NewInteg, EditInteg, and IntegInfo dispatch maps.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
backend/Core/Util/AllTriggersName.php Registers FormyChat in the integrations registry.
backend/Actions/FormyChat/Routes.php Declares the 3 REST routes for the new integration.
backend/Actions/FormyChat/FormyChatController.php Handles authorize/widget/field requests and dispatches execution.
backend/Actions/FormyChat/RecordApiHelper.php Builds field/meta payloads and triggers the formy_chat_create_lead hook.
frontend/src/components/Flow/New/SelectAction.jsx Adds FormyChat to the action selection list.
frontend/src/components/AllIntegrations/NewInteg.jsx Lazy-loads and routes to the new FormyChat creation flow.
frontend/src/components/AllIntegrations/EditInteg.jsx Lazy-loads EditFormyChat for the edit flow.
frontend/src/components/AllIntegrations/IntegInfo.jsx Adds FormyChat to the info/auth display dispatcher.
frontend/src/components/AllIntegrations/FormyChat/FormyChat.jsx 3-step new-integration screen orchestrator.
frontend/src/components/AllIntegrations/FormyChat/EditFormyChat.jsx Edit screen for existing FormyChat integrations.
frontend/src/components/AllIntegrations/FormyChat/FormyChatAuthorization.jsx Step-1 authorization UI.
frontend/src/components/AllIntegrations/FormyChat/FormyChatIntegLayout.jsx Action/widget selection plus field/meta mapping UI.
frontend/src/components/AllIntegrations/FormyChat/FormyChatFieldMap.jsx Row UI for mapping a form field to a FormyChat field.
frontend/src/components/AllIntegrations/FormyChat/FormyChatMetaFieldMap.jsx Row UI for mapping meta keys.
frontend/src/components/AllIntegrations/FormyChat/FormyChatCommonFunc.js Shared helpers (input, refresh, validation, meta map ops).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/src/components/AllIntegrations/FormyChat/FormyChatFieldMap.jsx Outdated
Comment thread backend/Actions/FormyChat/FormyChatController.php
Comment thread frontend/src/components/AllIntegrations/FormyChat/FormyChatAuthorization.jsx Outdated
- Implemented SureDash integration with multiple steps for configuration.
- Created SureDashAuthorization component for handling authorization with SureDash.
- Developed SureDashIntegLayout for managing integration actions and field mappings.
- Added SureDashFieldMap for mapping form fields to SureDash fields.
- Introduced utility functions for handling input and refreshing data from SureDash.
- Created static data for integration actions and field requirements.
- Added SVG and WEBP images for SureDash integration representation.
Copilot AI review requested due to automatic review settings May 20, 2026 09:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 28 changed files in this pull request and generated 9 comments.

Comments suppressed due to low confidence (1)

backend/Core/Util/AllTriggersName.php:134

  • AllTriggersName is used to populate the trigger list when Pro isn’t active (see backend/Triggers/TriggerController.php). SureDash is being registered here as a trigger, but this PR adds it as an action integration. If SureDash isn’t a trigger, it should not be listed in AllTriggersName (or it should be added to the appropriate actions registry instead).
            'SureMail'                       => ['name' => 'SureMail',  'isPro' => true, 'is_active' => false],
            'SureForms'                      => ['name' => 'SureForms',  'isPro' => true, 'is_active' => false],
            'SureFeedback'                   => ['name' => 'SureFeedback',  'isPro' => true, 'is_active' => false],
            'SureDash'                       => ['name' => 'SureDash',  'isPro' => true, 'is_active' => false],
            'SureMembers'                    => ['name' => 'SureMembers',  'isPro' => true, 'is_active' => false],
            'EventsCalendar'                 => ['name' => 'The Events Calendar',  'isPro' => true, 'is_active' => false],

Comment on lines 158 to 163
{ type: 'ZagoMail' },
{ type: 'Drip' },
{ type: 'Newsletter' },
{ type: 'SureDash' },
{ type: 'SureMembers' },
{ type: 'Mailster' },
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. The PR title/description will be updated to reflect both FormyChat and SureDash integrations.

{ type: 'MailerPress' },
{ type: 'CreatorLms' },
{ type: 'FluentCart' },
{ type: 'FormyChat' },
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logo exists at frontend/src/resource/img/integ/formyChat.webp. GetLogo is called with extension="webp" so it resolves correctly — no missing asset.

Comment on lines 601 to +605
return <WhatsAppAuthorization whatsAppConf={integrationConf} step={1} isInfo />
case 'Newsletter':
return <NewsletterAuthorization newsletterConf={integrationConf} step={1} isInfo />
case 'SureDash':
return <SureDashAuthorization sureDashConf={integrationConf} step={1} isInfo />
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SureDashAuthorization already accepts isInfo and gates all interactive controls (authorize button, Next button) behind {!isInfo && ...}. Calling handlers in info mode is not possible.

Comment on lines +7 to +15
export default function SureDashAuthorization({
sureDashConf,
setSureDashConf,
step,
nextPage,
isLoading,
setIsLoading,
setSnackbar
}) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isInfo is already accepted as a prop (line 15) and all interactive elements are wrapped in {!isInfo && (...)}. The name input also uses disabled={isInfo}. This matches other Authorization components.

break;
}

$responseType = isset($response['success']) && $response['success'] ? 'success' : 'error';
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Added is_wp_error() guard on line 93 of SureDash/RecordApiHelper.php:

$responseType = !is_wp_error($response) && isset($response['success']) && $response['success'] ? 'success' : 'error';

'Eventin' => ['name' => 'Eventin', 'isPro' => true, 'is_active' => false],
'EVF' => ['name' => 'Everest Forms', 'isPro' => true, 'is_active' => false],
'FormGent' => ['name' => 'FormGent', 'isPro' => true, 'is_active' => false],
'FormyChat' => ['name' => 'FormyChat', 'isPro' => true, 'is_active' => false],
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Both FormyChat (line 49) and SureDash (line 132) have been removed from AllTriggersName.php — they are actions, not triggers.

Comment on lines +52 to +69
export const checkMappedFields = formyChatConf => {
const mappedFields = formyChatConf?.field_map
? formyChatConf.field_map.filter(
mappedField =>
!mappedField.formField ||
!mappedField.formyChatField ||
(mappedField.formField === 'custom' && !mappedField.customValue)
)
: []
if (mappedFields.length > 0) return false
if (!formyChatConf?.widgetId || !formyChatConf?.mainAction) return false

const partialMeta = (formyChatConf?.meta_map || []).filter(
m => (m.formField && !m.metaKey) || (!m.formField && m.metaKey)
)
if (partialMeta.length > 0) return false

return true
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Extended the meta validation filter to also block rows where formField === 'custom' but customValue is empty:

const partialMeta = (formyChatConf?.meta_map || []).filter(
  m =>
    (m.formField && !m.metaKey) ||
    (!m.formField && m.metaKey) ||
    (m.formField === 'custom' && !m.customValue)
)

Comment on lines +1 to +10
import { useEffect } from 'react'
import { create } from 'mutative'
import MultiSelect from 'react-multiple-select-dropdown-lite'
import { useRecoilValue } from 'recoil'
import { $appConfigState } from '../../../GlobalStates'
import { __ } from '../../../Utils/i18nwrap'
import Loader from '../../Loaders/Loader'
import { checkIsPro, getProLabel } from '../../Utilities/ProUtilHelpers'
import { addFieldMap } from '../IntegrationHelpers/IntegrationHelpers'
import {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Removed unused useEffect import and unused formID/setSnackbar props from FormyChatIntegLayout.

Comment on lines +29 to +32
if (!\defined('SUREDASHBOARD_POST_TYPE')) {
wp_send_json_error(__('SureDash is not activated or not installed', 'bit-integrations'), 400);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Removed the redundant !\defined('SUREDASHBOARD_POST_TYPE') check from refreshSpaces()self::isExists() on the line above already covers it.

Copilot AI review requested due to automatic review settings May 20, 2026 10:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 28 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

backend/Core/Util/AllTriggersName.php:134

  • AllTriggersName::allTriggersName() is used to populate the trigger list for non‑Pro installs (see backend/Triggers/TriggerController.php:35-37). Registering SureDash here will incorrectly surface it as a trigger, even though this PR adds it as an action integration. Please remove SureDash from this trigger registry.
            'SureMail'                       => ['name' => 'SureMail',  'isPro' => true, 'is_active' => false],
            'SureForms'                      => ['name' => 'SureForms',  'isPro' => true, 'is_active' => false],
            'SureFeedback'                   => ['name' => 'SureFeedback',  'isPro' => true, 'is_active' => false],
            'SureDash'                       => ['name' => 'SureDash',  'isPro' => true, 'is_active' => false],
            'SureMembers'                    => ['name' => 'SureMembers',  'isPro' => true, 'is_active' => false],
            'EventsCalendar'                 => ['name' => 'The Events Calendar',  'isPro' => true, 'is_active' => false],

Comment on lines 46 to 51
'Eventin' => ['name' => 'Eventin', 'isPro' => true, 'is_active' => false],
'EVF' => ['name' => 'Everest Forms', 'isPro' => true, 'is_active' => false],
'FormGent' => ['name' => 'FormGent', 'isPro' => true, 'is_active' => false],
'FormyChat' => ['name' => 'FormyChat', 'isPro' => true, 'is_active' => false],
'FluentAffiliate' => ['name' => 'FluentAffiliate', 'isPro' => true, 'is_active' => false],
'WCAffiliate' => ['name' => 'WC Affiliate', 'isPro' => true, 'is_active' => false],
Comment on lines 158 to 163
{ type: 'ZagoMail' },
{ type: 'Drip' },
{ type: 'Newsletter' },
{ type: 'SureDash' },
{ type: 'SureMembers' },
{ type: 'Mailster' },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants