Skip to content

Commit

Permalink
feat(inbox): added ability to integrate new integration to inbox easyly
Browse files Browse the repository at this point in the history
closes #3672
  • Loading branch information
batamar committed Oct 13, 2022
1 parent 4a1e43d commit 7f19de3
Show file tree
Hide file tree
Showing 84 changed files with 2,129 additions and 3,043 deletions.
228 changes: 0 additions & 228 deletions packages/erxes-ui/src/constants/integrations.ts
Expand Up @@ -69,23 +69,8 @@ export const INTEGRATION_KINDS = {
MESSENGER: 'messenger',
FACEBOOK_MESSENGER: 'facebook-messenger',
FACEBOOK_POST: 'facebook-post',
GMAIL: 'gmail',
NYLAS_GMAIL: 'nylas-gmail',
NYLAS_IMAP: 'nylas-imap',
NYLAS_OUTLOOK: 'nylas-outlook',
NYLAS_EXCHANGE: 'nylas-exchange',
NYLAS_OFFICE365: 'nylas-office365',
NYLAS_YAHOO: 'nylas-yahoo',
FORMS: 'lead',
CALLPRO: 'callpro',
TWITTER_DM: 'twitter-dm',
CHATFUEL: 'chatfuel',
SMOOCH_TELEGRAM: 'smooch-telegram',
SMOOCH_VIBER: 'smooch-viber',
SMOOCH_LINE: 'smooch-line',
SMOOCH_TWILIO: 'smooch-twilio',
WHATSAPP: 'whatsapp',
TELNYX: 'telnyx',
WEBHOOK: 'webhook',
BOOKING: 'booking',
ALL: [
Expand All @@ -96,25 +81,8 @@ export const INTEGRATION_KINDS = {
value: 'facebook-messenger'
},
{ text: 'Facebook Post', value: 'facebook-post' },
{ text: 'Gmail', value: 'gmail' },
{ text: 'Webhook', value: 'webhook' },
{ text: 'Callpro', value: 'callpro' },
{ text: 'Chatfuel', value: 'chatfuel' },

{ text: 'WhatsApp by Smooch', value: 'whatsapp' },
{ text: 'Telegram by Smooch', value: 'smooch-telegram' },
{ text: 'Viber by Smooch', value: 'smooch-viber' },
{ text: 'Line by Smooch', value: 'smooch-line' },
{ text: 'SMS Twilio by Smooch', value: 'smooch-twilio' },

{ text: 'IMAP by Nylas', value: 'nylas-imap' },
{ text: 'Gmail by Nylas', value: 'nylas-gmail' },
{ text: 'Office 365 by Nylas', value: 'nylas-office365' },
{ text: 'Microsoft Exchange by Nylas', value: 'nylas-exchange' },
{ text: 'Outlook by Nylas', value: 'nylas-outlook' },
{ text: 'Yahoo by Nylas', value: 'nylas-yahoo' },

{ text: 'SMS by Telnyx', value: 'telnyx' },
{ text: 'Booking', value: 'booking' }
]
};
Expand Down Expand Up @@ -204,163 +172,6 @@ export const INTEGRATIONS = [
category:
'All integrations, For support teams, Marketing automation, Phone and video, Conversation'
},
{
name: 'Gmail',
description: __(
'Connect a company email address such as sales@mycompany.com or info@mycompany.com'
),
inMessenger: false,
isAvailable: false,
kind: 'gmail',
logo: '/images/integrations/gmail.png',
createModal: 'gmail',
createUrl: '/settings/integrations/createGmail',
category:
'All integrations, For support teams, Email marketing, Marketing automation, Conversation'
},
{
name: 'IMAP by Nylas',
description:
'Connect a company email address such as sales@mycompany.com or info@mycompany.com',
inMessenger: false,
isAvailable: false,
kind: 'nylas-imap',
logo: '/images/integrations/email.png',
createModal: 'nylas-imap',
createUrl: '/settings/integrations/nylas-imap',
category:
'All integrations, For support teams, Marketing automation, Email marketing'
},
{
name: 'Office 365 by Nylas',
description:
'Connect a company email address such as sales@mycompany.com or info@mycompany.com',
inMessenger: false,
isAvailable: false,
kind: 'nylas-office365',
logo: '/images/integrations/office365.png',
createModal: 'nylas-office365',
createUrl: 'nylas/oauth2/callback',
category:
'All integrations, For support teams, Marketing automation, Email marketing, Conversation'
},
{
name: 'Gmail by Nylas',
description:
'Connect a company email address such as sales@mycompany.com or info@mycompany.com',
inMessenger: false,
isAvailable: false,
kind: 'nylas-gmail',
logo: '/images/integrations/gmail.png',
createModal: 'nylas-gmail',
createUrl: 'nylas/oauth2/callback',
category:
'All integrations, For support teams, Email marketing, Marketing automation, Conversation'
},
{
name: 'Microsoft Exchange by Nylas',
description:
'Connect a company email address such as sales@mycompany.com or info@mycompany.com',
inMessenger: false,
isAvailable: false,
kind: 'nylas-exchange',
logo: '/images/integrations/exchange.png',
createModal: 'nylas-exchange',
createUrl: '/settings/integrations/nylas-exchange',
category:
'All integrations, For support teams, Email marketing, Marketing automation, Conversation'
},
{
name: 'Outlook by Nylas',
description:
'Connect a company email address such as sales@mycompany.com or info@mycompany.com',
inMessenger: false,
isAvailable: false,
kind: 'nylas-outlook',
logo: '/images/integrations/outlook.png',
createModal: 'nylas-outlook',
createUrl: '/settings/integrations/nylas-outlook',
category:
'All integrations, For support teams, Marketing automation, Email marketing'
},
{
name: 'Yahoo by Nylas',
description:
'Connect a company email address such as sales@mycompany.com or info@mycompany.com',
inMessenger: false,
isAvailable: false,
kind: 'nylas-yahoo',
logo: '/images/integrations/yahoo.png',
createModal: 'nylas-yahoo',
createUrl: '/settings/integrations/nylas-yahoo',
category:
'All integrations, For support teams, Marketing automation, Email marketing, Conversation'
},
{
name: 'Chatfuel',
description: 'Connect your chatfuel account',
inMessenger: false,
isAvailable: false,
kind: 'chatfuel',
logo: '/images/integrations/chatfuel.png',
createModal: 'chatfuel',
category:
'All integrations, For support teams, Marketing automation, Messaging, Conversation'
},
{
name: 'WhatsApp by Smooch',
description: 'Get a hold of your Whatsapp messages through your Team Inbox',
inMessenger: false,
isAvailable: false,
kind: 'whatsapp',
logo: '/images/integrations/whatsapp.png',
createModal: 'whatsapp',
category: 'All integrations, For support teams, Messaging, Conversation'
},
{
name: 'Telegram by Smooch',
description:
'Connect to your Telegram, a cloud-based mobile and desktop messaging app',
inMessenger: false,
isAvailable: false,
kind: 'smooch-telegram',
logo: '/images/integrations/telegram.png',
createModal: 'smooch-telegram',
category: 'All integrations, For support teams, Messaging, Conversation'
},
{
name: 'Viber by Smooch',
description: 'Connect Viber to your Team Inbox',
inMessenger: false,
isAvailable: false,
kind: 'smooch-viber',
logo: '/images/integrations/viber.png',
createModal: 'smooch-viber',
category:
'All integrations, For support teams, Marketing automation, Messaging, Conversation'
},
{
name: 'Line by Smooch',
description: 'See and reply to Line messages in your Team Inbox',
inMessenger: false,
isAvailable: false,
kind: 'smooch-line',
logo: '/images/integrations/line.png',
createModal: 'smooch-line',
category:
'All integrations, For support teams, For sales teams, For marketing teams, Marketing automation, Messaging, Phone and video, Conversation'
},
{
name: 'SMS by Telnyx',
description: 'Connect your Telnyx account to send & receive SMS',
inMessenger: false,
isAvailable: false,
kind: 'telnyx',
logo: '/images/integrations/telnyx.png',
createModal: 'telnyx',
category:
'All integrations, For support teams, For marketing teams, Conversation'
},
{
name: 'Incoming Webhook',
description: 'Configure incoming webhooks',
Expand All @@ -372,45 +183,6 @@ export const INTEGRATIONS = [
category:
'All integrations, For support teams, Conversation, Marketing automation'
}
// {
// name: 'Outgoing Webhook',
// description: 'Configure outging webhooks',
// inMessenger: false,
// isAvailable: false,
// kind: 'outgoing-webhook',
// logo: '/images/integrations/webhook.png',
// createModal: 'outgoing-webhook',
// category:
// 'All integrations, For support teams, Conversation, Marketing automation'
// }
];

export const INTEGRATION_FILTERS = [
{
name: 'Featured',
items: [
'All integrations',
'For support teams',
'For sales teams',
'For marketing teams'
]
},

{
name: 'Works with',
items: ['Conversation', 'Forms']
},
{
name: 'Categories',
items: [
'Email marketing',
'Messaging',
'Marketing automation',
'Phone and video',
'Social media',
'Surveys and Feedback'
]
}
];

export const WEBHOOK_DOC_URL =
Expand Down
1 change: 1 addition & 0 deletions packages/erxes-ui/src/utils/core.tsx
Expand Up @@ -26,6 +26,7 @@ export const loadComponent = (scope, module) => {

// Initialize the container, it may provide shared modules
await container.init(__webpack_share_scopes__.default);

const factory = await window[scope].get(module);

const Module = factory();
Expand Down
17 changes: 14 additions & 3 deletions packages/plugin-contacts-api/src/coc/utils.ts
Expand Up @@ -6,11 +6,11 @@ import { COC_LEAD_STATUS_TYPES } from '../constants';
import {
fetchSegment,
sendCoreMessage,
sendInboxMessage,
sendSegmentsMessage,
sendTagsMessage
} from '../messageBroker';
import { companySchema } from '../models/definitions/companies';
import { KIND_CHOICES } from '../models/definitions/constants';
import { customerSchema } from '../models/definitions/customers';

export interface ICountBy {
Expand Down Expand Up @@ -144,10 +144,21 @@ export const countByLeadStatus = async (qb): Promise<ICountBy> => {
return counts;
};

export const countByIntegrationType = async (qb): Promise<ICountBy> => {
export const countByIntegrationType = async (
subdomain: string,
qb
): Promise<ICountBy> => {
const counts: ICountBy = {};

for (const type of KIND_CHOICES.ALL) {
const kindsMap = await sendInboxMessage({
subdomain,
data: {},
action: 'getIntegrationKinds',
isRPC: true,
defaultValue: {}
});

for (const type of Object.keys(kindsMap)) {
await qb.buildAllQueries();
await qb.integrationTypeFilter(type);

Expand Down
@@ -1,4 +1,4 @@
import { KIND_CHOICES, TAG_TYPES } from '../../models/definitions/constants';
import { TAG_TYPES } from '../../models/definitions/constants';
import { Builder as BuildQuery, IListArgs } from '../../coc/customers';
import {
countByBrand,
Expand All @@ -12,16 +12,27 @@ import {
moduleRequireLogin
} from '@erxes/api-utils/src/permissions';
import { IContext } from '../../connectionResolver';
import { sendFormsMessage } from '../../messageBroker';
import { sendFormsMessage, sendInboxMessage } from '../../messageBroker';
interface ICountParams extends IListArgs {
only: string;
source: string;
}

const countByIntegrationType = async (qb): Promise<ICountBy> => {
const countByIntegrationType = async (
subdomain: string,
qb
): Promise<ICountBy> => {
const counts: ICountBy = {};

for (const type of KIND_CHOICES.ALL) {
const kindsMap = await sendInboxMessage({
subdomain,
data: {},
action: 'getIntegrationKinds',
isRPC: true,
defaultValue: {}
});

for (const type of Object.keys(kindsMap)) {
await qb.buildAllQueries();
await qb.integrationTypeFilter(type);

Expand Down Expand Up @@ -151,7 +162,7 @@ const customerQueries = {
break;

case 'byIntegrationType':
counts.byIntegrationType = await countByIntegrationType(qb);
counts.byIntegrationType = await countByIntegrationType(subdomain, qb);
break;

default:
Expand Down

0 comments on commit 7f19de3

Please sign in to comment.