Webhook Response

Post Reply
apietrocini
Member
Posts: 32
Joined: Fri Mar 24, 2017 7:06 pm
Location: Cleveland, OH

Webhook Response

Post 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
mkayyyy
Member
Posts: 79
Joined: Mon Nov 21, 2016 6:31 pm
Location: UK

Re: Webhook Response

Post 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
apietrocini
Member
Posts: 32
Joined: Fri Mar 24, 2017 7:06 pm
Location: Cleveland, OH

Re: Webhook Response

Post by apietrocini »

That did it! I was just using the webhook configurator and completely forgot about the ability to script it... :oops:

Thank you!
Post Reply