diff --git a/go-app-ussd_public_rapidpro.js b/go-app-ussd_public_rapidpro.js index b7312e2b..b51da7a4 100644 --- a/go-app-ussd_public_rapidpro.js +++ b/go-app-ussd_public_rapidpro.js @@ -291,7 +291,10 @@ go.app = function() { return self.states.create("state_public_subscription"); } else if(_.inRange(_.get(contact, "fields.prebirth_messaging"), 1, 7)) { return self.states.create("state_clinic_subscription"); - } else { + } else if(_.toUpper(_.get(contact, "fields.postbirth_messaging")) === "TRUE"){ + return self.states.create("state_clinic_subscription"); + } + else { return self.states.create("state_pregnant"); } }).catch(function(e) { diff --git a/src/ussd_public_rapidpro.js b/src/ussd_public_rapidpro.js index 1827c89b..eeeb762b 100644 --- a/src/ussd_public_rapidpro.js +++ b/src/ussd_public_rapidpro.js @@ -72,7 +72,10 @@ go.app = function() { return self.states.create("state_public_subscription"); } else if(_.inRange(_.get(contact, "fields.prebirth_messaging"), 1, 7)) { return self.states.create("state_clinic_subscription"); - } else { + } else if(_.toUpper(_.get(contact, "fields.postbirth_messaging")) === "TRUE"){ + return self.states.create("state_clinic_subscription"); + } + else { return self.states.create("state_pregnant"); } }).catch(function(e) { diff --git a/test/ussd_public_rapidpro.test.js b/test/ussd_public_rapidpro.test.js index 4155c90d..22b255e1 100644 --- a/test/ussd_public_rapidpro.test.js +++ b/test/ussd_public_rapidpro.test.js @@ -94,6 +94,26 @@ describe("ussd_public app", function() { }) .run(); }); + it("should give the user compliment/complaint instructions if they're receiving postbirth messages", function() { + return tester + .setup(function(api) { + api.http.fixtures.add( + fixtures_rapidpro.get_contact({ + urn: "whatsapp:27123456789", + exists: true, + fields: {postbirth_messaging: "TRUE"} + }) + ); + }) + .start() + .check.interaction({ + state: "state_clinic_subscription", + reply: + "Hello mom! You can reply to any MomConnect message with a question, compliment or complaint. Our team " + + "will get back to you as soon as they can." + }) + .run(); + }); it("should welcome the user if they don't have a subscription", function() { return tester .setup(function(api) {