Start n8n workflow from Salesforce flow with HTTP Callout

Hi there,

If you want an n8n flow to run when you change thing in Salesforce or when you start an screenflow in Salesforce and pass the information to other applications the HTTP callout is the right way to do it.

I recently shared a tip connecting Salesforce and n8n with outbound message: Outbound message Salesforce and n8n - Tips & Tricks - n8n
Now I would like to share an improved connection between n8n and Salesforce with the new HTTP Callout in SF. This connection is more secure and modern way to connect n8n with SF.

It takes some time to set up correctly but i think the following steps will help you get there.

Read the steps in Salesforce to configure the HTTP Callout. Configuring an HTTP Callout Action (salesforce.com) to understand what it is and how it works.

Follow this youtube video to set it up with more direction, See the next link for authentication. Create HTTP Callout for Salesforce Flow (Spring '23 Beta Feature) - YouTube

To configure the right Authentication in Salesforce for n8n follow this instruction. and copy paste your self made webhook apikey into Salesforce. How to set up Header based API Key authentication in External Services? | forcePanda (wordpress.com)

The JSON input for the flow is standard {“message”:“Workflow was started”} but it depends what you want send back to Salesforce. The value the n8n flow gives back to Salesforce you will have to define in the flow.

Tip: HTTP Callouts can only run as Asynchronously in Salesforce

This is a quick summary of what is possible. If you have any question please ask :slight_smile:

2 Likes

Hey! Exciting post. I would appreciate a more detailed walkthrough of this, including on the n8n side. I’m having a hard time seeing an example workflow with this solution. I would appreciate a bit more on the salesforce side too in terms of the flow action set up.

Thanks very much for sharing here in the community. It took a longtail search to surface your Salesforce posts.

Hi trijste, Well, the n8n side of this is easy :slight_smile:

There is a webhook node that receives the Salesforce HTTPS Callout. I only send the SF ID to n8n and use the SF nodes to gather the rest of the information.
image
In n8n you have to add the Webhook and make a new header credential like this, just generate a password. NB: there is a maximum lenght of the token that SF can handle make it long but not too long.

Just add this as the header based API key to SF like the instruction videos above describe.
Hope this helps.

1 Like

@timautomation ,

I only send the SF ID to n8n and use the SF nodes to gather the rest of the information.

It sounds like an overkill. I have always been using Outbound messages where you can already provide n8n with all the data you need to process further. Can that be done with HTTP Callout too?

Also, it sounds like while Outbound messages would be used when SFDC passes the data over to external services whereas HTTP callout serves the opposite purpose - SFDC initiates a request to get the data from an external service. Did I get it right?

Yes, it is a little bit of an overkill… You can do that with HTTP callout too, it was just easier to do it this way in the beginning.

With http callout you can do both :slight_smile: And because of the bearer token it is more secure.

1 Like

Hi @timautomation, I know it has been some time. I wanted to thank you as I was able to get this working. I used basic auth instead of the header auth and set the Generate Authorization Header option to true in the named credential callout options.

1 Like