An Internet Computer service for notifications
We use Courier notifications API in order to integrate with different providers.
- Create an account in https://www.courier.com/
- Sign in
- Go to Settings > API Keys
- Generate New API key
Now you need to register your API key in order to let W3NS send notifications on your behalf
dfx canister --wallet=<YOUR_WALLET_PRINCIPAL_ID> call w3ns register_key "(\"<YOUR_COURIER_API_KEY>\")"
W3NS currently supports 3 notifications channels:
Gmail
for emailsTwilio
for SMSFirebase FCM
for push
To set up a Courier Channel:
- Sign in to https://www.courier.com/
- Go to Channels > Add Channel
- Follow the steps for each of the providers that W3NS supports (Gmail, Twilio, Firebase FCM)
For the following steps to work you should already have your Courier's API key registered as well as the Courier's providers configured. Each notification sending method requires a 4000000000 cycles payment in order to cover for cycles consumed.
You can send emails via W3NS by running:
dfx canister --wallet=<YOUR_WALLET_PRINCIPAL_ID> call --with-cycles=4000000000 w3ns send_email "(record { to=\"<EMAIL>\"; subject=\"<SUBJECT>\"; body=\"<BODY>\" })"
You can send SMS via W3NS by running
dfx canister --wallet=<YOUR_WALLET_PRINCIPAL_ID> call --with-cycles=4000000000 w3ns send_sms "(record { to=\"<PHONE_NUMBER>\"; message=\"<MESSAGE>\" })"
You can send Push notifications via W3NS by running
dfx canister --wallet=<YOUR_WALLET_PRINCIPAL_ID> call --with-cycles=4000000000 w3ns send_push "(record { to=\"<FIREBASE_TOKEN>\"; title=\"<SUBJECT>\"; body=\"<BODY>\" })"
To send a push notifcations to users subscribed to a certain topic first you have to create it and subscribe users to it
dfx canister --wallet=<YOUR_WALLET_PRINCIPAL_ID> call w3ns create_topic "(\"<YOUR_TOPIC_NAME>\")"
dfx canister --wallet=<YOUR_WALLET_PRINCIPAL_ID> call w3ns subscribe_user_to_topic "(record { topic=\"<YOUR_TOPIC_NAME>\"; registration_token=\"<USERS_FIREBASE_TOKEN>\" })"
dfx canister --wallet=<YOUR_WALLET_PRINCIPAL_ID> call --with-cycles=4000000000 w3ns send_push_to_topic "(record { title=\"<TITLE>\"; body=\"<BODY>\"; topic=\"<TOPIC_NAME>\" })"
dfx canister --wallet=<YOUR_WALLET_PRINCIPAL_ID> call w3ns unsubscribe_user_from_topic "(record { topic=\"<YOUR_TOPIC_NAME>\"; registration_token=\"<USERS_FIREBASE_TOKEN>\" })"