Join us in San Francisco on the 29/30th of October for two days of developer workshops and technical talks

Understanding Facebook messaging

Only individuals may create a Facebook Profile. However, an individual can use their Profile to create a Facebook Page for a business.

A Facebook user must initiate communication using Facebook Messenger via the business's Facebook Page. A message from the business to the Facebook user will otherwise be refused.

Facebook Messenger uses its own form of IDs for the Facebook User and the Facebook Page :

The Facebook User will have a Page-scoped ID (PSID) and this is unique for each Facebook Profile. The business can only obtain the PSID of a user when the user sends a message to the business. In Facebook Messenger, the default is for the customer to initiate a conversation with a business.

In order to get started with Facebook Messenger you will need to link your business's Facebook Page to Nexmo.

NOTE: The link between your Nexmo account and Facebook page expires after 90 days. After then you must re-link it.

Linking your Facebook page to your Nexmo account allows Nexmo to handle inbound messages and enables you to send messages from the Nexmo Messages API.

IMPORTANT: This process needs to be authenticated by JWT. The JWT generated in this case can be based on any Application ID in your account, as this JWT is only used to authenticate the linking process, and it not used to authenticate application-specific API calls.

You will need to paste in a valid JWT. If you don't have one you can create one as follows:

1. Create a temporary application:

nexmo app:create "Delete Me Later" --keyfile=temp.key --type=messages

2. Copy the generated Application ID to the clipboard.

3. Generate a JWT with the following command, pasting in your Application ID:

JWT="$(nexmo jwt:generate ./temp.key application_id=YOUR_APP_ID)"

TIP: This JWT will expire after the default 15 minutes.

4. Display the generated JWT:

echo $JWT

5. Copy the JWT to the clipboard.

You are now ready to link your Facebook Page to Nexmo:

6. Click the following link when you have your JWT pasted to the clipboard and you are ready to link your Facebook Page to Nexmo:

You will see your Facebook Pages listed.

7. Select the Facebook Page you want to connect to your Nexmo account from the drop down list.

8. Paste your JWT into the box labeled "2. Provide a valid JWT token".

9. You will receive a message confirm successful subscription.

At this point your Nexmo Account and this Facebook Page are linked.

NOTE: If at some point in the future you want to further link a specific application to this Facebook Page you can now do this from the Dashboard on the External Accounts tab for the specific Messages and Dispatch application you want to link.

Re-linking your Facebook page to your Nexmo account

The link between your Nexmo account and Facebook page expires after 90 days. You can re-link it by performing the following steps:

1. Generate a new temporary application and an associated JWT using the same process that you used to create the initial link.

2. Visit the following page and select the page you want to re-link from the drop down list:

3. Paste the JWT you generated in step 1 into the "Provide a valid JWT token" text box.

4. Click "Unsubscribe".

5. When the page is successfully unsubscribed, re-link it by clicking "Subscribe".