FlowRunner.CustomBlocks.Webhook (flow_runner v6.15.1)

Copy Markdown

A custom Webhook block type for Turn's Build functionality.

The FLOIP spec originally did not specify a Webhook block and so we had to roll our own until it does.

Since rc4 it does Turn had already implemented this. We'll look at moving to rc4 at some stage but not right now.

Because of historical RapidPro context informing the FLOIP design, there's an assumption for some systems that the webhook key in the context's variables always contains the last called webhook response.

This may be useful as a default when a FLOIP only does a single webhook call but it ends up being confusing when there are multiple webhook calls that can happen.

To retain some compatibility we always write the results under the webhook key in the context in addition to the key of the current block.

Summary

Functions

Returns all block documentation defined in this module.

Process the response received from a call to an external HTTP API. Provides somewhat graceful fallback handling when the remote endpoint doesn't respond within adequate time.

Naive check to see if a URL is safe or not by checking if the domain points at IP addresses for reserved internal networks or not.

Functions

block_docs()

@spec block_docs() :: [Keyword.t()]

Returns all block documentation defined in this module.

Each block doc entry is a keyword list with keys like :type, :description, :config, etc., plus a :category key added from @block_category.

create_client(block, headers)

default_timeout()

evaluate_webhook_parameters(block, context)

httpc_method(binary)

process_async_webhook(block, context, map)

process_response(arg, block)

@spec process_response(Tesla.Env.result(), FlowRunner.Spec.Block.t()) :: map()

Process the response received from a call to an external HTTP API. Provides somewhat graceful fallback handling when the remote endpoint doesn't respond within adequate time.

If there's simply no response, in the event of a connection error or a timeout then we'll construct a response to the best of our abilities to allow the stack to continue, delegating responsibility for the handling of this error case to the stack author.

This returns the context map that is added to the flow context for this block.

process_sync_webhook(block, context, map)

process_webhook(block, context, parameters)

@spec process_webhook(
  FlowRunner.Spec.Block.t(),
  FlowRunner.Context.t(),
  parameters :: map()
) :: map()

safe_url?(url)

Naive check to see if a URL is safe or not by checking if the domain points at IP addresses for reserved internal networks or not.