guides
Webhook Node

Webhook Node

The Webhook node enables your bot to connect with external systems, APIs, and services to fetch or send data during a conversation.

Webhook Node

Overview

Webhook nodes are powerful integration points that allow your bot to:

  • Retrieve information from external databases or services
  • Send collected data to your business systems
  • Verify information provided by users
  • Trigger actions in other applications
  • Enhance conversations with external data

Configuration Options

URL & Method

The primary settings for a webhook are the URL and HTTP method:

  • URL: The full endpoint URL, including protocol (https://)
  • Method: The HTTP method to use
    • GET: For retrieving data
    • POST: For sending data
    • Other methods (PUT, DELETE, etc.) are also available

Headers

You can customize the request headers for your webhook:

Custom Headers

  • Toggle "Customize Headers" to add headers
  • Common headers include:
    • Content-Type: application/json
    • Authorization: Bearer [token]
    • API keys or custom authentication headers

Request Body

For POST, PUT, and PATCH requests, you can configure the request body:

  • Enter the data to send to the API
  • You can include variables from previous interactions
  • JSON format is commonly used
  • Dynamic values can be inserted using the Variables button

Testing Your Request

Before deploying, you can test your webhook:

Test Request

  • Toggle "Test Your Request" to enable testing
  • Set test values for any variables
  • Click "Test the request" to verify the connection works
  • Review the response to ensure it matches expectations

Saving Responses as Variables

You can save the API response for use in later nodes:

Save Responses

  • Toggle "Save Responses as Variables" to enable
  • Enter variable names for different parts of the response
  • Access response data, status codes, and headers
  • These variables can be used in subsequent nodes

Response Routing

When you enable response routing, the webhook node creates multiple output paths based on HTTP status codes:

Response Routing Example

  • Toggle "Response Routing" to enable
  • Different HTTP status codes create separate output paths from your webhook node
  • Typically includes:
    • Default path (for unhandled status codes)
    • 200 path (for successful responses)
    • 400 path (for client errors)
    • Other custom status codes you define
  • Each output path can be connected to different nodes in your flow
  • This allows you to create different experiences based on the API response

Common Use Cases

  • Data Retrieval: Fetch product information, account details, or pricing
  • Data Submission: Send user input to your CRM, database, or ticketing system
  • Verification: Validate coupon codes, account numbers, or user credentials
  • Third-Party Integration: Connect with payment processors, shipping calculators, etc.
  • Advanced Logic: Perform complex calculations or processing that's better handled server-side

Best Practices

  1. Secure your endpoints: Use HTTPS and proper authentication
  2. Handle errors gracefully: Create paths for different error scenarios
  3. Test thoroughly: Verify that your webhooks work with all possible inputs
  4. Cache when appropriate: Avoid making the same API call repeatedly
  5. Set timeouts: Configure reasonable timeouts for external services
  6. Monitor usage: Keep track of API limits and response times
  7. Validate input: Ensure data sent to external systems is properly formatted
  8. Document dependencies: Make note of which external services your bot relies on

Connecting to Other Nodes

After a Webhook node, you typically connect to:

  • A Condition node to branch based on the API response
  • A Message node to display information from the API
  • Another Webhook node for sequential API calls
  • A Question node to ask for additional information based on the API response

With response routing enabled, you'll create connections for each response path.

Example Implementations

Product Information Lookup

Webhook GET to https://api.example.com/products/{{product_id}}
Headers: 
  - Authorization: Bearer {{api_key}}
Save response data as {{product_info}}
If status 200:
  → Connect to "Product Found" Message node
If status 404:
  → Connect to "Product Not Found" Message node
Default:
  → Connect to "Error" Message node

User Registration

Webhook POST to https://api.example.com/users
Body:
  {
    "name": "{{user_name}}",
    "email": "{{user_email}}",
    "phone": "{{user_phone}}"
  }
Save response as {{registration_result}}
If status 201:
  → Connect to "Registration Success" Message node
If status 400:
  → Connect to "Invalid Data" Message node
Default:
  → Connect to "Try Again Later" Message node

Notes and Limitations

  • Webhook timeouts occur after 10 seconds if the external service doesn't respond
  • Response data is limited to 1MB in size
  • CORS restrictions do not apply since requests are server-side
  • Credentials and tokens in URLs or headers will be sent as-is, so use secure endpoints
  • For security, avoid exposing sensitive APIs directly; consider using proxy services