From 0d5492bc570fc417aaa6ffb0555383b4fdc98c33 Mon Sep 17 00:00:00 2001 From: devchima Date: Wed, 29 Jan 2025 16:01:08 -0500 Subject: [PATCH 1/4] Handle contacts with active postbirth messaging --- go-app-ussd_public_rapidpro.js | 15 ++++++++++++++- src/ussd_public_rapidpro.js | 15 ++++++++++++++- test/ussd_public_rapidpro.test.js | 20 ++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/go-app-ussd_public_rapidpro.js b/go-app-ussd_public_rapidpro.js index fc0b499a..d1115935 100644 --- a/go-app-ussd_public_rapidpro.js +++ b/go-app-ussd_public_rapidpro.js @@ -279,7 +279,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_postbirth_subscription"); + } + else { return self.states.create("state_pregnant"); } }).catch(function(e) { @@ -313,6 +316,16 @@ go.app = function() { }); }); + self.states.add("state_postbirth_subscription", function(name) { + return new EndState(name, { + next: "state_start", + text: $( + "Hello mom! You're getting postbirth messages. Reply with questions, compliments, or " + + "complaints. We'll get back to you soon." + ) + }); + }); + self.states.add("state_pregnant", function(name) { return new MenuState(name, { question: $( diff --git a/src/ussd_public_rapidpro.js b/src/ussd_public_rapidpro.js index 41ab3042..b1d69f5d 100644 --- a/src/ussd_public_rapidpro.js +++ b/src/ussd_public_rapidpro.js @@ -115,7 +115,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_postbirth_subscription"); + } + else { return self.states.create("state_pregnant"); } }).catch(function(e) { @@ -149,6 +152,16 @@ go.app = function() { }); }); + self.states.add("state_postbirth_subscription", function(name) { + return new EndState(name, { + next: "state_start", + text: $( + "Hello mom! You're getting postbirth messages. Reply with questions, compliments, or " + + "complaints. We'll get back to you soon." + ) + }); + }); + self.states.add("state_pregnant", function(name) { return new MenuState(name, { question: $( diff --git a/test/ussd_public_rapidpro.test.js b/test/ussd_public_rapidpro.test.js index e4a4f344..795c3578 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_postbirth_subscription", + reply: + "Hello mom! You're getting postbirth messages. Reply with questions, compliments, or " + + "complaints. We'll get back to you soon." + }) + .run(); + }); it("should welcome the user if they don't have a subscription", function() { return tester .setup(function(api) { From 9fef9a58ec2b28529902b1b709a17b5fc1761585 Mon Sep 17 00:00:00 2001 From: devchima Date: Wed, 29 Jan 2025 16:07:00 -0500 Subject: [PATCH 2/4] change state --- go-app-ussd_public_rapidpro.js | 12 +----------- src/ussd_public_rapidpro.js | 12 +----------- test/ussd_public_rapidpro.test.js | 6 +++--- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/go-app-ussd_public_rapidpro.js b/go-app-ussd_public_rapidpro.js index d1115935..2fc175fb 100644 --- a/go-app-ussd_public_rapidpro.js +++ b/go-app-ussd_public_rapidpro.js @@ -280,7 +280,7 @@ go.app = function() { } else if(_.inRange(_.get(contact, "fields.prebirth_messaging"), 1, 7)) { return self.states.create("state_clinic_subscription"); } else if(_.toUpper(_.get(contact, "fields.postbirth_messaging")) === "TRUE"){ - return self.states.create("state_postbirth_subscription"); + return self.states.create("state_clinic_subscription"); } else { return self.states.create("state_pregnant"); @@ -316,16 +316,6 @@ go.app = function() { }); }); - self.states.add("state_postbirth_subscription", function(name) { - return new EndState(name, { - next: "state_start", - text: $( - "Hello mom! You're getting postbirth messages. Reply with questions, compliments, or " + - "complaints. We'll get back to you soon." - ) - }); - }); - self.states.add("state_pregnant", function(name) { return new MenuState(name, { question: $( diff --git a/src/ussd_public_rapidpro.js b/src/ussd_public_rapidpro.js index b1d69f5d..31db4dd7 100644 --- a/src/ussd_public_rapidpro.js +++ b/src/ussd_public_rapidpro.js @@ -116,7 +116,7 @@ go.app = function() { } else if(_.inRange(_.get(contact, "fields.prebirth_messaging"), 1, 7)) { return self.states.create("state_clinic_subscription"); } else if(_.toUpper(_.get(contact, "fields.postbirth_messaging")) === "TRUE"){ - return self.states.create("state_postbirth_subscription"); + return self.states.create("state_clinic_subscription"); } else { return self.states.create("state_pregnant"); @@ -152,16 +152,6 @@ go.app = function() { }); }); - self.states.add("state_postbirth_subscription", function(name) { - return new EndState(name, { - next: "state_start", - text: $( - "Hello mom! You're getting postbirth messages. Reply with questions, compliments, or " + - "complaints. We'll get back to you soon." - ) - }); - }); - self.states.add("state_pregnant", function(name) { return new MenuState(name, { question: $( diff --git a/test/ussd_public_rapidpro.test.js b/test/ussd_public_rapidpro.test.js index 795c3578..69b38899 100644 --- a/test/ussd_public_rapidpro.test.js +++ b/test/ussd_public_rapidpro.test.js @@ -107,10 +107,10 @@ describe("ussd_public app", function() { }) .start() .check.interaction({ - state: "state_postbirth_subscription", + state: "state_clinic_subscription", reply: - "Hello mom! You're getting postbirth messages. Reply with questions, compliments, or " + - "complaints. We'll get back to you soon." + "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(); }); From 2a71f761db381dfaf9f67fa906e4395e2352f282 Mon Sep 17 00:00:00 2001 From: devchima Date: Thu, 30 Jan 2025 01:45:45 -0500 Subject: [PATCH 3/4] Remoce duplicate test --- test/ussd_public_rapidpro.test.js | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/test/ussd_public_rapidpro.test.js b/test/ussd_public_rapidpro.test.js index 69b38899..e4a4f344 100644 --- a/test/ussd_public_rapidpro.test.js +++ b/test/ussd_public_rapidpro.test.js @@ -94,26 +94,6 @@ 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) { From eff9aa1526ef32ba2bdaea86596b0745a971f843 Mon Sep 17 00:00:00 2001 From: devchima Date: Thu, 30 Jan 2025 01:51:29 -0500 Subject: [PATCH 4/4] Add postbirth --- test/ussd_public_rapidpro.test.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/ussd_public_rapidpro.test.js b/test/ussd_public_rapidpro.test.js index e4a4f344..69b38899 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) {