Close

This module allows you to close out an HTTP connection and send a response back to the service, while continuing the rest of your method. This module is particularly useful for “user-invokable” invokable events, since often services that will be invoking a user’s Flow will require a specific response to stop further requests (for more information about invokable Flows, check out this guide). This allows you to build in the response to your connector, rather than relying on a user to end a Flow with a specific “Return Raw” card. Note, this module will only work if you are specifically using “user-invokable” invokable Flows, designated by the “user-invokable” flag being set to true at the top level.

Inputs

  • statusCode: The status code you would like to pass along to the service who invoked your connector.
  • headers: The headers you would like to send back to the service that invoked your connector
  • query: The group of query parameters you would like to send back to the service that invoked your connector.
  • body: The body of the response you would like to send back to the service that invoked your connector.

Outputs

There are no outputs for this module. It simply closes out the connection using the information provided.

Example

As an example, Salesforce’s Outbound Messaging allows you to set an endpoint to trigger whenever their own conditions are met internally. This is a perfect case for “user-invokable” connectors, because Salesforce will be triggering a Flow for you, and requires an acknowledgment response to know that the trigger was received.  Since we can’t assume that Flow builders will always end their Flows with a Return Raw card, set with the exact response format that Salesforce expects, we can’t expect the Salesforce HTTP connection to be correctly closed unless we perform it ourselves inside of the invokable method. Salesforce’s acknowledgment response is required to look like this: Status Code: 200 Headers: { “Content-Type”: “text/xml” } Body:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:out="http://soap.sforce.com/2005/09/outbound">
    <soapenv:Header/>
       <soapenv:Body>
          <out:notificationsResponse>
              <out:Ack>true</out:Ack>
          </out:notificationsResponse>
       </soapenv:Body>
    </soapenv:Header>
</soapenv:Envelope>

So, we know that inside of our connector we’ll need to send out this response, using the HTTP.Close card. Here’s what that would look like, with “XMLBUILD.output” being the output of an XML.Build module that contains the above XML.

{
   "brick": "http.close",
   "id": "Byxw3",
   "inputs": {
      "statusCode": {
        "_type": "number",
        "_array": false,
        "_value": 200
      },
      "query": {
          "_availableTypes": [
             "object",
             "string"
          ],
         "_type": "object",
         "_array": false,
         "_value": {}
      },
      "body": {
         "_availableTypes": [
           "object",
           "string"
         ],
         "_type": "object",
         "_array": false,
         "_value": "{{XMLBUILD.output}}"
       },
       "headers": {
         "_type": "object",
         "_array": false,
         "_value": {
           "Content-Type": "text/xml"
         }
      }
   },
  "outputs": {}
}