How to trigger API end point from Prosody (api_prefix of event_sync function)

I followed prosody-plugins/event_sync at main · jitsi-contrib/prosody-plugins · GitHub

I have added in yourdomain.cfg.lua (/etc/prosody/config.d/.cfg.lua), but my API is not triggered

Component “event_sync.yourdomain.com” “event_sync_component”
muc_component = “conference.yourdomain.com
api_prefix = “https://****.execute-api.us-east-1.amazonaws.com/NonProd/grantModeratorDelete”
api_timeout = 10 – timeout if API does not respond within 10s
retry_count = 5 – retry up to 5 times
api_retry_delay = 1 – wait 1s between retries

-- change retry rules so we also retry if endpoint returns HTTP 408
api_should_retry_for_code = function (code)
    return code >= 500 or code == 408
end

Able to trigger the API with curl and Postman as below

ubuntu@dev:~$ curl --location --request POST ‘https://**.execute-api.us-east-1.amazonaws.com/NonProd/grantModeratorDelete’ \

–header ‘Content-Type: text/plain’
–data-raw ‘{
“meetingId”: 41546525
}’
{“data”:{“status”:200,“Message”:“Data Deleted Successfully”},“status”:200,“statusMessage”:“Data Deleted Successfully”,“errorMessage”:""}

Please suggest on what else need to be added in yourdomain.cfg.lua file to make my API trigger from Prosody . Any other steps to make my API trigger will also be helpful.

In a PM with you colleague @KameshDhanasekar , we have already established that your event_sync setup can indeed make API calls when different endpoint is used (e.g. using webhook.site) so the issue is not as you stated. Not sure how much I can help if the issue is in your backend and not in the prosody module.

A few things I’d note:

event_sync will send a POST for different events – room created, room destroyed, occupant joined, occupant left; what is your intent here? Do you really want to call your grantModeratorDelete on all those events?

That payload does not match the payload sent by event-sync.

Does curl still work without --location? If not, then this might be the issue. I don’t think the prosody module follows redirects. The API call might be successful but all it gets back is the 301/302 response.

In general, I sense there is a disconnect here between what the module does and what you are trying to achieve with it. If this is true, then may you want to consider writing your own module using event_sync as reference, in particular if you need to:

  1. trigger an API call only for specific events, or trigger different API calls for different events
  2. change the payload
  3. inject additional auth details that are not static. It is possible to use api_headers to specify static headers, but if your API auth is dynamic (e.g. an HMAC auth that needs a hash of payload and timestamp) then this won’t work.