-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
📝 Up^date doc #348
Merged
Merged
📝 Up^date doc #348
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,7 +1,7 @@ | ||||||
--- | ||||||
title: "Build a connector" | ||||||
description: "We welcome all contributions to Panora; from small UI enhancements to brand new integrations. We love seeing community members level up and give people power-ups!" | ||||||
icon: "star" | ||||||
title: 'Build a connector' | ||||||
description: 'We welcome all contributions to Panora; from small UI enhancements to brand new integrations. We love seeing community members level up and give people power-ups!' | ||||||
icon: 'star' | ||||||
--- | ||||||
|
||||||
## Introduction | ||||||
|
@@ -14,30 +14,27 @@ We made a docker file that builds Panora from sources, specifically to help you | |||||
|
||||||
<Steps> | ||||||
|
||||||
<Step title="Copy env variables"> | ||||||
```bash | ||||||
cp .env.example .env | ||||||
``` | ||||||
</Step> | ||||||
|
||||||
<Step title="Removed previously installed dependencies"> | ||||||
```bash | ||||||
rm -rf node_modules .pnpm-store ./packages/api/dist ./packages/api/node_modules ./apps/webapp/node_modules ./apps/frontend_snippet/node_modules | ||||||
``` | ||||||
</Step> | ||||||
<Step title="Copy env variables">```bash cp .env.example .env ```</Step> | ||||||
|
||||||
<Step title="Mac Users only:"> | ||||||
```bash | ||||||
echo -e "node-linker=hoisted\npackage-import-method=clone-or-copy" > .npmrc | ||||||
``` | ||||||
</Step> | ||||||
|
||||||
<Step title="Removed previously installed dependencies"> | ||||||
```bash rm -rf node_modules .pnpm-store ./packages/api/dist | ||||||
./packages/api/node_modules ./apps/webapp/node_modules | ||||||
./apps/frontend_snippet/node_modules ``` | ||||||
</Step> | ||||||
|
||||||
<Step title="Mac Users only:"> | ||||||
```bash echo -e "node-linker=hoisted\npackage-import-method=clone-or-copy" > | ||||||
.npmrc ``` | ||||||
</Step> | ||||||
|
||||||
<Step title="Start the Dockerfile"> | ||||||
```bash | ||||||
docker compose -f docker-compose.dev.yml up | ||||||
``` | ||||||
|
||||||
That's all! You can find the backend and other services running at their usual location. Editing code locally will immediately reflect. | ||||||
That's all! You can find the backend and other services running at their usual location. Editing code locally will immediately reflect. | ||||||
|
||||||
</Step> | ||||||
</Steps> | ||||||
|
@@ -56,109 +53,30 @@ First choose wisely which vertical the 3rd party belongs to among these: | |||||
- ticketing | ||||||
- accounting | ||||||
- ats | ||||||
- file-storage | ||||||
- file_storage | ||||||
- hris | ||||||
- marketing-automation | ||||||
- marketing_automation | ||||||
|
||||||
For the sake of the guide, now on we'll consider adding a 3rd party belonging to the `crm` vertical. | ||||||
|
||||||
## 1. Adding a new connection service for your 3rd Party | ||||||
|
||||||
Create a new folder with the name of your 3rd party. Let's call it _my3rdParty_. | ||||||
|
||||||
`cd @core/connections/crm/services/my3rdParty` | ||||||
|
||||||
Create a new file containing the core logic of your service. | ||||||
|
||||||
`cd @core/connections/crm/services/my3rdParty/my3rdParty.service.ts` | ||||||
|
||||||
It must implement the `ICrmConnectionService` interface. | ||||||
|
||||||
```ts | ||||||
export interface ICrmConnectionService { | ||||||
handleCallback(opts: CallbackParams): Promise<Connection>; | ||||||
handleTokenRefresh(opts: RefreshParams): Promise<any>; | ||||||
} | ||||||
|
||||||
export type CallbackParams = { | ||||||
linkedUserId: string; | ||||||
projectId: string; | ||||||
code: string; | ||||||
location?: string; //for zoho | ||||||
}; | ||||||
|
||||||
export type RefreshParams = { | ||||||
connectionId: string; | ||||||
refreshToken: string; | ||||||
account_url?: string; | ||||||
}; | ||||||
``` | ||||||
|
||||||
```ts | ||||||
import { Injectable } from "@nestjs/common"; | ||||||
import { | ||||||
CallbackParams, | ||||||
ICrmConnectionService, | ||||||
RefreshParams, | ||||||
} from "../../types"; | ||||||
|
||||||
@Injectable() | ||||||
export class My3rdPartyConnectionService implements ICrmConnectionService { | ||||||
constructor( | ||||||
private prisma: PrismaService, | ||||||
private logger: LoggerService, | ||||||
private env: EnvironmentService, | ||||||
private cryptoService: EncryptionService, | ||||||
private registry: ServiceRegistry | ||||||
) { | ||||||
this.logger.setContext(My3rdPartyConnectionService.name); | ||||||
this.registry.registerService("insert_the_name_of_your_3rd_party", this); | ||||||
} | ||||||
|
||||||
async handleCallback(opts: CallbackParams) { | ||||||
return; | ||||||
} | ||||||
async handleTokenRefresh(opts: RefreshParams) { | ||||||
return; | ||||||
} | ||||||
} | ||||||
``` | ||||||
## 1. Look into the `packages/shared/src/utils.ts` file and check if the provider you want to build has its metadata set inside the `providersConfig` object. | ||||||
|
||||||
Now that you have the structure, check other 3rd parties implementations under `/@core/connections/crm/services` to build your functions. | ||||||
It should be available (if not contact Panora team) with active field set to false meaning the integration has not been built. | ||||||
|
||||||
## 2. Enable your connection service to handle oAuth granting access | ||||||
Actually an integration is built in 2 parts : | ||||||
|
||||||
Add your service to the `CrmConnectionModule` under @core/connections/crm/crm.connection.module.ts module ! | ||||||
- the authentication part (oauth, api key, basic etc) which is built by the Panora team | ||||||
- the service integration where the mapping is created with our unified model which is what you'll build | ||||||
|
||||||
```ts | ||||||
@Module({ | ||||||
imports: [WebhookModule], | ||||||
providers: [ | ||||||
CrmConnectionsService, | ||||||
PrismaService, | ||||||
ServiceConnectionRegistry, | ||||||
LoggerService, | ||||||
WebhookService, | ||||||
EnvironmentService, | ||||||
EncryptionService, | ||||||
FreshsalesConnectionService, | ||||||
HubspotConnectionService, | ||||||
ZohoConnectionService, | ||||||
ZendeskConnectionService, | ||||||
PipedriveConnectionService, | ||||||
//INSERT YOUR SERVICE HERE | ||||||
My3rdPartyConnectionService, | ||||||
], | ||||||
exports: [CrmConnectionsService], | ||||||
}) | ||||||
export class CrmConnectionModule {} | ||||||
``` | ||||||
## 2. Build your provider service | ||||||
|
||||||
# You want to map a common object to your new 3rd Party ? 👩🎤 | ||||||
|
||||||
_Ie: Contact, Ticket, Deal, Company ..._ | ||||||
|
||||||
For the sake of this guide, let's map the common object `contact` under `crm` vertical to _my3rdParty_ just defined just before. | ||||||
For the sake of this guide, let's map the common object `contact` under `crm` vertical to _my3rdParty_ (in reality it would be a real 3rd party name). | ||||||
|
||||||
### DISCLAIMER: an integration is considered valid when all common objects have been mapped. Then, after the PR is accepted we'll be able to set `active` field to `true` inside `providersConfig`. | ||||||
|
||||||
## 1. Add a new service to map your common object to your 3rd party | ||||||
|
||||||
|
@@ -168,7 +86,7 @@ Create a new service folder with the name of your 3rd party. Let's call it _my3r | |||||
|
||||||
You'll now create 3 files. | ||||||
|
||||||
`index.ts` _where your service is created and direct interaction with your 3rd party API is handled_ | ||||||
`index.ts` \_where your service is created and direct interaction with your 3rd party API is handled | ||||||
|
||||||
It must implement the `IContactService` interface. | ||||||
|
||||||
|
@@ -197,8 +115,7 @@ export class My3rdPartyService implements IContactService { | |||||
this.logger.setContext( | ||||||
CrmObject.contact.toUpperCase() + ':' + My3rdPartyService.name, | ||||||
); | ||||||
this.registry.registerService('my3rdPartyService', this); | ||||||
|
||||||
this.registry.registerService('my3rdParty', this); | ||||||
} | ||||||
async addContact( | ||||||
contactData: 3rdPartyContactInput, | ||||||
|
@@ -273,80 +190,14 @@ export class My3rdPartyMapper implements IContactMapper { | |||||
|
||||||
Check other implementations under `/crm/contacts/services` to fill the core functions. | ||||||
|
||||||
## 2. Enable your service | ||||||
|
||||||
`cd crm/contact/types/mappingsTypes.ts` | ||||||
## 2. Enable your new service | ||||||
|
||||||
Add your new 3rd party service to the `contactUnificationMapping` object. | ||||||
To make sure the service is enabled, dependencies and imports must be added. | ||||||
We built a script that does it in seconds. | ||||||
|
||||||
```ts | ||||||
// ADD YOUR IMPORT HERE | ||||||
import { My3rdPartyContactMapper } from '@contact/services/my3rdParty/mappers'; | ||||||
|
||||||
const hubspotContactMapper = new HubspotContactMapper(); | ||||||
const zendeskContactMapper = new ZendeskContactMapper(); | ||||||
const zohoContactMapper = new ZohoContactMapper(); | ||||||
const pipedriveContactMapper = new PipedriveContactMapper(); | ||||||
const freshSalesContactMapper = new FreshsalesContactMapper(); | ||||||
// INSERT BELOW YOUR 3rd PARTY HERE | ||||||
const my3rdPartyContactMapper = new My3rdPartyContactMapper(); | ||||||
|
||||||
|
||||||
export const contactUnificationMapping = { | ||||||
hubspot: { | ||||||
unify: hubspotContactMapper.unify, | ||||||
desunify: hubspotContactMapper.desunify, | ||||||
}, | ||||||
pipedrive: { | ||||||
unify: pipedriveContactMapper.unify, | ||||||
desunify: pipedriveContactMapper.desunify, | ||||||
}, | ||||||
zoho: { | ||||||
unify: zohoContactMapper.unify, | ||||||
desunify: zohoContactMapper.desunify, | ||||||
}, | ||||||
...., | ||||||
...., | ||||||
// INSERT BELOW YOUR 3rd PARTY HERE | ||||||
my3rdParty: { | ||||||
unify: my3rdPartyContactMapper.unify, | ||||||
desunify: my3rdPartyContactMapper.desunify, | ||||||
}, | ||||||
}; | ||||||
``` | ||||||
|
||||||
Don't forget to add your service you've defined at step 1 inside the module under `/crm/contacts/contact.module.ts`. | ||||||
`pnpm run validate-connectors --vertical="crm" --objectType="contact"` | ||||||
|
||||||
```ts | ||||||
@Module({ | ||||||
imports: [ | ||||||
BullModule.registerQueue({ | ||||||
name: "webhookDelivery", | ||||||
}), | ||||||
], | ||||||
controllers: [ContactController], | ||||||
providers: [ | ||||||
ContactService, | ||||||
PrismaService, | ||||||
LoggerService, | ||||||
FieldMappingService, | ||||||
SyncService, | ||||||
WebhookService, | ||||||
EncryptionService, | ||||||
ServiceRegistry, | ||||||
/* PROVIDERS SERVICES */ | ||||||
FreshSalesService, | ||||||
ZendeskService, | ||||||
ZohoService, | ||||||
PipedriveService, | ||||||
HubspotService, | ||||||
//INSERT YOUR SERVICE HERE | ||||||
My3rdPartyService, | ||||||
], | ||||||
exports: [SyncService], | ||||||
}) | ||||||
export class ContactModule {} | ||||||
``` | ||||||
The script will automatically scan the `/crm/contact/services` folder and detect any new service folder so all dependencies and imports are updated across the codebase. | ||||||
|
||||||
### Congrats Hero ! 🦸♀️ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the space before the exclamation mark. - ### Congrats Hero ! 🦸♀️
+ ### Congrats Hero! 🦸♀️ Committable suggestion
Suggested change
|
||||||
|
||||||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the space before the question mark.
Committable suggestion