Mobile Configuration in 2.34.3

In 2.31.9, when configuring the SMS gateway the following parameters were available: Message Parameter=content and Recipient Parameter=to_number. In 2.34.3 to the latest version of DHIS2 doesn’t have those parameters. Please what is the way of configuring SMS gateway on 2.34.3? Because it is saying sent but I am not receiving the SMS on my phone. I am getting this error on the SMS gateway log:

{
“message”: {
“status”: “error”,
“error”: {
“name”: “SyntaxError”,
“message”: “Unexpected end of JSON input”,
“code”: 422
}
},
“level”: “error”,
“label”: “sms-gateway-prod”,
“timestamp”: “2021-04-04T22:08:40.072Z”
}

the latest version of the SMS gateway is buggy, it doesn’t work as it was working in 2.33 and expected.

please configured it as it’s in the above image.

Hi @mujtabaomar ,

Thanks for your quick response but can you be more explicit? Because the content of the

Url and the Configuration template

are hidden by the red ligne in your image

HI @Isidoreadje,

URL template includes the gateway but the rest of the parameters should be included in the configuration template, in the previous version there was the message parameter here you have to encode that like (message=${text}) and receiver=${recipients}. here is the link for the API SMS configuration.

Okay Thanks @mujtabaomar

Mujtaba,
Please all secret information were not shared and I had already tried it in so many ways nothing is working for me:

URL Template: https://a8765b3c33e5/messages/send
configuration Template: content=${text}&to_number=${recipients}&provider=rapidpro&secret=${secret}
contentType: application/x-www-form-urlencoded
sendUrlParameter: (checked)
secret=xxxxxxx

And I am getting this error on the SMS gateway logs:

"message": {
    "status": "error",
    "error": {
        "name": "SyntaxError",
        "message": "Unexpected token c in JSON at position 0",
        "code": 422
    }
},
"level": "error",
"label": "sms-gateway-prod",
"timestamp": "2021-04-07T20:53:23.467Z"

Hi @Gerald_Thomas,

embed the parameters in Configuration template like provider you did.
configuration Template: content=${text}&to_number=${recipients}&provider=rapidpro&secret=secret

don’t include any key-value pair as a parameter embed them in the query string.

Hi Majtaba,
I already did as you suggested:
configuration Template: content=${text}&to_number=${recipients}&provider=rapidpro&secret=secret but the SMS is still FAILED. On the SMS gateway I

am receiving this error message:

{
** “message”: {**
** “status”: “error”,**
** “error”: {**
** “name”: “SyntaxError”,**
** “message”: “Unexpected token c in JSON at position 0”,**
** “code”: 422**
** }**
** },**
** “level”: “error”,**
** “label”: “sms-gateway-prod”,**
** “timestamp”: “2021-04-08T04:38:35.986Z”**
}

Did you put whatever is expected in the provider=providerExpectedName and secret=whateverIsTheSecret. are you able to check what hits their server like what parameters are missing.

Dear Mujtaba,
I change the secret to my secret. I can’t see any parameter on the SMS server; it only send out an information about json which was attached on the previous message and DHIS2 under view send message it FAILED

Finally, find the solution for 2.34.3
Gateway Name: ANY_NAME
URL Template: https://SMS_GATEWAY_LINK?content={text}&to_number={recipients}&provider=provider_name&secret=XXXXXX
configurationTemplate: This should be blank
contentType: text/plain

useGet: (checked)
sendUrlParameters: (checked)

On 2.34.4
Gateway Name: ANY_NAME
URL Template: https://SMS_GATEWAY_LINK
configurationTemplate: content=${text}&to_number=${recipients}&provider=provider_name&secret=XXXXXX
contentType: text/plain

useGet: (checked)
sendUrlParameters: (checked)

1 Like

So in our new versions, are we supposed to pass our API Keys, Passwords, Secrets, etc directly into the query string of the configurationTemplate instead of using the parameters and “sendURLParameters” checkbox?

I could not get the parameters to pass into the query string.

Hello,

I’m facing problems with passing recipients and message to the variables. The SMS gets sent when I hardcode the values, like this:


Tried doing:
&to=${recipients}&txt=${text},
&to={recipients}&txt={text},
content=${text}&to_number=${recipients}

But none seem to work. any help?

Hi @Micheal_Berhanu,
Welcome to the community! :tada:

What is the version of your dhis2 instance?

Why don’t you try to use APPLICATION_JSON instead of FORM_URL_ENCODED? You’ll change somethings but I don’t think you’ll face difficulty with variables once you use the parameters in that format. Have you seen this sample JSON payload? SMS - DHIS2 Documentation

Thanks! :+1:

1 Like

Thanks for the quick response @Gassim,

I’m on version 2.33.0

Yes, I saw the payload, my service provider expects a GET request with this format
https://portal.websprix.com/sendsms.php?id=myid&pass=*****&to=09122807836&txt=hrt

I tried this but still doesn’t work:

Yes, sorry if you are required to use only that format then APPLICATION_JSON will 100% not work. Thanks!

so, back to FORM_URL_ENCODED, but what am I doing wrong with the variable ? anything you see wrong?
On the UI, the message and recipient fields are blank:

Is there something I should write there?

1 Like

From 2.33 to 2.35 this how we configured it:

“name”: “Websprix”
“URL Template”: https://portal.websprix.com/messages/send
“Configuration template”: content=${text}&to_number=${recipients}&secret=xxxxxx&provider=depends_on_your_provider
“Content type”: Plain text

check “Use GET”
check “Send url paramenters”

2 Likes

Hey @Gerald_Thomas,

My provider has the following attributes only:

  • Id
  • pass
  • to
  • text

You suggested to use these: content=${text}&to_number=${recipients}&secret=xxxxxx&provider=depends_on_your_provider

Am I supposed to change the values according to my context. i.e
txt=${text}&to=${recipients}&pass=xxxxxx&id=****

Or write them exactly as you did? I sort of did both actually but doesn’t seem to work. Don’t know what to do.