Skip to content
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

Merged
merged 2 commits into from
Jun 25, 2023
Merged

Conversation

jainpawan21
Copy link
Member

What change does this PR introduce?

  • Fix version and few minor things in ejs templates
  • Update new provider docs with correct path and steps

Why was this change needed?

Other information (Screenshots)

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jun 23, 2023
Copy link
Contributor

@p-fernandez p-fernandez left a 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",
Copy link
Contributor

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. 🙁

Copy link
Contributor

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

Comment on lines +32 to +33
id: 'id_returned_by_provider',
date: 'current_time'
Copy link
Contributor

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**.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Contributor

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:

Suggested change
```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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Member Author

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?

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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!
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Hurray 🎉, You have successfully added a new provider in Novu!
Hurray 🎉! You have successfully added a new provider in Novu!

@peoray
Copy link
Contributor

peoray commented Jun 23, 2023

Also, would it make sense to have different pages for different providers as a lot of examples here refer to an email provider?
I had the thought of having the main starting code inside of an index.md file and then have sub-pages for email, SMS, etc.

@peoray
Copy link
Contributor

peoray commented Jun 23, 2023

Can we also get the packages from the generator module to have the current versions? Like @novu/stateless and the other devDependencies?

@jainpawan21
Copy link
Member Author

Added version flag with 0.16.0 as value. Could not find a way to extract version from package.json as we don't have novu version specified in root package.json file

@jainpawan21
Copy link
Member Author

Also, would it make sense to have different pages for different providers as a lot of examples here refer to an email provider? I had the thought of having the main starting code inside of an index.md file and then have sub-pages for email, SMS, etc.

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.

@jainpawan21 jainpawan21 added this pull request to the merge queue Jun 25, 2023
Merged via the queue into next with commit 8fe5b66 Jun 25, 2023
17 checks passed
@jainpawan21 jainpawan21 deleted the fix/update-new-provider-doc branch June 25, 2023 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants