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.

Next you'll need to link your Facebook Page to your Nexmo account. This will allow Nexmo to handle the inbound messages and allow 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" https://example.com/inbound https://example.com/status --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.