From 124ed5cbf058aaefb20b27524edeba20efadd099 Mon Sep 17 00:00:00 2001 From: buhle79 Date: Thu, 18 Jul 2024 15:24:55 +0200 Subject: [PATCH] Fix undefined error on get whatsapp status --- go-app-ussd_clinic_rapidpro.js | 3 +-- src/ussd_clinic_rapidpro.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/go-app-ussd_clinic_rapidpro.js b/go-app-ussd_clinic_rapidpro.js index c3aba3a2..1a5d183c 100644 --- a/go-app-ussd_clinic_rapidpro.js +++ b/go-app-ussd_clinic_rapidpro.js @@ -1262,6 +1262,7 @@ go.app = function() { .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); if (data.preferred_channel == "SMS") { return self.rapidpro.get_global_flag("sms_registrations_enabled") .then(function(sms_registration_enabled) { @@ -1425,8 +1426,6 @@ go.app = function() { .get_whatsapp_template_status(status_id) .then(function(data) { self.im.user.set_answer("preferred_channel", data.preferred_channel); - self.im.user.set_answer("status", data.status); - return self.states.create("state_trigger_rapidpro_flow"); }).catch(function(e) { // Go to error state after 3 failed HTTP requests diff --git a/src/ussd_clinic_rapidpro.js b/src/ussd_clinic_rapidpro.js index e332c9a6..34a083bc 100644 --- a/src/ussd_clinic_rapidpro.js +++ b/src/ussd_clinic_rapidpro.js @@ -1001,6 +1001,7 @@ go.app = function() { .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); if (data.preferred_channel == "SMS") { return self.rapidpro.get_global_flag("sms_registrations_enabled") .then(function(sms_registration_enabled) { @@ -1164,8 +1165,6 @@ go.app = function() { .get_whatsapp_template_status(status_id) .then(function(data) { self.im.user.set_answer("preferred_channel", data.preferred_channel); - self.im.user.set_answer("status", data.status); - return self.states.create("state_trigger_rapidpro_flow"); }).catch(function(e) { // Go to error state after 3 failed HTTP requests