Page 1 of 1

Webhook Response

Posted: Thu Sep 26, 2019 10:15 pm
by apietrocini
Hi All,

I'm wondering if anyone else has had this problem... Is there a way to configure a/the response that is sent from Switch back to the webhook originator...? The particular case I'm using this in is with Twilio... I'm generating a text to someone through switch, and they then respond, and that response is sent to a webhook back into switch from Twilio, Twilio is then looking for a response back from Switch after submitting the webhook... I hope this makes sense...

Thanks,

Anthony

Re: Webhook Response

Posted: Thu Sep 26, 2019 11:31 pm
by mkayyyy
Using the constructWebhookResponse entry point in a script should allow for this:

Code: Select all

function constructWebhookResponse( r : WebhookRequest, response : WebhookResponse, args : Array ) : Boolean
{
    response.statusCode = 200;
    response.write('{status:"true"}');
    return false;
}
You can change the body of the response from the default '{"status":true}' to what is needed for Twilio. There are a few examples in the Scripting Guide: https://www.enfocus.com/manuals/Develop ... ponse.html

Re: Webhook Response

Posted: Fri Sep 27, 2019 12:21 am
by apietrocini
That did it! I was just using the webhook configurator and completely forgot about the ability to script it... :oops:

Thank you!