Webhooks in Salesforce using Streamscript

Streamscript enables Salesforce Flows to send REST API calls and respond to webhooks, using formula-like statements and actions. Streamscript runs inside Flow so it benefits from flow security settings, flow versioning and flow tests.

Scripts bring CSV, XML, JSON capabilities (and more) directly into flows. This example video shows how to create a Salesforce webhook integration, using a flow triggered by web requests:


Webhook Flows run exclusively on your Salesforce Site and no data passes through any other server. Follow the site setup video if you haven't yet got a Site, then open the Integrations tab:



Getting started

This example shows how to parse JSON in flow:

  1. Install the Streams package in Sandbox or Production (direct URL)
  2. Go to Setup > Flows > New Autolaunched Flow
  3. Add an action element, type: Streamscript
  4. Copy and paste the below exchange rate example into your step:
# Streamscript
$http = GET 'http://api.exchangerate.host/live?access_key=...'
$result = JSON-Decode $http.body
return $result.quotes.USDEURTry

Save the flow, then click debug. That's it! You just integrated live exchange rates into your flow. You'll need to add a Remote Site Setting for the example. Then use the editor in flow builder to test and iterate your logic.




Show more videos...



Show more tutorials...



Streams Q&A

Q: Where is the package?
Here is the install URL: /packaging/installPackage.apexp?p0=04t7F000005N1wy

Q: What is inside the package?
The package contains: 1 custom object, 5 apex classes, and 1 LWC for the script editor.

Q: I'm not a coder, can I use Streamscript?
Yes. If you've used formulas, it will feel familiar. Try our AI Prompts tutorial video and generate your first script automatically instead of starting from scratch.

Q: Doesn't this overlap Salesforce functionality?
Yes. Platform aspects like HTTP callouts have changed since the first release of Streams. We recommend using declarative features where possible. Check out these alternatives, each with a unique approach to bring a specific area of focus into Flow:
- Apex actions - Chris, Professor Flow
- Slack integration - Jack Pond, UnofficialSF
- Callouts (Beta) Spring '23 - Joseph Thomas, P&N Bank
- Mini Postman with Invocable Callout - Munawir Rahman at Gojek

Q: I don't see the point. Can you explain where script is used?
Script solves immediate needs (like webhooks) without waiting for declarative tools. Flow is for business processes and users may choose the approach best suited to their business. The right tool for the job may be config or code or a combination of both.

Q: Functions wrap logic in general form. Can I call functions in other scripts?
No. Scripts are self-contained and don't reference external dependencies. This ensures a script can be versioned within flow and deployed to any environment as a single logical unit.

Q: How can I send auth headers in my HTTP callout?
Set up a Named Credential then use as follows: Http-Post 'callout:My_Cred/path/to/api'
Avoid handling session ids, usernames, passwords or authentication tokens within your logic.

Q: Is the package security reviewed?
Yes. Latest details here. Streams is published on the AppExchange with Aloha status from Salesforce. At install you can click 'View Components' to verify it contains no integrations.

Q: Is this related to OmniScript, Mule DataWeave scripts, or AMPscript?
No. Those are external hosted environments. Streamscript only runs in native Salesforce flows.

Q: How do I access the results of script in subsequent steps?
One-line scripts automatically return the result of the expression. Streamscript will set the output variable (num, bool, text, list, record, records) according to the result data type.
Multi-line scripts use the return keyword. For example: return $num or return $list
Note: when returning SObjects, the variable name must be the type, eg: return $Account

Q: Does it support bulkification?
Yes. Best practice for record-triggered flows is to use the Bulk directive. In bulk mode, Streamscript will run once instead of many times. Inputs or merge fields will contain lists instead of a single value. Outputs or return values will expect lists instead of a single value.

Q: Is this free? What do you gain in return?
Yes. In return we hope you'll consider us for your next project.

Q: Can I offer script capabilities in my company's package?
Yes. Contact us and we will assist.


Getting started with Streamscript
Install from the Salesforce AppExchange
Package install link: /packaging/installPackage.apexp?p0=04t7F000005N1wy