Skip to content
This repository has been archived by the owner on Mar 31, 2021. It is now read-only.

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
f-w committed May 12, 2020
1 parent 3f61ea4 commit ed0f2f5
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 24 deletions.
23 changes: 13 additions & 10 deletions common/models/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,19 +773,22 @@ module.exports = function (Subscription) {
Reference: '5eb9e53ac8de837a99fd214a',
OutgoingMessageID: '789091964',
MessageNumber: '59255257',
hash: '1111'
notifyBCSwiftKey: '1111'
}
*/
let smsConfig = Subscription.app.get('sms')
if (smsConfig.swift && smsConfig.swift.notifyBCSwiftKey) {
if (
smsConfig.swift.notifyBCSwiftKey !==
options.httpContext.req.body.notifyBCSwiftKey
) {
let error = new Error('Forbidden')
error.status = 403
throw error
}
if (!smsConfig || !smsConfig.swift || !smsConfig.swift.notifyBCSwiftKey) {
let error = new Error('Forbidden')
error.status = 403
throw error
}
if (
smsConfig.swift.notifyBCSwiftKey !==
options.httpContext.req.body.notifyBCSwiftKey
) {
let error = new Error('Forbidden')
error.status = 403
throw error
}
let whereClause = {
state: 'confirmed',
Expand Down
62 changes: 48 additions & 14 deletions docs/_docs/config-sms.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,82 @@ title: SMS
permalink: /docs/config-sms/
---

*NotifyBC* depends on underlying SMS service providers to deliver SMS messages. The supported service providers are
_NotifyBC_ depends on underlying SMS service providers to deliver SMS messages. The supported service providers are

* [Twilio](https://twilio.com/) (default)
* [Swift](https://www.swiftsmsgateway.com)
- [Twilio](https://twilio.com/) (default)
- [Swift](https://www.swiftsmsgateway.com)

Only one service provider can be chosen per installation. To change service provider, add following *smsServiceProvider* config object to file */server/config.local.js*
Only one service provider can be chosen per installation. To change service provider, add following _smsServiceProvider_ config object to file _/server/config.local.js_

```js
module.exports = {
...
smsServiceProvider: 'swift'
}
```

The rest configs are service provider specific. You should have an account with the chosen service provider before proceeding.

## Twilio
Add *sms.twilio* config object to file */server/config.local.js*

Add _sms.twilio_ config object to file _/server/config.local.js_

```js
module.exports = {
sms: {
twilio: {
accountSid: '<AccountSid>',
authToken: '<AuthToken>',
fromNumber: '<FromNumber>'
}
}
fromNumber: '<FromNumber>',
},
},
}
```
Obtain *\<AccountSid\>*, *\<AuthToken\>* and *\<FromNumber\>* from your Twilio account.

Obtain _\<AccountSid\>_, _\<AuthToken\>_ and _\<FromNumber\>_ from your Twilio account.

## Swift
Add *sms.swift* config object to file */server/config.local.js*

Add _sms.swift_ config object to file _/server/config.local.js_

```js
module.exports = {
sms: {
swift: {
accountKey: '<accountKey>'
}
}
accountKey: '<accountKey>',
},
},
}
```
Obtain *\<accountKey\>* from your Swift account.

Obtain _\<accountKey\>_ from your Swift account.

### Unsubscription by replying a keyword

With Swift short code, sms user can unsubscribe by replying to a sms message with a keyword. The keyword must be pre-registered with Swift.

To enable this feature,

1. Generate a random string, hereafter referred to as *\<randomly-genereated-string\>*
2. Add it to _sms.swift.notifyBCSwiftKey_ in file _/server/config.local.js_

```js
module.exports = {
sms: {
swift: {
...
notifyBCSwiftKey: '<randomly-genereated-string>',
},
},
}
```
3. Go to Swift web admin console, click *Number Management* tab
4. Click *Launch* button next to *Manage Short Code Keywords*
5. Click *Features* button next to the registered keyword(s). A keyword may have multiple entries. In such case do this for each entry.
6. Click *Redirect To Webpage* tab in the popup window
7. Enter following information in the tab
* set *URL* to *\<NotifyBCHttpHost\>/api/subscriptions/swift*, where *\<NotifyBCHttpHost\>* is NotifyBC HTTP host name and should be the same as [HTTP Host](../config-httpHost/) config
* set *Method* to *POST*
* set *Custom Parameter 1 Name* to *notifyBCSwiftKey*
* set *Custom Parameter 1 Value* to *\<randomly-genereated-string\>*
8. Click *Save Changes* button and then *Done*

0 comments on commit ed0f2f5

Please sign in to comment.