Skip to content

Commit

Permalink
Merge branch 'next' into idempotency-impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Cliftonz authored Oct 26, 2023
2 parents 7890302 + b21b24c commit d0dc15a
Show file tree
Hide file tree
Showing 28 changed files with 919 additions and 1,102 deletions.
30 changes: 30 additions & 0 deletions apps/api/src/app/integrations/dtos/credentials.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,34 @@ export class CredentialsDto implements ICredentials {
@IsString()
@IsOptional()
ipPoolName?: string;

@ApiPropertyOptional()
@IsString()
@IsOptional()
apiKeyRequestHeader?: string;

@ApiPropertyOptional()
@IsString()
@IsOptional()
secretKeyRequestHeader?: string;

@ApiPropertyOptional()
@IsString()
@IsOptional()
idPath?: string;

@ApiPropertyOptional()
@IsString()
@IsOptional()
datePath?: string;

@ApiPropertyOptional()
@IsBoolean()
@IsOptional()
authenticateByToken?: boolean;

@ApiPropertyOptional()
@IsString()
@IsOptional()
authenticationTokenKey?: string;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions docs/docs/channels/sms/generic-sms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generic SMS

The Custom SMS provider allows you to send transactional SMS messages through your own SMS service using the Novu Platform.

## Getting Started

To use the Custom SMS provider within the SMS channel, you'll need to have your own SMS service or access to a service provider that supports sending SMS messages using an API endpoint. You will also need to configure the following parameters in the Custom SMS integration on the Novu platform:

- `BaseUrl`: The endpoint URL of your SMS service provider.
- `API Key Request Header`: The request header used for authenticating with the SMS service ex. `x-api-key`.
- `API Key`: Your API key for authenticating with the SMS service.
- `Secret Key Request Header` (optional): If your SMS service requires a secret key for authentication, specify the request header used for authenticating with the SMS service.
- `Secret Key` (optional): If your SMS service requires a secret key for authentication.
- `Id Path`: The path to the message ID in the response from the SMS service.
- `Date Path`: The path to the message date in the response from the SMS service.
- `From`: The sender information you want to appear on the SMS (e.g., your company name or phone number).
- `Authenticate by token` (optional): If your SMS service requires authentication by token, set this to `true` this option will use the `API key` and `Secret key` to get the access token.
- `Auth URL` (optional): The endpoint URL of your SMS service provider for authentication.
- `Authentication Token Key` (optional): The key of the authentication token in the response from the SMS service.

## Setting Up Custom SMS Integration with Novu

Follow these steps to create a Custom SMS integration with Novu:

- **Visit the Integrations Store Page on Novu:** Log in to your Novu account and navigate to the "Integrations Store" page.
- **Locate Custom SMS Provider:** You will find "Custom SMS" under SMS Section and click on it to open the integration setup.
- **Enter Your SMS Service Credentials:** In the integration setup, provide the following information:
- `BaseUrl`: Fill in the endpoint URL of your SMS service provider.
- `API Key Request Header`: Specify the request header used for authenticating with the SMS service.
- `API Key`: Enter your API key for authentication.
- `Secret Key Request Header` (optional): If your SMS service requires a secret key, specify the request header used for authenticating with the SMS service.
- `Secret Key` (optional): If your SMS service requires a secret key, enter it here.
- `From`: Specify the sender information you want to display on the SMS messages.
- **Activate the Integration:** Click on the "Disabled" button to switch it to "Active."

Once you've completed these steps, you can send notifications using the Custom SMS provider through Novu's platform.
6 changes: 6 additions & 0 deletions libs/dal/src/repositories/integration/integration.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ const integrationSchema = new Schema<IntegrationDBModel>(
redirectUrl: Schema.Types.String,
hmac: Schema.Types.Boolean,
ipPoolName: Schema.Types.String,
apiKeyRequestHeader: Schema.Types.String,
secretKeyRequestHeader: Schema.Types.String,
idPath: Schema.Types.String,
datePath: Schema.Types.String,
authenticateByToken: Schema.Types.Boolean,
authenticationTokenKey: Schema.Types.String,
},
active: {
type: Schema.Types.Boolean,
Expand Down
9 changes: 9 additions & 0 deletions libs/shared/src/consts/providers/channels/sms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
termiiConfig,
africasTalkingConfig,
sendchampConfig,
genericSmsConfig,
clickSendConfig,
bandwidthConfig,
} from '../credentials';
Expand Down Expand Up @@ -181,6 +182,14 @@ export const smsProviders: IProviderConfig[] = [
docReference: 'https://docs.novu.co/channels-and-providers/sms/sendchamp',
logoFileName: { light: 'sendchamp.svg', dark: 'sendchamp.svg' },
},
{
id: SmsProviderIdEnum.GenericSms,
displayName: `Generic SMS`,
channel: ChannelTypeEnum.SMS,
credentials: genericSmsConfig,
docReference: 'https://docs.novu.co/channels/sms/generic-sms',
logoFileName: { light: 'generic-sms.svg', dark: 'generic-sms.svg' },
},
{
id: SmsProviderIdEnum.Clicksend,
displayName: `Clicksend`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,3 +806,83 @@ export const bandwidthConfig: IConfigCredentials[] = [
},
...smsConfigBase,
];

export const genericSmsConfig: IConfigCredentials[] = [
{
key: CredentialsKeyEnum.BaseUrl,
displayName: 'Base URL',
type: 'string',
required: true,
},
{
key: CredentialsKeyEnum.ApiKeyRequestHeader,
displayName: 'API Key Request Header',
type: 'string',
description: 'The name of the header attribute to use for the API key ex. (X-API-KEY, apiKey, ...)',
required: true,
},
{
key: CredentialsKeyEnum.ApiKey,
displayName: 'API Key',
type: 'string',
description: 'The value of the header attribute to use for the API key.',
required: true,
},
{
key: CredentialsKeyEnum.SecretKeyRequestHeader,
displayName: 'Secret Key Request Header',
type: 'string',
description: 'The name of the header attribute to use for the secret key ex. (X-SECRET-KEY, secretKey, ...)',
required: false,
},
{
key: CredentialsKeyEnum.SecretKey,
displayName: 'Secret Key',
type: 'string',
description: 'The value of the header attribute to use for the secret key',
required: false,
},
{
key: CredentialsKeyEnum.IdPath,
displayName: 'Id Path',
type: 'string',
value: 'data.id',
description: 'The path to the id field in the response data ex. (id, message.id, ...)',
required: true,
},
{
key: CredentialsKeyEnum.DatePath,
displayName: 'Date Path',
type: 'string',
value: 'data.date',
description: 'The path to the date field in the response data ex. (date, message.date, ...)',
required: true,
},
{
key: CredentialsKeyEnum.AuthenticateByToken,
displayName: 'Authenticate by token',
type: 'switch',
description: 'If enabled, the API key and secret key will be sent as a token in the Authorization header',
required: true,
},
{
key: CredentialsKeyEnum.Domain,
displayName: 'Auth URL',
type: 'string',
description: 'The URL to use for authentication in case the Authenticate by token option is enabled',
required: false,
tooltip: {
text: 'The URL to use for authentication in case the Authenticate by token option is enabled',
when: true,
},
},
{
key: CredentialsKeyEnum.AuthenticationTokenKey,
displayName: 'Authentication Token Key',
type: 'string',
description:
'The name of the header attribute to use for the authentication token ex. (X-AUTH-TOKEN, auth-token, ...)',
required: false,
},
...smsConfigBase,
];
7 changes: 7 additions & 0 deletions libs/shared/src/consts/providers/provider.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export enum CredentialsKeyEnum {
RedirectUrl = 'redirectUrl',
Hmac = 'hmac',
IpPoolName = 'ipPoolName',
ApiKeyRequestHeader = 'apiKeyRequestHeader',
SecretKeyRequestHeader = 'secretKeyRequestHeader',
IdPath = 'idPath',
DatePath = 'datePath',
AuthenticateByToken = 'authenticateByToken',
AuthenticationTokenKey = 'authenticationTokenKey',
}

export enum EmailProviderIdEnum {
Expand Down Expand Up @@ -72,6 +78,7 @@ export enum SmsProviderIdEnum {
AfricasTalking = 'africas-talking',
Novu = 'novu-sms',
Sendchamp = 'sendchamp',
GenericSms = 'generic-sms',
Clicksend = 'clicksend',
Bandwidth = 'bandwidth',
}
Expand Down
6 changes: 6 additions & 0 deletions libs/shared/src/entities/integration/credential.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ export interface ICredentials {
redirectUrl?: string;
hmac?: boolean;
ipPoolName?: string;
apiKeyRequestHeader?: string;
secretKeyRequestHeader?: string;
idPath?: string;
datePath?: string;
authenticateByToken?: boolean;
authenticationTokenKey?: string;
}
4 changes: 4 additions & 0 deletions novu.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@
{
"name": "🔔 @novu/maqsam",
"path": "providers/maqsam"
},
{
"name": "🔔 @novu/generic-sms",
"path": "providers/generic-sms"
}
],
"settings": {
Expand Down
1 change: 1 addition & 0 deletions packages/application-generic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@novu/fcm": "^0.20.0",
"@novu/firetext": "^0.20.0",
"@novu/forty-six-elks": "^0.20.0",
"@novu/generic-sms": "^0.20.0",
"@novu/gupshup": "^0.20.0",
"@novu/infobip": "^0.20.0",
"@novu/kannel": "^0.20.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { GenericSmsProvider } from '@novu/generic-sms';
import { ChannelTypeEnum, ICredentials } from '@novu/shared';
import { BaseSmsHandler } from './base.handler';

export class GenericSmsHandler extends BaseSmsHandler {
constructor() {
super('generic-sms', ChannelTypeEnum.SMS);
}

buildProvider(credentials: ICredentials) {
this.provider = new GenericSmsProvider({
baseUrl: credentials.baseUrl,
apiKey: credentials.apiKey,
secretKey: credentials.secretKey,
from: credentials.from,
apiKeyRequestHeader: credentials.apiKeyRequestHeader,
secretKeyRequestHeader: credentials.secretKeyRequestHeader,
idPath: credentials.idPath,
datePath: credentials.datePath,
domain: credentials.domain,
authenticateByToken: credentials.authenticateByToken,
authenticationTokenKey: credentials.authenticationTokenKey,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export * from './sendchamp.handler';
export * from './clicksend.handler';
export * from './bandwidth.handler';
export * from './novu.handler';
export * from './generic-sms.handler';
2 changes: 2 additions & 0 deletions packages/application-generic/src/factories/sms/sms.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
ClicksendSmsHandler,
BandwidthHandler,
NovuSmsHandler,
GenericSmsHandler,
} from './handlers';

export class SmsFactory implements ISmsFactory {
Expand All @@ -45,6 +46,7 @@ export class SmsFactory implements ISmsFactory {
new ClicksendSmsHandler(),
new BandwidthHandler(),
new NovuSmsHandler(),
new GenericSmsHandler(),
];

getHandler(integration: IntegrationEntity) {
Expand Down
Loading

0 comments on commit d0dc15a

Please sign in to comment.