Skip to content

Commit

Permalink
Merge pull request #635 from praekeltfoundation/sigma-1155-CAPI-regis…
Browse files Browse the repository at this point in the history
…tration-USSD

Sigma 1155 capi registration ussd
  • Loading branch information
Buhle79 authored Jul 18, 2024
2 parents 537e4b8 + a0c26f7 commit fe4978c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions go-app-ussd_clinic_rapidpro.js
Original file line number Diff line number Diff line change
Expand Up @@ -1261,8 +1261,10 @@ go.app = function() {
return self.hub
.send_whatsapp_template_message(msisdn, template_name, media)
.then(function(data) {
self.im.user.set_answer("preferred_channel", data.preferred_channel);
self.im.user.set_answer("status_id", data.status_id);
console.log("Template Data: ", data);
self.im.user.answers.preferred_channel = data.preferred_channel;
self.im.user.answers.status_id = data.status_id;
console.log("ID: ", self.im.user.answers.status_id);
if (data.preferred_channel == "SMS") {
return self.rapidpro.get_global_flag("sms_registrations_enabled")
.then(function(sms_registration_enabled) {
Expand Down Expand Up @@ -1421,11 +1423,12 @@ go.app = function() {

self.add("state_get_whatsapp_template_status", function(name, opts) {
var status_id = self.im.user.answers.status_id;

console.log(">>>>>>", status_id);
return self.hub
.get_whatsapp_template_status(status_id)
.then(function(data) {
self.im.user.set_answer("preferred_channel", data.preferred_channel);
console.log("Status Data: ", data);
self.im.user.answers.preferred_channel = data.preferred_channel;
return self.states.create("state_trigger_rapidpro_flow");
}).catch(function(e) {
// Go to error state after 3 failed HTTP requests
Expand Down
11 changes: 7 additions & 4 deletions src/ussd_clinic_rapidpro.js
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,10 @@ go.app = function() {
return self.hub
.send_whatsapp_template_message(msisdn, template_name, media)
.then(function(data) {
self.im.user.set_answer("preferred_channel", data.preferred_channel);
self.im.user.set_answer("status_id", data.status_id);
console.log("Template Data: ", data);
self.im.user.answers.preferred_channel = data.preferred_channel;
self.im.user.answers.status_id = data.status_id;
console.log("ID: ", self.im.user.answers.status_id);
if (data.preferred_channel == "SMS") {
return self.rapidpro.get_global_flag("sms_registrations_enabled")
.then(function(sms_registration_enabled) {
Expand Down Expand Up @@ -1160,11 +1162,12 @@ go.app = function() {

self.add("state_get_whatsapp_template_status", function(name, opts) {
var status_id = self.im.user.answers.status_id;

console.log(">>>>>>", status_id);
return self.hub
.get_whatsapp_template_status(status_id)
.then(function(data) {
self.im.user.set_answer("preferred_channel", data.preferred_channel);
console.log("Status Data: ", data);
self.im.user.answers.preferred_channel = data.preferred_channel;
return self.states.create("state_trigger_rapidpro_flow");
}).catch(function(e) {
// Go to error state after 3 failed HTTP requests
Expand Down

0 comments on commit fe4978c

Please sign in to comment.