Link Menu Expand (external link) Document Search Copy Copied

Make Http Call with Callback

Definition

This action initiates an HTTP request to a specified external endpoint and immediately pauses the workflow’s execution, waiting for a signal to resume. Unlike standard HTTP requests that keep the connection open while waiting for a reply, this action utilizes an asynchronous “Request-Reply” pattern. It automatically generates a unique, secure callback URL for the specific flow run and injects it into the outgoing request’s headers (specifically x-zenphi-callback-url). The flow remains in a paused state until the external system (or a secondary process) sends a request back to that unique URL, allowing for long-running processes that exceed standard timeout limits.

  • Asynchronous Orchestration: Pauses the flow efficiently without consuming resources, allowing waits of minutes, hours, or days.
  • Automatic Callback Generation: Dynamically creates and secures a unique listener URL for every specific execution.
  • Header-Based Handshake: Transmits the callback URL via the x-zenphi-callback-url header to the target system.

This action is essential for integrating with “Async APIs” or systems that perform heavy tasks (like AI processing, video rendering, or human approvals), ensuring your automation is robust, scalable, and immune to standard network timeouts.


Inputs

  1. HTTP Request Method
    • Purpose: This field determines the type of action you want to perform on the destination API (e.g., retrieving data, sending data, or updating a resource).
    • Practical Guidance: Select the appropriate verb from the dropdown menu (GET, POST, PUT, HEAD, PATCH, DELETE). This is typically a static value based on the external API’s documentation.
    • Use Case Context: You would select ‘POST’ if you are sending a file to an external processing service, or ‘GET’ if you are triggering a remote script.
  2. API URL
    • Purpose: This is the specific web address (endpoint) of the external service or system you want to communicate with.
    • Practical Guidance: Enter the full endpoint URL. You can use a static value for fixed API addresses (e.g., https://api.example.com/process), or use the token picker to insert dynamic values (like an ID from a trigger) to build the URL at runtime.
    • Use Case Context: You would use this field to specify the exact address of the “Wrapper Flow” or external webhook listener that will receive your request.
  3. Authorization
    • Purpose: This section manages the security credentials required to prove your identity to the external API so it accepts your request.
    • Practical Guidance: Select the method required by the API:
      • No Auth: Leave blank if the API is public.
      • Basic Auth: Enter the Username and Password.
      • API Key: Enter the Key name and Value.
      • Bearer Token: Enter the token string.
      • Note: It is best practice to store sensitive keys in Zenphi Vault and reference them here dynamically using the token picker.
    • Use Case Context: You would use ‘Bearer Token’ to pass the secure API key provided by services like OpenAI or Replicate.
  4. Headers
    • Purpose: This allows you to pass additional metadata or instructions to the API, such as the content format or custom tracking tags.
    • Practical Guidance: Click to add key-value pairs. A common static value is Key: Content-Type, Value: application/json. You can also inject dynamic values if the header needs to change based on previous steps.
    • Use Case Context: You would use this to specify Content-Type: application/json so the receiving API knows how to interpret the data you are sending in the body.
  5. Body
    • Purpose: This is where you define the actual data payload to be sent to the external API.
    • Practical Guidance: Select the content type (usually application/json or text/plain). You can construct a JSON object here, using the Token Picker to map dynamic values (like File Names, URLs, or IDs) from previous steps into the payload.
    • Use Case Context: This is where you would format the JSON object containing the file_url you want CloudConvert to process.
  6. Ignore Server Certificate Validation
    • Purpose: This setting tells Zenphi whether to enforce strict security checks on the destination server’s SSL certificate.
    • Practical Guidance: This is a toggle switch. Keep it Off (default) for production to ensure security. Only switch it On if you are testing against a local server or a system with a self-signed certificate.
    • Use Case Context: You would enable this temporarily if you are debugging a connection to an internal development server that doesn’t have a public SSL certificate yet.

Outputs

  1. requestHeaders
    • Data Description: An object containing the raw headers sent back by the external system when it performed the callback to resume the flow.
    • Workflow Utility: This is useful for debugging or verifying the source of the callback. You can inspect these headers to ensure the callback came from the expected service or to retrieve metadata like trace IDs.
  2. headers
    • Data Description: A collection (list) of the callback request headers, formatted as key-value pairs.
    • Workflow Utility: This list is essential if you need to extract specific metadata from the callback request using a “Query Collection” or “For Each” loop. For example, you might look for a specific signature header to validate the request security.
  3. queryStrings
    • Data Description: A list of any parameters appended to the callback URL (e.g., ?status=success&id=123) when the external system called it.
    • Workflow Utility: This is vital for “Human Link” approval scenarios. If a user clicks a link like .../callback?action=approve, you can use this output to read the “action” parameter and decide whether to proceed down the “Approved” or “Rejected” path.
  4. payload
    • Data Description: The main body content sent by the external system when it called the callback URL.
    • Workflow Utility: This is the most critical output. It contains the actual result of the long-running process (e.g., the signed document data, the converted file URL, or the AI-generated image link). You pass this token to subsequent actions to save the file or update a database.
  5. correlationId
    • Data Description: A unique identifier string associated with this specific request-response cycle.
    • Workflow Utility: This ID is valuable for logging and troubleshooting. You can save this to a log file or database to trace the entire transaction history across multiple systems if an error occurs.
  6. duration
    • Data Description: A breakdown of how long the flow was paused, provided in seconds, minutes, hours, and days.
    • Workflow Utility: This allows you to perform analytics on your automation performance. You can log the ‘inSeconds’ value to a Google Sheet to track if your external vendors or AI services are meeting their Service Level Agreements (SLAs).

Example Use Cases

  1. Bridge Standard APIs with “Wrapper” Flows Connect to services like Adobe Acrobat Sign, DocuSign, or CloudConvert (which strictly require callback URLs in the JSON body) by pausing the main flow while a helper flow extracts the x-zenphi-callback-url header and maps it to the required API payload field.
  2. Enable Zero-Login External Approvals Create frictionless approval processes for external vendors or clients by sending an email with a unique link; the flow pauses until the recipient simply clicks the link (triggering a GET request), which instantly resumes the automation without requiring a portal login or form submission.
  3. Orchestrate Long-Running AI Batch Jobs Leverage cost-effective “Batch” endpoints from providers like OpenAI or Replicate to process massive datasets, allowing Zenphi to “sleep” and conserve resources for hours or days until the model computes the results and calls back with the generated content.
  4. Synchronize Cross-Tenant Processes Trigger and wait for complex workflows in completely different Zenphi workspaces or tenants (e.g., an HR onboarding flow waiting for an IT provisioning flow), enabling secure, decoupled hand-offs where the target flow explicitly notifies the source flow upon completion.

Example

Scenario: An engineering firm manages a Google Drive folder where architects upload large AutoCAD (.dwg) blueprints. These files need to be converted to PDF for client review. The conversion process via an external API (like CloudConvert) takes 5-10 minutes, which causes standard HTTP requests to timeout. To solve this, the firm uses the “Make http request with callback” action to trigger a Helper Flow that handles the conversion asynchronously.

Steps to Implement:

  1. Google Drive file added Configure the trigger to monitor the “Raw Blueprints” folder for new files.
  2. Make http request with callback Add this action to the flow to initiate the conversion request and pause execution.
    • HTTP Request Method: Select POST.
    • API URL: Enter the Invocation URL of your Helper Flow (which is set up to extract the header and call CloudConvert).
    • Headers: Add a key Content-Type with value application/json.
    • Body: Enter a JSON object containing the file details, mapping the WebViewLink token from the trigger. Example:
      {
        "file_url": "[WebViewLink]",
        "file_name": "[Name]"
      }
      
  3. Save File to Google Drive Add this action after the HTTP step. Since the flow resumes only when the PDF is ready, map the result URL from the HTTP action’s payload output to save the converted file.

Outcome: The automation handles heavy file conversions without ever hitting a timeout limit. The flow efficiently “sleeps” during the 10-minute conversion process, saving compute resources. As soon as the external service finishes, the flow wakes up and saves the PDF, ensuring a seamless experience for the architects.


Best Practices

  1. Use Wrapper Flows for Standard APIs Most services (like Adobe Sign or CloudConvert) expect the callback URL in the JSON body, not a header. Always use a Helper Flow to extract the x-zenphi-callback-url header and map it to the required body field.
  2. Implement Parallel Timeout Paths To prevent a flow from waiting indefinitely if the external service fails to call back, place this action inside a parallel branch alongside a Timer action (e.g., wait 2 days) that terminates or alerts on timeout.
  3. Manage Payload Limits Ensure the response sent back to the callback URL does not exceed 30MB. For larger files, the external system should save the file to cloud storage and return a download link in the callback body instead.
  4. Validate Request Origins When accepting callbacks, verify that the data matches your expected schema. While the callback URL is unique to the run, validating the returned payload ensures data integrity for subsequent steps.