Sample Messenger Experience - Original Coast Clothing

Original Coast Clothing (OCC) is a fictional clothing brand created to showcase the key features of the Messenger Platform delivering a great customer experience. Using this demo as inspiration, anyone can create a delightful messaging experience that leverages both automation and live customer support. Open-source code for the app and a guide on how to deploy the experience on your local environment or remote server are provided. There is also a companion sample Instagram experience.

Access the Messenger experience


This Messenger experience is designed to inspire and accelerate development. The guide shares design materials and source code to help with development.

Original Coast Clothing has a demo Messenger automated experience as well as a Facebook Page and an eCommerce website to show entry points.

Experience highlights

The website uses the Customer Chat Plugin

QR Code with link to trigger a promotional discount for the summer collection

Click to Messenger Ad displayed as a post on the Original Coast Clothing Page

Flow diagram

It is highly recommended to map out the intended experience in a Flow Diagram. Here is one for reference:

Original Coast Clothing Flow Diagram

Platform features

This experience leverages the following platform features listed below. If you decide to deploy the experience on your Page, the code will use them all:

Deploy this experience on Messenger

By the end of this guide, you'll have a full Messenger app running on your server, answering messages from your test Page.

The code that powers this experience is open-source. Anyone can easily get started with developing a great messaging experience for a business. Once complete, you'll be able to engage with your Page via Messenger and get automated responses from your server.

The code is released under the BSD License, allowing you to use it freely for your business needs. The code is hosted on GitHub for further reference.

Requirements to deploy a Messenger app

  • Facebook Page: Make sure that you have a Facebook Page since it represents your business identity when connecting with people on Messenger. To create a new Page, visit, you can also set up a test Page to start.

  • Developer Account: Required to create new apps, which are the core of any Meta technologies integration. You can register as a developer by going to our Developers website and clicking the "Get Started" button.

  • Facebook App: Contains the settings for your app, including access tokens. To create a new app, visit and click on Add New App

Setup Page and app

The objective of this section is to gather all the access tokens and ids necessary for the Messenger app to successfully send and receive messages. Before you begin, make sure you have completed all of the requirements listed above. At this point you should have a Page and a registered Facebook app.

If you just created a new Facebook app, it is probably in development mode. Note that apps in this mode are only allowed to message people connected to the app (Admins, Developers and Testers). You can continue with this guide in this mode, but once your app is ready to be public, the app needs to go through app review for the pages_messaging permission. For more info, see App Review

Additionally, this experience uses extended Page features and app permissions that also need review, to allow the app to read the user gender and locale fields. Again, apps in development mode can see these fields only for the people connected to the app. For more information, see User Profile API

Now let's collect the following values for your configuration


Let's get the App ID and App Secret

  1. Go to your app Dashboard and then to Basic Settings
  2. Save the App ID number and the App Secret

Grant Messenger access to your Facebook app

  1. Go to your app Dashboard
  2. Under Add Product find Messenger and click Set Up
  3. Now you should be in the app Messenger Settings
  4. Under Access Tokens, click on Edit Permissions
  5. Select the desired Page and allow Manage and access Page conversations in Messenger
  6. Select the desired Page and an access token should appear
  7. Get the Page ID from the Page access token by using the Access Token Debugger

At this point you now have all the environmental variables and assets needed to run the app. You can run it on your local machine or hosted on Heroku. It's recommended to have a Development, Staging, and Production Environment, each of them will need their own Page and app pair.

Run it on a local environment

Now it's time to get the code and run it on your local machine. You'll need NodeJS 10.x or higher, check your current version with the following command

node -v

Clone this repository on your local machine:

git clone
cd original-coast-clothing

Install the code dependencies

yarn install

Using ngrok to get incoming messages

In order to receive messages, we need to be able to get incoming webhooks from our Servers. So we need an external address, a quick way to do this is to use ngrok since it will provide an external https address that will tunnel into your NodeJS running app.

If not already installed, install ngrok via download or via command line:

npm install -g ngrok

In the directory of this repo, request a tunnel to your local server with your preferred port

ngrok http 3000

The screen should show the ngrok status:

Session Status                online
Account                       Redacted (Plan: Free)
Version                       2.3.35
Region                        United States (us)
Web Interface       
Forwarding           -> http://localhost:3000
Forwarding           -> http://localhost:3000

Connections                   ttl     opn     rt1     rt5     p50     p90
0       0       0.00    0.00    0.00    0.00

Note the https URL of the external server that is fowarded to your local machine. In the above example, it is

Set webhooks and Messenger Profile

Now we have all the elements needed to run the app. Back into the first terminal, let's use the provided template to fill all the environmental values.

mv .sample.env .env

Edit the .env file to add all the values for your app and Page as collected in previous steps. Note that for VERIFY_TOKEN you should set a random string, the app will use it to validate API calls.

Run your app locally using the built-in web server

node app.js

You should now be able to access the application in your browser at http://localhost:3000

The app is able to configure webhooks subscription settings on the Facebook app and configure the Page Messenger Profile all via the API.

Trigger the code that sets the configuration. Note that you need to use the value for VERIFY_TOKEN added in .env file. Call the /profile endpoint like so:


Test app setup

Send a message to your Page from Facebook or in Messenger, if your webhook receives an event, you have fully set up your app! Voilà!

Let's make a code change

Let's edit the file locales/en_US.json, replacing the message under get_started.welcome and change it from "Hi {{userFirstName}}! Welcome to Original Coast Clothing..." to something else.

Back on the first terminal, every time you change the code, you'll need to restart the NodeJS server. Let's stop the server with Ctrl-C and run it again, to reload the new code.

node app.js

Open your Messenger and message your Page the word "Hi", you should get the new message.

Deploy the app on Heroku

As an added bonus if you want to deploy this as a Heroku app, here are the steps that will allow you to do just that. A Heroku instance can be used to host the production or staging environment for your business Page.

You'll need the Heroku CLI, check if you don't already have it, with the following command

heroku -v

Create a Heroku app from the CLI

git init
heroku apps:create
# Creating app... done, ⬢ mystic-wind-83
# Created |

Deploy the code to Heroku

heroku git:remote -a mystic-wind-83
git push heroku master

Set environment variables (Config Vars)

On Heroku the environment is not set up via a .env file but by setting your Heroku app Config Vars. You can find them in your Heroku app dashboard,

Similar to the Setup step needed for development setup, you'll need to set the same variables described in the the .sample.env. If this is the production environment, the page id and corresponding page access token, will be for the business Page instead of the test Page used on the development environment.

Alternative to the Heroku app dashboard. you can set the values for each of the required vars directly on the terminal.

heroku config:set APP_ID="<VALUE>" -a mystic-wind-83
heroku config:set APP_SECRET="<VALUE>" -a mystic-wind-83
heroku config:set APP_URL="" -a mystic-wind-83
heroku config:set PAGE_ID="<VALUE>" -a mystic-wind-83
heroku config:set PAGE_ACCESS_TOKEN="<VALUE>" -a mystic-wind-83
heroku config:set VERIFY_TOKEN="<RANDOM-STRING>" -a mystic-wind-83
## Default value example
heroku config:set SHOP_URL="" -a mystic-wind-83

Set webhooks and Messenger Profile

You should now be able to access the application. Use the VERIFY_TOKEN that you created as config vars and call the /profile endpoint like so:<VERIFY_TOKEN>

Optional The above URL will return the ids of personas uploaded. Since they are held in memory, you need to add those returned ids as Config Vars, so they can persist after a reload.

heroku config:set PERSONA_BILLING=<PERSONA_ID> -a mystic-wind-83
heroku config:set PERSONA_ORDER=<PERSONA_ID> -a mystic-wind-83
heroku config:set PERSONA_SALES=<PERSONA_ID> -a mystic-wind-83

Test app setup

Send a message to your Page from Facebook or in Messenger, if your webhook receives an event, you have fully set up your app! Voilà!


Rerun app locally

After running ngrok, a new external address will be provided. Update the APP_URL address on the .env file, then run the NodeJS server.

node app.js

Update the webhook address on the Facebook App Settings by visiting http://localhost:3000/profile?mode=webhook&verify_token=<VERIFY_TOKEN>

My Page only replies to me, but not someone else

The Facebook app is likely still in Development Mode. You can add someone as a tester of the app, if they accept, the app will be able to message them. Once ready, you may request the pages_messaging permission to be able to reply to anyone.

Other Issues

Is this guide wrong?, let us know by filing an Issue