-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
fix: update how to add new provider docs #3653
Conversation
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.
These changes should make creating a provider easier for any contributor. This was a great move.
🌟
@@ -5,7 +5,7 @@ | |||
|
|||
{ | |||
"name": "@novu/<%= name %>", | |||
"version": "^0.12.0", | |||
"version": "^0.16.0", |
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.
Yesterday I was looking for a way to inject the version in the EJS template dynamically from our package.json version. Didn't find anything yet. 🙁
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.
It should just be "version": "^0.16.0"
without the ^
otherwise it won't build, that has been my experience
id: 'id_returned_by_provider', | ||
date: 'current_time' |
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.
I like this. 👏🏻
|
||
## Creating a Novu provider package | ||
Novu currently supports five channels `in_app`, `push`, `email`, `chat` and `sms`. For `in_app` we support only our own provider, so new provider cannot be added for this channel. For other four channels we support integration of external providers. This guide will help in adding new provider for any of these 4 channels. **In this guide, we are adding a new provider for email channel, but all of the mentioned steps are similar for other channels as well**. |
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.
Novu currently supports five channels `in_app`, `push`, `email`, `chat` and `sms`. For `in_app` we support only our own provider, so new provider cannot be added for this channel. For other four channels we support integration of external providers. This guide will help in adding new provider for any of these 4 channels. **In this guide, we are adding a new provider for email channel, but all of the mentioned steps are similar for other channels as well**. | |
Novu currently supports five channels `in_app`, `push`, `email`, `chat` and `sms`. For `in_app` we support only our own provider, so new providers cannot be added for this channel. For the other four channels we support integration of external providers. This guide will help in adding new providers for any of these 4 channels. **In this guide, we are adding a new provider for email channel, but all of the mentioned steps are similar for other channels as well**. |
|
||
To set up the repository, run the initial setup command: | ||
|
||
```zsh | ||
```bash |
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.
If you want to be agnostic of the shell used we can simply leave it as:
```bash | |
```shell |
|
||
After the project is initialized creating a new provider is achievable with the following. | ||
After the project is initialized, new provider can be generated using below command. |
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.
After the project is initialized, new provider can be generated using below command. | |
After the project is initialized, a new provider can be generated using below command. |
|
||
```ts | ||
> In above example, we have given our provider name as `example-provider` for simplicity. If provider you want to add have name as `twilio`, don't use `twilio-provider` as name, instead use `twilio` only. If one provider supports multiple channels like `infobip` supports both `sms` and `email` channels, use `infobip-email` or `infobip-sms` to differentiate these providers. |
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.
Great addition!
``` | ||
|
||
### Email Provider | ||
### Sample Email Provider (SendGrid) |
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.
Does this make sense now?
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.
Not much sense, just a example that sendMessage function will be changed,
I think in last steps I should mention that checkout sendgrid provider to know other details?
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.
That could be a good option.
Now, build the project again using this command | ||
|
||
```bash | ||
npm run setup:project |
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.
npm run setup:project | |
pnpm run setup:project |
Run below command in the root of project to run providers test | ||
|
||
```bash | ||
npm run test:providers |
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.
npm run test:providers | |
pnpm run test:providers |
|
||
The last step is to initialize the handler in the factory located in `apps/api/src/app/events/services/mail-service/mail.factory.ts` | ||
Hurray 🎉, You have successfully added a new provider in Novu! |
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.
Hurray 🎉, You have successfully added a new provider in Novu! | |
Hurray 🎉! You have successfully added a new provider in Novu! |
Also, would it make sense to have different pages for different providers as a lot of examples here refer to an email provider? |
Can we also get the packages from the generator module to have the current versions? Like |
Added version flag with |
Earlier I also thought to add separate docs for each channel. But I feel all steps are similar for each channel. I have mentioned this information in introduction. |
What change does this PR introduce?
Why was this change needed?
Other information (Screenshots)