...
Since each provider has different APIs AND endpoints, having one service that manages all of them is a very convenient solution to manage.
Having this service avoids adding more complexity to other services that require sending a message or a notification to a user.
It has been designed to be able to work with openHim and to be able to have this service linked.
This is an example of a payload to send the message:
Code Block |
---|
{
"project": "{{projectID}}",
"msg": "Hi, I'm a test",
"channel": "{{channel}}",
"to": "{{to}}",
"from": "{{from}}"
} |
msgType: Different providers allow us to send different message types (text, images, sound, templates…). Most of the projects use Meta and have their own API. We try to use the same types as Meta to avoid misspellings and mistakes.
Our current message types are: image | template | text | quick-replies. ‘text’ is the default type.
Example to send WhatsApp message with quick replies (previously, you need to start the conversation):
Code Block |
---|
{ "project": "{{project}}", "msg": "More info: https://developers.facebook.com/docs/whatsapp/cloud-api/messages/interactive-reply-buttons-messages/", "channel": "whatsapp", "to": "{{phone}}", "lang": "en", "msgType": "quick-replies", "extraParams": { "header": { "type": "text", "text": "You can remove this. This is a mega title" }, "action": { "buttons": [ { "type": "reply", "reply": { "id": "sad", "title": "Sad" } }, { "type": "reply", "reply": { "id": "happy", "title": "Fine" } } ] }, "footer": "You can remove this if you are not using it." } } |
the client will see:
...
This is an example to send an image:
Code Block |
---|
{
"project": "TEST-FB",
"msgType": "image",
"msg": "https://www.psi.or.tz/images/logo_psi.png",
"channel": "facebook",
"to": "{{fb-psid}}",
} |
⚠️ Before starting to use this service in a project, you need to communicate with the service admin to
...
update
...
the configuration.
For each project, the service needs a configuration (which channels are going to use the project, which aggregators exist, and credentials). After that, we can use it easily to send a POST requests with the previous payload template.
You can find more examples in this POSTMAN workspace: POSTMAN
You can find the service repository here: GITHUB REPOSITORY
If you have any doubt, you can contact ghernandez@psi.org