Universal Webhook Feature for AI models (instead of more APIs)

So … I was giving it some more thought. I think instead of chasing every API from here to eternity … and there will be many more. You will constantly be programming APIs. That is probably not the best solution.

I think what you should do is just create a Universal WEBHOOK Feature … that let’s the user create as many Webhooks / API types as they want while making your job easier with less work. It would be very similar to the structure I detailed earlier … and Of course, allow us to pass and extract Macro values to and from the webhooks.

Allow User to create unlimited webhooks and for each one
ASK USER FOR:

  1. Webhook Name
  2. Server Endpoint
  3. Method (GET or POST)
  4. Workflow (TextArea for All Request Parameters, allow for Macro Variables)
  5. Payload Type (type of response expected … is it text, json, xml, image, video?)
  6. Payload Parser (TextArea that allows macro variables to be set from extracted data and returned to task)
  7. Timeout (s).

You can even do templates for popular webhooks, like ComfyUI, or heck … anything … (think Zapier/Make.com - no limits!).

This way you are not chasing the horizon with every new API that comes out that users will want.

… or do you have a similar feature already? I looked, but couldn’t find a webhook system.

I asked Perplexity about creating a universal webhook system and this was the response:

Designing a universal webhook system that allows users to construct JSON/request parameters themselves and extract the needed data is indeed feasible. Such a system can provide flexibility and scalability, accommodating various APIs without hard-coding specific API calls. Below are some examples and considerations for implementing such a system.

Examples of Universal Webhook Solutions

Symphony’s Universal Webhook

Symphony’s Universal Webhook allows external apps and cloud services to share content within Symphony chats. Users can configure webhooks using the Symphony extension app, which supports various formats like xml, x-www-form-urlencoded, and form-data. This system forwards received messages in a standardized format (MessageML) to the Symphony platform, making it versatile for different services like Zapier, IFTTT, Jira, etc…

Docs:

Github:

Rapid7’s Universal Webhook Data Exporter

Rapid7’s Universal Webhook Data Exporter enables integration with third-party or custom software by sending HTTP POST messages to a configured URL when events trigger on the Rapid7 Platform. It includes request headers and body specifications, allowing for event-specific data to be sent and processed, which can be useful for security and IT operations.
DOCS: Universal Webhook | InsightIDR Documentation

InsightIDR Universal Webhook

InsightIDR’s Universal Webhook allows for the integration of Rapid7 Platform products with third-party software. It sends HTTP POST requests with specific headers and JSON bodies, making it adaptable for various event types and ensuring secure and verified communications.

Design Considerations for a Universal Webhook System

Storing Event Payloads

Storing event payloads can be beneficial for replaying or retransmitting them to other services. This approach saves from re-implementing webhook receipt code and provides context for debugging and auditing. However, it requires careful consideration of storage and potential high traffic.

Processing Webhook Receipts

Using background jobs (e.g., Sidekiq) to process webhook receipts can improve performance by quickly acknowledging receipt (HTTP 200 status) and processing the payload asynchronously. This method helps manage load and ensures timely processing of webhook events.

Flexible Configuration

Allowing users to configure the JSON/request parameters themselves can be achieved by providing a user-friendly interface to define the structure and content of the requests. This flexibility can be enhanced by supporting various content types and ensuring robust validation and error handling

For generating images, a simplified webhooks would work.

So under api logins, AI there is a box for Image AI

image

Then inside I could give you

  1. Target url
  2. JSON post data
  3. A macro to %keyword%

%keyword% would be from the image prompt.

Right now we have an ai image prompt

image

However it only goes to openai or scm default ai.

I need to add stablediffusion / custom webhook to it.

Right now all AI image infrastructure isn’t built out like the text AI section is.

However I do plan to add AI image section with stable diffusion, open ai and comfyui (if I can figure out how to make it zero config)

Ideally, you just add [img-src-base64:%keyword%] to your article prompt, and it goes to whatever service you picked as default for ai image, which can mean a webhook to comfui, and the %keyword% part is given to you to fill out the JSON post parameter.

If you follow where I’m going with the Universal Webhook idea … you will only need the WebhookAPI NameID and the prompt. The WebhookAPI record has all the info related to it, including MIME type, so you would already know that it is an image that you are expecting.

[Webhook API NameID: prompt ]

If you want or need to specify image for your internal programming purposes, then you can put the type before it:

[text|Webhook API NameID: prompt ]

or

[img-src-base64|Webhook API NameID: prompt ]

but the user would have already indicated the Mime-type in the Webhook/API record, so indicating it here might seem repetitive and unnecessary. However, it still might be a good idea to specify [img-src-base64|APIname…] considering an image-src base64 could theoretically be returned inside of a JSON string … no? This way they can specify the MIME type here in case it is different than what the payload MIME type is. This should be as flexible as possible.

If you read my latest comment on the Allow Inline thread … this also solves that issue you brought up as well with having too many parameters.

Just make sure the Webhook system has can read/write to all the User’s %macro variables%. Problem solved.

PS: A Universal Webhook idea, makes SCM extremely flexible and allows it to work not just with AI, but just about any data source on the web. And it eliminates the need for you having to program for every future API on the planet. The more I think about it, the more sense it’s making to include a Universal Webhook API feature.

Yep this proposal would work, just add a new service that allows you to enter your own json post data and url

Would like to chime in and discuss the possibilities of HTTP/API Request Tool (all method + auths) instead of webhook (limited method).

Based on my understanding, this would provide more flexibility (PUT/PATCH) for replacing outdated content/specific information.

Also, integration with macros, e.g get API data as data source, for context. Even better, get multimodal content (via response) injected.

You mean instead of just post + post json data, give you action? ie get, post put…

Yes, so the http/api tool can be reusable in every SCM feature/macro/prompt

Handling secrets (token bearer/api key) in settings, like handling other API key

image

I called it Webhook/API module … but really needs to as flexible as possible, so it can be used for just about any data source. Most API calls today are JSON or XLM-based … SCM user would be asked for Method (GET,POST, etc) and the payload (response) would need to parsed so SCM can return %macro-variables% back to whatever module called it.

Tim, I don’t know how you can ideally parse the payload … to make it easy for SCM users to set returned values into %macro-variables%, but I figure that you probably have more experience with that since you created the various scrapers in this tool.

If SCM users can easily Webhook/API into data sources and other automation engines, like Zapier, Make.com, ActivePieces, etc … it boggles the mind just how many use cases SCM will have.

:100: Exactly, I’ve requested webhook feature in the past, but with HTTP/API tool, it will 10x SCM integration muscle :muscle:, both internal (agentic chat)/external (automation workflow) request.

Hopefully it will be feasible to develop.

WIP:

Action, body and header.

image

image

  1. Will support only JSON calls, ie whatever in the body will always be parsed as JSON object. If you paste in a non valid json string, it will cause the call to fail.

  2. The result box gives you access to the result via a javascript function call. That way you can do some basic manipulation on the data, or just correctly select the part of the JSON result data you want to use. This requires some javascript knowledge.

Picture is an example of how it couldwork to access groq

I’m not sure if everything having to be JSON is a limitation or not since AI models allow json calls.

I’m doing some testing to see how easy it is to call external apis with this setup

1 Like

looks like a great start.

However, instead of just returning one value. You know many times JSON returns several values.

Can you allow us to set macros in the Result Box?

Something like

%myvariable1% = result.choices[0].message.content
%myvariable2% = result.choices[1].message.content
%myvariable3% = result.choices[2].message.content

Right now, I code the webhooks as another prompt call,
ie
[ai do this]

The return is always singular
eg
%value% = [ai do this]

The return box has to return a single value since its actually just a sandboxed javascript eval.

Right now its set to return everything as one string, so even if you returned an object the output into the article is that of an object JSON string.

Theoretically though you could return multiple values like this though,

return ({%var1%:result.choices[0].message.content, %var2%:'hello world'})

It would have to be a non prompt [ ] method, maybe a box under user macros?

image

Webhook macros?

I’ll test the current implementation a bit more and explore some ideas of getting in multiple outputs

1 Like

Amazing stuff @Tim

Is it reusable for SCM chat using this feat to call SCM API? (function calling)?

You can kill a lot of birds with one stone (http/api tool)

A post was split to a new topic: AI model webhook, allow multiple return values

I think only if called inside user macros and it will need a new call method too.

I will need to play around with it to see what is best way to implement

Would be usable in chat if you set default to webhook

Webhooks for AI prompts have been added

image

image

Ready for testing!

ok … great … were you able to pass back multiple variables or just one returned variable?