Trigger task from Textit

Hello community

Is it possible to trigger a task in CHT through webhook POSTing of a contact response in rapidpro?
cc @diana

It possible to trigger a task in CHT by submitting a CHT report from RapidPro, using the CHT API for POSTing records. The presence of the report can then trigger the task, as would be done with other other submitted forms.

Let us know how that works out, and if you need any other guidance to get it working!

1 Like

hello @marc thanks for the feedback ,
I am looking at mainly creating the records by submitting the raw message string and would to get clarification on a few questions .

  • will i have to configure a sms json form that is submitted whenever the webhook posts a message to CHT

  • How will CHT know that this message from textit should generated the submitting of this sms json form which turns into a report to trigger the desired task because am only seeing three form parameters for the option of creating the records by submitting the raw message

Hi @cliff

To address your questions:

  • correct, you will need to configure a json form with all the required fields that are needed to generate the task appropriately
  • the api/v2/records does exactly what you described, it matches the contents of the message or the payload of the request and generates a report with the correct fields. The raw message is enough to create the report, as it would contain all the fields that you configured and you need to have in the report. Please have a look at how json forms work Building SMS Forms | Community Health Toolkit

please let us know if this works!

1 Like

hello @diana

For some reason POSTing to records CHT api endpoint is returning

 "code": 401,
  "error": "unauthorized"


I have tried to verify that the token api is the one in textit, could the url be not right here ?

Hello @cliff

Unfortunately, this API endpoint doesn’t use the same authentication protocol as the Rapidpro endpoints, you won’t be able to use the same authentication token. You’re going to have to use basic authentication with a CHT user account to use this API that has the can_create_records permission.

1 Like

Hello @diana
thanks for the feedback …
Textit only uses token API authentication, i think the community may consider supporting basic authentication for these kinds of endpoints because currently one can’t POST to these basic authentication ends points while in textit unless they use another service like Postman

I would have thought textit allowed to add any headers to an outgoing request, does it not?

Hello @diana
it doesn’t , the feedback i got from them is that they only support token API authentication.

I think that’s true for incoming requests, from an external API to Textit, but outgoing, from Textit to external APIs can carry any kind of authentication.

I believe there are no limitations to these headers. Can you please try it out?

1 Like

hello @diana
Something like ?
Screenshot from 2022-09-29 15-29-34

It’s actually something like I added, I think you need to encode the credentials yourself, I doubt textit will do it for you. If you’re already using Postman, try making a request with basic authentication and check the actual Authorization header that is sent then, and copy that here.

2 Likes