Ordinary 2wt with rapidpro and CHT

Hello community

We are seeking to achieve ordinary two-way texting with textit and CHT outside of textit flows, is it possible to achieve corresponding back to back texting communication between a provide at the facility and the patient through rapidpro where by when the patient is communicating back to CHT he/she doesn’t have to go through a flow and POSTing the SMS via a webhook to CHT ie they just text directly to CHT .
I have achieve the provider side of the communication ie the message from to CHT to the patient
cc @diana

Hello @cliff it seems possible to do so through triggers. You still might have to do flows to handle the two-way communication - directing texts in and out. The RapidPro messaging gateway documentation is a good resource to review.

thanks @kitsao , i was considering the same approach initially …

Is Start a Flow after Receiving a Message that Doesn't Match Any Keywords or Start a flow when conversation is started by a contact the best option ?

hello @kitsao used Start a Flow after Receiving a Message that Doesn't Match Any Keywords it looked for suitable however in CHT the messages are not in the same thread as seen below .

Here when a chw send a message Hello Tom to the patient , the patient responds back with Hello CHT but the message is not in the original thread that initiated it .
Any ideas on how i can get the response from the patient in the same thread of Hello Tom

It’s a little suspicious that the heading for the first message starts with “tel:”. I would expect that to be just the phone number. If the phone number in the doc starts with “tel:” then it won’t match the phone number for Tom which may be why it’s not showing up in the thread. Look up the message in the database and check the sms_message.from field. I suspect this is an issue with the TextIt configuration.

@cliff I just noticed that’s covered in the documentation the @kitsao linked. Scroll down to the section that includes replace(urns.tel,"tel:+", "+") and apply that to your flow.

thanks @gareth for the feedback ,your right, i have looked up in the logs and i see "from":"tel:+256785579893"
I changed the payload format in the textit webhook from



     "from":"replace(urns.tel,"tel:+", "+")",

And got this feedback below

POST /api/v1/sms/radpidpro/incoming-messages HTTP/1.1
Host: cht.openelis-global.org
User-Agent: RapidProMailroom/7.5.12
Content-Length: 123
Accept: application/json
Authorization: Token 57b30498a5b0aae73f2bd974f850ef4181856377
Content-Type: application/json
X-Mailroom-Mode: simulation
Accept-Encoding: gzip

     "from":"replace(urns.tel,"tel:+", "+")",
HTTP/1.1 500 Internal Server Error
Content-Length: 35
Connection: keep-alive
Content-Security-Policy: default-src 'none'; font-src 'self'; manifest-src 'self'; connect-src 'self' https://staging.dev.medicmobile.org/_couch/builds/ maps.googleapis.com; child-src 'self'; form-action 'self'; img-src 'self' data: blob: *.openstreetmap.org; media-src 'self' blob:; script-src 'self' 'sha256-B5cfIVb4/wnv2ixHP03bHeMXZDszDL610YG5wdDq/Tc=' 'unsafe-eval' 'unsafe-hashes' 'sha256-2rvfFrggTCtyF5WOiTri1gDS8Boibj4Njn0e+VCBmDI='; style-src 'self' 'unsafe-inline'
Content-Type: application/json; charset=utf-8
Date: Mon, 19 Sep 2022 19:56:07 GMT
Etag: W/"23-Sr4fG1ljs8UL8ru7fCuZVjsHJJY"
Server: nginx/1.13.6
Strict-Transport-Security: max-age=15552000; includeSubDomains
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Dns-Prefetch-Control: off
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block

{"code":500,"error":"Server error"}

@cliff An Internal Server Error means something unexpected happened on the server. If you check the API logs I expect you’ll see an error with stacktrace which will have more information about what happened and help us debug it further.

@gareth API logs for textit or for the remote CHT server am using ?

Oh! I think I just worked out what the problem is. I assumed it was a CHT issue but looking more closely at the error message I think it’s a textit issue where it’s parsing the replace command.

Please check the flow configuration and make sure it exactly matches what’s in the documentation. It looks like you’ve configured it with additional quotes around the replace(...) function, eg: "from": "replace(urns.tel,"tel:+", "+")" instead of "from": replace(urns.tel,"tel:+", "+")

1 Like

thanks @gareth for the response ,
i used

     "id", run.uuid,
     "from", replace(urns.tel, "tel:", ""),
     "content", results.result1.input

and it worked , am thinking may be we could update the screen shots here

1 Like