# About Launching Scenario from Facebook Ads

Facebook Ads allows launching different bot scenarios for different advertising campaigns. This allows creating personalized experiences for different audiences and tracking effectiveness of each campaign separately.

---

## Context and Problem

In many cases, you need to launch different scenarios for different advertising campaigns:
- Different offers for different audiences
- Personalization based on traffic source
- Tracking effectiveness of each campaign
- Optimizing conversions for different campaigns

Launching scenario from advertising solves this task by allowing configuring a unique scenario for each advertising campaign.

---

## Key Concepts

### Configuration in Facebook Ads

To launch a scenario from advertising, you need to:
1. Create an advertising campaign in Facebook Ads
2. Configure "Call to Action" → "Send Message"
3. Select "Message Template" → "Create New" → "Partner App" → "Select Flow"
4. Get JSON code from Kwizbot and insert into Facebook Ads

### JSON Configuration

JSON code contains keyboard configuration with buttons:
- Buttons that lead to another block
- Link buttons with parameters `ActionType: "open-url"` and `ActionBody`

---

## Approach Options

### One Scenario vs Many Scenarios

**One scenario for all campaigns:**
- ✅ Pros: Simplicity of maintenance
- ❌ Cons: Impossibility of personalization for different audiences

**Many scenarios for different campaigns:**
- ✅ Pros: Personalization, effectiveness tracking
- ❌ Cons: More complex maintenance

**Why we use many scenarios:**
This allows creating personalized experiences for different audiences and tracking effectiveness of each campaign separately.

---

## Adopted Solutions

### Using Referral Tags

For tracking traffic source, referral tags (`ref`, `ref_source`, `ref_ad_id`) are used, which allow:
- Determining which campaign the user came from
- Personalizing messages based on source
- Tracking effectiveness of each campaign

### Button Limitations

Facebook Messenger Platform has limitations on button count:
- Maximum button count: 3 for initial message
- Some button types may not be supported in advertising

---

## Implications for Users and Implementation

### For Integrators

When configuring scenario launch from advertising, it's important to:

1. **Create unique scenario** — for each advertising campaign
2. **Configure keyboard** — with correct button types
3. **Get JSON code** — from Kwizbot and insert into Facebook Ads
4. **Add referral tags** — for tracking traffic source

### Common Errors

**Error:** JSON code does not work in Facebook Ads  
**Problem:** JSON does not match Facebook Messenger Platform format  
**Solution:** Check JSON format and Facebook Messenger Platform limitations

**Error:** Buttons do not display  
**Problem:** Button count limit exceeded or incorrect format  
**Solution:** Check button count and format

**Error:** Cannot track traffic source  
**Problem:** Referral tags are not added to URL  
**Solution:** Add referral tags to advertising campaign URL

---

## Usage Examples

### JSON Button Configuration

```json
{
  "ActionType": "open-url",
  "ActionBody": "http://example.com"
}
```

### Scenario Structure

1. Create "Message with keyboard" block
2. Add buttons according to types
3. Get JSON code from Kwizbot
4. Insert JSON into Facebook Ads

---

## Related Documents

- **Reference:** [Facebook Messenger Platform](https://developers.facebook.com/docs/messenger-platform) — official Facebook documentation
- **Explanation:** [Facebook Ads Referral Tags](/en/scenariodialog/explanation/facebook-ads-referral-tags.md) — tracking traffic source
- **Explanation:** [Inline Keyboard](/en/scenariodialog/explanation/inline-keyboard.md) — keyboard configuration

