You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-22Lines changed: 22 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -33,14 +33,14 @@ Airhorn makes it easy to send SMS, SMTP, Webhooks, and mobile push notifications
33
33
* Built using [writr](https://github.org/jaredwray/writr) markdown based content.
34
34
* Subscriptions - You can now specify a subscription for a profile and track it. Data is stored in MongoDB and Posgres will be supported soon.
35
35
36
-
##ESM and Node Version Support
36
+
# ESM and Node Version Support
37
37
38
38
This package is ESM only and tested on the current lts version and its previous. Please don't open issues for questions regarding CommonJS / ESM or previous Nodejs versions. To learn more about using ESM please read this from `sindresorhus`: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
39
39
40
40
41
41
# Library API
42
42
43
-
###`send()`
43
+
## `send()`
44
44
45
45
The `send()` function, located in `airhorn.ts`, is used to send notifications. It accepts the following parameters:
46
46
@@ -51,7 +51,7 @@ The `send()` function, located in `airhorn.ts`, is used to send notifications. I
51
51
*`data` (any): The information to pass to the message. This parameter is typically a data object or a string. The data can include the raw message to be sent, or it can be used to populate a message template.
52
52
*`languageCode` (string): The language code of the message template to be sent.
53
53
54
-
###`sendSMTP()`
54
+
## `sendSMTP()`
55
55
56
56
The `sendSMTP()` function, located in `airhorn.ts`, is used to send `SMTP` notifications. It accepts the following parameters:
57
57
@@ -61,7 +61,7 @@ The `sendSMTP()` function, located in `airhorn.ts`, is used to send `SMTP` notif
61
61
*`data` (any): The information to pass to the message. This parameter is typically a data object or a string. The data can include the raw message to be sent, or it can be used to populate a message template.
62
62
*`languageCode` (string): The language code of the message template to be sent.
63
63
64
-
###`sendSMS()`
64
+
## `sendSMS()`
65
65
66
66
The `sendSMS()` function, located in `airhorn.ts`, is used to send `SMS` notifications. It accepts the following parameters:
67
67
@@ -71,7 +71,7 @@ The `sendSMS()` function, located in `airhorn.ts`, is used to send `SMS` notific
71
71
*`data` (any): The information to pass to the message. This parameter is typically a data object or a string. The data can include the raw message to be sent, or it can be used to populate a message template.
72
72
*`languageCode` (string): The language code of the message template to be sent.
73
73
74
-
###`sendWebhook()`
74
+
## `sendWebhook()`
75
75
76
76
The `sendWebhook()` function, located in `airhorn.ts`, is used to send `Webhook` notifications. It accepts the following parameters:
77
77
@@ -81,7 +81,7 @@ The `sendWebhook()` function, located in `airhorn.ts`, is used to send `Webhook`
81
81
*`data` (any): The information to pass to the message. This parameter is typically a data object or a string. The data can include the raw message to be sent, or it can be used to populate a message template.
82
82
*`languageCode` (string): The language code of the message template to be sent.
83
83
84
-
###`sendMobilePush()`
84
+
## `sendMobilePush()`
85
85
86
86
The `sendMobilePush()` function, located in `airhorn.ts`, is used to send `Mobile Push` notifications. It accepts the following parameters:
87
87
@@ -91,7 +91,7 @@ The `sendMobilePush()` function, located in `airhorn.ts`, is used to send `Mobil
91
91
*`data` (any): The information to pass to the message. This parameter is typically a data object or a string. The data can include the raw message to be sent, or it can be used to populate a message template.
92
92
*`languageCode` (string): The language code of the message template to be sent.
93
93
94
-
###`options`
94
+
## `options`
95
95
96
96
The `AirhornOptions` enables you to configure the settings of Airhorn. It accepts the following parameters:
97
97
@@ -121,17 +121,17 @@ const airhorn = new Airhorn({
121
121
});
122
122
```
123
123
124
-
###Templates
124
+
# Templates
125
125
126
126
This library supports the use of templates to easily send formatted messages to different providers. Sample templates can be found in `test/templates` within the subdirectories `cool-multi-lingual`, `generic-template-foo`, and `multiple-types-bar`.
127
127
128
128
By default, `Config` will look for templates at `./templates`. However, this path can be manually adjusted if needed.
129
129
130
-
####Language Localization
130
+
# Language Localization
131
131
132
132
With templates, users can easily send messages in different languages. A sample architecture for language localized templates can be found in the `cool-multi-lingual` directory within `test/templates`. This directory contains folders for English and Spanish language codes, 'en' and 'es' respectively. Each of these directories contains SMS, SMTP, and Webhook templates in the appropriate language. To send notifications in a specific language, users can simply provide the appropriate `languageCode` parameter to the `send()` function.
133
133
134
-
####Template Overrides
134
+
# Template Overrides
135
135
136
136
When looking at the sample templates, we can see that some of them support word substitution. For example, the generic SMTP template looks like this:
137
137
@@ -145,11 +145,11 @@ subject: Generic Hello
145
145
146
146
To substitute the appropriate text for `firstName`, `lastName`, and `email`, users can provide the appropriate data to the `send()` function. This data is then passed to the template and rendered automatically.
147
147
148
-
###Examples for using this library
148
+
# Examples for using this library
149
149
150
150
This library can be used to easily send a variety of notifications. In this section, we'll cover how to implement some simple use cases.
151
151
152
-
####Sending a simple email
152
+
## Sending a simple email
153
153
154
154
Using the send function, we can email '[email protected]' from '[email protected]' using the generic template 'generic-template-foo'. We'll also use the provider type `AirhornProviderType.SMTP` to indicate that we're sending an email:
155
155
@@ -159,7 +159,7 @@ const airhorn = new Airhorn();
In this example, we'll send a message using multiple email providers:
174
174
@@ -197,11 +197,11 @@ This library supports sending notifications via email, SMS, and Mobile Push for
197
197
198
198
In this section, we'll describe how to use each of these notification services.
199
199
200
-
###Email providers
200
+
## Email providers
201
201
202
202
This library supports sending emails via AWS SES and Twilio Sendgrid.
203
203
204
-
####AWS SES
204
+
## AWS SES
205
205
206
206
After configuring your system to use AWS SES, you can easily use `airhorn` to send emails. In this example, we'll email '[email protected]' from '[email protected]' using the email template 'generic-template-foo'. We'll list the provider type as `AirhornProviderType.SMTP` to indicate that we're sending an email:
To send emails via Twilio Sendgrid, first update the `TWILIO_SENDGRID_API_KEY` value via `AirhornOptions`. Then, we can use the same syntax as above to send an email through Twilio Sendgrid:
Now that you've set up your workspace, you're ready to contribute changes to the `airhorn` repository you can refer to the [CONTRIBUTING](CONTRIBUTING.md) guide. If you have any questions please feel free to ask by creating an issue and label it `question`.
293
293
294
-
##Setting up your Development Environment
294
+
# Setting up your Development Environment
295
295
296
296
To set up your development environment, you'll need the following dependencies:
297
297
* Node.js (latest)
@@ -318,6 +318,6 @@ If you are using `nvm` you can run the following:
318
318
nvm use && npm i && npm run test:services:start && npm test
319
319
```
320
320
321
-
##Licensing
321
+
# Licensing
322
322
323
323
This project is licensed under [MIT](LICENSE) and copyright by Jared Wray 2021-future.
0 commit comments