How do I control the JSON response that is sent back to the app that the HTTP request originated from

This topic was automatically generated from Slack. You can find the original thread here.

King-A. J. Olly : Hi! I’m a newbie using Pipedream. I’ve reviewed all the docs, but can’t find the answer to my question, unless I’ve overlooked something. It’s likely a newbie question – I’d like to know when I send an incoming HTTP Request into Pipedream, how do I control the JSON response that is sent back to the app that the request originated from? Are we able to control this?

For more context, I’m sending a request to our CRM from a Twilio Studio HTTP Request widget. I want to use Pipedream to throttle the requests and return the data from the CRM to Twilio Studio within 10 seconds. But, when I’m doing the initial testing just with a RequestBin, when I begin to edit a workflow, I don’t see where or how to handle or edit the response being sent back to Twilio Studio. Right now, it’s getting an immediate 200 response. How do I edit/control this?

SERW2039 : I think in this case you are referring to the custom http response from the workflow, it uses the $respond() function, docs here: https://docs.pipedream.com/workflows/steps/triggers/#http

Tod Sacerdoti : Yes, $respond is correct. Here is the direct link in docs - https://docs.pipedream.com/workflows/steps/triggers/#customizing-the-http-response.

King-A. J. Olly : Okay, awesome! Thank you! I’m assuming that using $respond() anywhere in a workflow automatically tells Pipedream not to issue the automated HTTP response, but to wait for the part in the code that manually issues the response? Am I correct? Or do I need to adjust a setting somewhere for the workflow to tell Pipedream that I’m going to write the response code manually?

Tod Sacerdoti : Yes, that is correct. Note that if you use $respond() in a workflow, you must always make sure $respond() is called in your code. If you make an HTTP request to a workflow, and run code where $respond() is not called, your endpoint URL will issue a 400 Bad Request error.

King-A. J. Olly : So, if I use $respond() in one workflow, it will signal to Pipedream that I want to use it all of my workflows and essentially stop providing the default response and begin to look for it in all workflows?

Am I understanding correctly?

Will RequestBin still continue to issue 200 responses when new HTTP requests come in? Or will it also seek to be attached to a workflow and need a response to function if I use $response() anywhere in my workflows?

Tod Sacerdoti : No, using $respond() will only impact the workflow in which it is used.

King-A. J. Olly : Okay, I think I understand. I’ll give it a shot and reply back if I need additional insights. Thank you so much!