Facebook Lead Generation
Lead generation can be done in the following ways:
By letting users fill out the form on Messenger, Facebook or WhatsApp. You can automate the process of sending messages to these users through NicoChat.
The course is divided into several sections.
- How you can connect NicoChat to your Facebook ads environment
- Create a lead form using instant forms (can be used inside FB ads)
- How you can send a WhatsApp message to a new lead
- How to send an SMS to a new lead
- Even how to call new leads if they provided their phone number
- How to redirect the user back to your Chatbot directly and instantly.
Connecting your Facebook page inside NicoChat
First you need to connect your Facebook page inside NicoChat.

Connecting NicoChat with Facebook Ads Manager
The same page the instant form is linked to.
The same Facebook page that is linked to the account on which you plan to run ads.
Integrations inside NicoChat
Integrations -> Others -> Facebook Ads
You need to connect your Facebook Ads business account here.

After clicking the button, you will be taken to the FB ad account integration page.

After continuing, one more page will appear where you need to enable the items mentioned:
- Manage ads for ad accounts you have access to
- Receive your email address <<email address>>
Once enabled, you can click Done.


Back to NicoChat Integrations -> Others -> Facebook Ads 👍
You can see that your Facebook Ads business account is connected.

Checking on Facebook whether NicoChat is assigned as a CRM tool
Next, we need to check whether NicoChat was installed as your CRM management system to receive the lead data.
Go to Facebook Account -> Business Manager -> Integrations -> Lead Access -> CRMs:
Here you must confirm that NicoChat was installed. That is what ensures you receive all the lead generation data.
If you do not see it, just type NicoChat and search: you should be able to find it.
Please connect your Facebook page inside the NicoChat platform.

Lead generation can only be received on the Facebook Messenger Channel or on the Omni-Channel. These are the two channels where we can create this type of automation.
Set the chatbot admin
Inside the Chatbot -> Tools -> Admins ->
It is important that you register yourself as an admin here, because all lead generation information will go to that specific admin, where you can set up the entire automation.
You can choose a new admin: search by name in the contact list and select one.
To receive the Lead Generation Data, you can use only Messenger Profiles or your Web Chat Profile, whichever you prefer. Either Profile needs to be an admin of the Chatbot.
Now you are ready to receive data from Meta when a new lead signs up through your instant forms.


Creating a lead form in Ads Manager
Create a new campaign
Open your Ads Manager account -> Create a new ad campaign

Under Campaigns, Create new campaign -> Choose “Leads” as your campaign objective.
Under Leads you can see:
- Instant forms - Capture the data and send it to NicoChat.
- Messenger
- Conversions
- Carts
After choosing Lead forms, click “Continue” to go to the “Choose a campaign setup” page

Now select Manual leads campaign and press Continue.

Now let's name the campaign “Lead form demo”.
Special ad categories: No changes
Campaign details: No changes
Advantage campaign budget: Off
Click the “Next” button to switch to the Ad set section.

The Ad Set section.
The most important thing here is that you will create a FORM. We leave the Ad set section untouched and click the Next button to go to the ADS section.

Ad Section - Create Form
We need to scroll down to the Form Section called “Instant form”. Let's create a form by clicking “Create form”

After clicking “Create form”, the following window will appear

Create form (Settings)

Field names: Email and Full name

Tracking parameters: Parameter Name and Parameter Value.

Create form (Content)
- Form name: Lead form demo
- Form type: More volume - (this depends entirely on the user's preference)

Just fill in your details below and I will send them to you.

If you need an additional field, such as Business Name or other data, you need to add a new question.
- Multiple Choice
- Short answer
- Conditional
- Appointment request

Prefilled questions: this is the data Meta already has. It makes users check the prefilled data from their Facebook, WhatsApp or Instagram accounts and then press OK
Description: We keep your data stored securely on our servers and will not share it with third parties.
We will use only the Prefilled questions and add contact fields, such as phone number, first name, last name and email address.
You can reorder them however you need.
They will be filled in dynamically.

Privacy Policy: it is also important to add the Privacy Policy. You can point to the link of your site for any type of privacy policy. Add the link of your site page.
Link text: TOS
Custom Disclaimer: You can also add this or leave it as it is.

Message for Leads
- Title: Thank you, everything is ready.
- Description: You can visit our site or exit the form now.
- Call to action button: View site | Call the business | View file
- Link: google.com/


Now we have our Form published, so you can set up your own complete ad. Creating ads is not the main goal of this document.
You should know how to set up your Facebook ads.

Lead form test
To test the Leads Form, go to the site https://developers.facebook.com/tools/lead-ads-testing

Note: you need to select the correct page.
Now all the lead forms you created will be displayed. You can preview the form by clicking the “Preview form” link and a window will appear, showing your ad along with the form you created.

All the user data is filled in automatically, with nothing to type. Just go through the data shown in the form, check that it is correct and press the Next button.
You can see all the user data, first name, last name, phone number and email in the form.
You can also create a lead by clicking directly on “Create lead”, and the lead is created. With that, we will send all the data to NicoChat, but before that we need to set up the Automation.
Create automation in NicoChat
Creating a SubFlow in NicoChat for Automations
Let's create a SubFlow called “Facebook leadgen”
Just like before, we need to go to Automations and create triggers inside them.
Now we can create this trigger inside the flow builder.
Click the Start Block -> Add Item -> Add Trigger -> Facebook LeadGen and enable it.

Here you can save the data we receive from Meta inside the custom fields.
- Webhook Payload: </> fb_lead_gen_data (JSON variable)
- LeadGen ID: fb_leadgen_id (text variable)
- Lead form ID: fb_leadgen_form_id (text variable)

You can also apply filters, if you want to prevent certain people from signing up for the Leads Form.
If you want to exclude them from the automation, that is also possible inside your NicoChat chatbot.
You can add a Note to this trigger, to have a bit more context about what it does. Let's press Save.
Now we have the Facebook LeadGen trigger enabled directly in this flow.

Now we need to fetch the User Details.
View the preloaded data: using the Message Block, displaying the entire payload.

This is used to test the data, since we need to set up our automation to receive sample data.
As soon as I press the “Create lead” button on the FB page “developers.facebook.com/tools/leads-ads-form” as shown before, the message “your test lead has been sent. To create a new lead, delete this one.” appears

Let's check in the Facebook Messenger profile whether I received the Payload.
I have just received the payload. Inside LiveChat, you will see the created time, the leadgen_id, the page_id and the form_id.

For example, let's take this “leadgen_id” data
Inside NicoChat, we will remove the Message Block and use the API Action.

Let's select the Facebook API related to the “Get Lead Gen” action function.

In Lead Gen, we need the lead gen ID, which we stored in the payload. Let's select the custom field “fb_leadgen_id” and paste the Test Value there to create the “Test Request”
Now that we have received all the lead generation data, let's map the first name, the last name, the phone and the email.

Let's map the lead generation data we need
- First Name: $.field_data[0].values[0] -> leadgen_first_name
- Last Name: $.field_data[1].values[0] -> leadgen_last_name
- Email: $.field_data[2].values[0] -> leadgen_email
- Phone Number: $.field_data[3].values[0] -> leadgen_phone
You can also save the creation time, if you want:
Creation time: $.created_time -> leadgen_time_stamp
All this data can be exported to a Google spreadsheet. That way, we can build many automations.
Sending a WhatsApp message template to the new lead
Modify the SubFlow in NicoChat for WhatsApp Messages. As you saw before, we mapped everything correctly. Now we will see the use case: sending a WhatsApp message template directly to the new lead.
The way to do this is quite simple:
In the previous SubFlow called -> Facebook leadgen, we are adding the following blocks:
Action Block -> Notifications -> WhatsApp template notification

Now you can select the phone number you need to send to.
In our case, we stored this number in the custom field “Leadgen_phone”, with a Number variable.
You can also choose the WhatsApp message template: in the dropdown, select any of the WhatsApp templates created earlier.
In our case, let's select the WhatsApp message template “Hello, World”.
You can also test receiving the WhatsApp template.



Sending an SMS about a new signup
Creating the SMS Bot for the LeadGen process
Let's create/modify the SubFlow created earlier to send the SMS during the lead generation process.
We will use the same setup with a few adjustments.
First, we need to make sure you have connected your phone number to your NicoChat workspace.
The SMS Channel must have some kind of phone number connected. In our case, we use the Twilio account to send the SMS message. But you can use other accounts as well, such as SignalWire and Message Media.

If you have one of these accounts, you can create an SMS Bot. After setting up your SMS Bot, you can use the registered number inside any of the Chatbots to send an SMS directly to a user or, in this case, to a new lead.

Let's take a look at the flow. Taking advantage of the previous feature of sending the WhatsApp message, we take the same flow, remove the Action Block connected to the WhatsApp message template and add an Action Block with SMS Notification.
Action Block -> Notifications -> SMS Notifications

Let's edit the SMS Notification Action Block, clicking “Edit Action”

Now we need to configure the SMS notification to send the SMS directly to the Lead Gen phone number:
- From Phone Number: the registered phone number.
- To Phone Number: Leadgen_phone (to the new lead's phone number)
- Message: Hello {{Leadgen_first_name}}, you have successfully submitted your data. Just type start to access your premium workshop. (the same as the WA message template)

Now, in the selected channel, you will be able to set up a flow for this. Let's go to the SMS Channel -> Open Bot.

Now let's set up the flow for this. Let's go to Automation -> Keywords -> New Keyword.
If the message contains one of the following keywords: start
Status: Active
Hotword: selected
Trigger SubFlow: “Lead generation opt-in workshop”

Now we have successfully set up the automation.
As soon as the user replies to the SMS they received — sent as soon as the Leadgen data arrives — we will be able to use an SMS notification to send the SMS to the user.
From there, we will be able to trigger the “Lead generation opt-in workshop” flow by setting up a keyword trigger.
As soon as the user types “start” or interacts with the SMS and replies to it, they automatically become a contact inside the SMS Bot.
That is how easy it is to send an SMS to a new lead, or to an existing lead as well.
Making a phone call through IVR
Creating the Voice Bot for the LeadGen process
Let's create a Voice Call for a new lead who signs up with your lead form in an FB ad, or on Messenger, on WhatsApp or on Instagram, wherever it was shown. As soon as the lead signs up, we will be able to call them, if we have their phone number.
In this use case, we also use the same phone number as the SMS Bot.

We are going into the main flow. We will always fire this Voice Call from the Main Flow, but we need to know what type of message to send.
Back in the “Facebook Leadgen” flow, we are adding the Action Block.

The Ref payload determines what type of message the Voice Call | Voice Bot will send to the user.
For example, if this is an ad for access to a Premium Workshop, let's say “adworkshop” - this will be the 'ref payload', which will be forwarded to the Voice Bot phone number.
From Phone Number: the phone number registered with the provider
To Phone Number: the Leadgen phone number stored in the custom field
Ref payload: adworkshop

Now let's set up the Automation on the Voice Bot side. Let's go to the Voice Bot's Main Flow:
Now we need to determine what type of message to send. By default, whenever the Voice Bot is activated, the Main Flow is activated.
From the Main Flow, you will be able to send the user to different parts of your Voice Bot.
The trick is to determine the payload we saved in the Action Block of the previous flow.
In the Main Flow -> Start Block
Save Ref Payload in: (in the custom variable of our preference) let's say “ref”

As soon as the user receives the call, this Main Flow will be activated. We will have received the payload “adworkshop”.
Now let's set up the automation based on that. We will add a Condition Block.
Condition Block -> if “ref” has any value

Then, with another condition, let's check what that value is. If it has no value at all, it simply goes to the regular main menu of the Voice Bot, for example.

If the “ref” payload is “adworkshop”, we can now set up a custom message.
Let's say:
“You have successfully submitted your data. Just type start to access your premium workshop”
Let's select Text and set the “Text to Speech Language” to English (US). In fact, you can choose among several countries and many Variables in the dropdown. Choose whatever works best for you.

- Text selected
- Text to Speech Language: English (US)
- Message for the Leadgen user:
This is how you activate your Voice Bot in your IVR flow, so you can respond to any new Leadgen user who enters your Omni-Channel chatbot.
Define what type of action you want to take after capturing the lead generation data.
Redirect users directly to the Chatbot from the lead form
Getting leads directly inside the Chatbot after the lead form is submitted.
Right at the end of the Leads Form, we have “Message for Leads”. You can customize this text however you want.
We have a title and a description, and also a CTA

Call to action
- View site: “Selected”
- Call the business
- View file

When we select View site, you can add a Ref URL under “Add a link”.
You can shorten this Ref URL with a link shortener, if you want.
This Ref URL can also contain several types of payloads, which directly activate certain data inside your own chatbot.

Let's go to the Chatbot.
Tools -> URL Triggers -> New Trigger. (Creating a New Trigger)

Let's create a new Ref URL trigger.
Name -> refurl ad workshop
Now let's save and edit this new “refurl ad workshop”
The best part of this Ref URL is that you can choose the channel where you want users to opt in.
You have different channels: Web | Facebook | WhatsApp | WhatsApp Cloud | Telegram | Line | Viber
- Name: refurl ad workshop
- Channel: Facebook.
- Status: Active
- Opt-In Flow: lead generation follow-up
- Custom reference parameter: access-premium-workshop
- Save Payload in custom user fields:
Payload: leadgen_ad_data

The Payload is basically a value saved in a specific CUF, to which you assign it.
If you have this Ref URL, we can assign a payload, an additional data source, by adding two hyphens ( - - ) and then the payload data.
The additional payload can be something like “Add Workshop”, “Add One”, “Copy One” etc.,
You can add up to 10 different payloads, customize them and save them in your CUFs.

The value “ad1copy1” will then be stored in a CUF assigned in the Payload list.
Let's give the CUF a name - “leadgen_ad_data”. This is the custom field that will store the value “ad1copy1”
In the ad text lead form -> Message for Leads -> Call to action text -> “access workshop”

This is an additional method to bring users directly back to your chatbot.
Instant forms let you set up all kinds of automation, instead of resorting to Zapier or Pabbly Connect to define these automations.
You can easily create automations inside the NicoChat platform itself.