Download PDF
Steps Prerequisites Create Account and Page Create Facebok App App Token Generation Integrate App in Ameyo --(Normal Method) Integrate App at Backend --(Recommended Method) Integrate App via OAuth Submit App for Review Settings of Facebook Media Profile Delete Facebook Media Profile Ticket Resolver

Facebook Media Profile

This media profile lets you interact with your clients using the Facebook. You can interact with posts, comments, and messages using it. It is requried to perform the following steps sequentially for creating a Facebook Messenger Media Profile.

  1. Create Facebook Account and Page
  2. Create Facebook App and Make it Public
  3. Generate App Access Token for your Facebok Page
  4. Integrate the App with Ameyo
  5. Submit Your App to Facebook for Review
Prerequisites
  1. Facebook Login Credentials
  2. Facebook Page
  3. Facebook App registered with Facebook

If above prerequisites are not met, perform the following steps.

Create Facebook Account and a Facebook Page
  1. Create a Facebook account for the organization.
  2. Go to Facebook.com, fill the required details, and click "Sign Up".

    You need to confirm your email or mobile phone number. Refer to "How to create Account on Facebook" page for more information.

  3. Visit Create a Facebook Page, select a Page Type, and follow onscreen instructions to create a page.

    Refer to "How to create a Facebook Page" for more information.

Create Facebook App

Perform the following steps to create a Facebook App.

  1. Visit "Facebook Developers Portal" and login with your credentials.
  2. Go to "My Apps" and click "Add New App". It shows the following pop-up.

    Start Adding a New App

    Figure: Creating a New Facebok App

  3. Provide the display name for App and your contact email address.
  4. Click "Create App ID".
  5. Verify "CAPTCHA", if it appears. The following page is displayed.

    Select Product

    Figure: Asking to select product to create Facebook Page

  6. Do not click on any product here. Rather, Click "Settings" in the left panel to expand its items, and then click "Basic". It shows the following page.

    Basic Settings

    Figure: Basic Settings

  7. Enter the value of following fields.
    1. Privacy Policy URL: Enter the URL of the privacy policy of your organization. It may be "Privacy Policy" page hosted at your Website.
    2. Select the category as "Business and Pages".
    3. Select "Support my own business" in "Business Use" section.
    4. Upload an app icon of the required size.
    Following is a screenshot with sample details.

    Sample Settings

    Figure: Sample Basic Settings

  8. Scroll down and click "+Add Platform". It shows the following pop-up.

    Platforms

    Figure: Platforms for Facebok App

  9. Select "Website". It shows the following box.

    Website Box

    Figure: Textbox to provide Website URL

  10. Enter the URL of your Website where Ameyo Server is running. Preferrably, it should be in HTTPS format.
  11. Click "Save Changes".
  12. Now, click "App Review" in the left panel. It shows the following page.

    Make App Public

    Figure: Make your App Public

  13. Click the toggle switch in "Make <App_Name> public?" section to make your App public.

    Do not submit your App for approval here.

Facebook App Token Generation

Perform the following steps to generate the access token for your app.

  1. Visit "Facebook Graph API Explorer" and login with your credentials.
  2. Select the App for which you want to generate the token.

    Select App

    Figure: Select App

  3. Select "User Access Token" in the drop-down menu.

    Select Token

    Figure: Select Token

  4. After selecting the token, you have to select the permissions.

    Select Permissons

    Figure: Select Permissons

  5. Clck "Get Access Token" to get the access token. You will get a token here, which you have to copy and reuse to generate a final token.
  6. Now, you have to enter these details in the following URL format.

    https://graph.facebook.com/oauth/access_token?client_id=<APP_ID>& client_secret=<APP_SECRET>& grant_type=fb_exchange_token&fb_exchange_token=<ACCESS_TOKEN>

    Here, you have to replace <APP_ID>, <APP_SECRET>, and <ACCESS_TOKEN> with your own values.
  7. Open this URL in a Web browser. The browser will dipslay the access token.

    Access Token

    Figure: Access Token

  8. Copy this access token and paste it into the Graph API Explorer. Now, type the following two words in the explorer.

    me/accounts

  9. Click "Submit" button. A set of code appears in the textarea.

    Highlighting Access Token

    Figure: Required Access Token

  10. This code is actually giving the access tokens for all of your Facebook pages and accounts. Note down the access token for your page. This is the final token.
Integrate your App in Ameyo

There are following two ways to integrate your App in Ameyo to create a media profile.

(Normal Method) Integrate Facebok App at Backend

Now, you have the following prerequisites.

Perform the following steps to integrate the Facebook App in Ameyo through backend.

  1. Access the Operating System through Putty and execute the following commands to enter the PostgreSQL system.

    psql -U postgres

  2. In the PostgreSQL console, execute the following command to enter your database.

    \c <DB_Name>

    Replace <DB_Name> with the name of database that has been integrated with your Ameyo App.
  3. Execute the following command to enter Media Profile ID, Username, Access Token, App ID, and APP Secret in "facebook_profile" table.

    INSERT INTO facebook_profile (media_profile_id,user_name,access_token,app_key,app_secret,should_fetch_conversation) values ('<media_profile_id>','<user_name>','<access_token>','<app_id>','<app_secret>',true)

    Replace the following values.

    Samle Attribute

    Required Value

    <media_profile_id>

    Provide a unique ID for your media profile.

    <user_name>

    Facebook Username

    <access_token>

    Access Token

    <app_id>

    App ID

    <app_secret>

    App Secret

  4. Execute the following command to enter the Media Profile details in "media_profile" table.

    INSERT INTO media_profile (media_profile_id,media_entity_name,media_profile_type,fetch_timer_interval,is_incoming_allowed,is_outgoing_allowed,contact_center_id,escalation_priority) values ('<media_profile_id>','<media_entity_name>',<media_profile_type>,'180','t','t','1','100');

    Replace the following values.

    Samle Attribute

    Required Value

    <media_profile_id>

    Provide the same Media Profile ID that you have entered in "facebook_profile" table.

    <media_entity_name>

    Provide a unique name for your Media Profile. If you are creating multiple media profiles, make sure that all have unique names.

    <media_profile_type>

    Type FACEBOOK

  5. Execute the following command to make an entry in "interaction_resolver_configuration".

    INSERT INTO interaction_resolver_configuration (media_profile_id,resolver) values ('<media_profile_id>','["socialmediainteractionresolvervalue"]');

    Replace <media_profie_id> with the ID of your Media Profile that you have entered in "facebook_profile" table.

  6. Now, execute the following command to exit from database console.

    \q

  7. Execute the following command to restart the appserver service.

    ameyoctl service appserver restart

Facebook Media Profile has been created now. You have to submit your App for review to Facebok and then use this media profile in the campaign.

(Recommended Method) Integrate Facebook App via OAuth in Ameyo

It is the recommended method to integrate your Facebook App via OAuth in Ameyo Server. For this, you have to generate redirection URL for App, make entries at the backend, provide OAuth URL in Facebook App, and then integrate App in Ameyo through User Interface.

  1. Redirect URL: Following will be redirect URL for your Facebook App in Ameyo Server.

    http://<App_Server_IP>:<PORT>/oauth/oauth/facebook

    Replace App_Server_IP with the IP Address of your Ameyo Server App, PORT with the Port Number where Ameyo Server is running (that can be 8888 by default).
  2. Commands for the Backend: Perform the following steps.
    1. Access the Operating System through Putty and execute the following commands to enter the PostgreSQL system.

      psql -U postgres

    2. In the PostgreSQL console, execute the following command to enter your database.

      \c <DB_Name>

      Replace <DB_Name> with the name of database that has been integrated with your Ameyo App.
    3. Execute the following command.

      INSERT INTO APP_OAUTH_CONFIGURATION (CONSUMER_ID, SERVICE_PROVIDER, OAUTH_AUTHORIZATION_URL, OAUTH_AUTHORIZATION_REDIRECT_URL, OAUTH_SCOPE_VALUES, OAUTH_TOKEN_REQUEST_URL, OAUTH_TOKEN_REQUEST_REDIRECT_URL, OAUTH_REVOKE_ACCESS_URL, CLIENT_ID, CLIENT_SECRET, ERROR_PAGE, DESCRIPTION) VALUES (125,'FACEBOOK','https://www.facebook.com/v2.8/dialog/oauth',<redirect-url>,'publish_pages,read_page_mailboxes,manage_pages','https://graph.facebook.com/v2.8/oauth/access_token',<redirect-url>,'',<App-Id>,<App-Secret>,'http://<App_Server_IP>:<PORT>/oauth/error.html','');

      Replace the following inputs.
      • <redirect-url> with your redirect URL
      • <App-Id> with your App ID
      • <App-Secret> with your App Secret
      • <App_Server_IP> with the IP Address of your App Server
      • <PORT> with the Port Number where your App Server is running
    4. Execute the following command.

      INSERT INTO APP_OAUTH_REQUEST_PARAMETER (CONSUMER_ID, TYPE, PARAMETER_NAME, PARAMETER_VALUE) VALUES(125,'AUTH_REQUEST','response_type','code');

    5. Execute the following command. INSERT INTO APP_OAUTH_REQUEST_PARAMETER (CONSUMER_ID, TYPE, PARAMETER_NAME, PARAMETER_VALUE) VALUES(125,'ACCESS_TOKEN_REQUEST','grant_type','authorization_code');
    6. Execute the following command.

      INSERT INTO APP_OAUTH_RESPONSE_PARAMETER (CONSUMER_ID, TYPE, PARAMETER_NAME) VALUES(125,'ACCESS_TOKEN_REQUEST','token_type');

  3. Add Redirect URL in the Facebook App: Perform the following steps.
    1. Visit "Facebook Developers Portal" and login with your credentials.
    2. Go to "My Apps" and select your application.
    3. Select "Settings" in the left panel.

      Providing OAuth URL in Facebook

      Figure: Providing OAuth URL in Facebook

    4. Here, you have to provide the OAuth URL in the box titled "Valid OAuth Redirect URIs".
    5. Click "Save Changes".
  4. Integrate Facebook App in Ameyo Server:

    Perform the following steps to create a Facebook Media Profile.

    1. Go to "System" → "System Configuration".
    2. Click "Media Profile" tab.
    3. Click "Add" to create a media profile.
    4. Click "Continue with Facebook" to create a Facebook Messenger Media Profile using the following pop-up.

      Add Facebok Media Profile

      Figure: Add Facebok Media Profiile

    5. Click "Authorize Facebook". It shows a pop-up, where you have to click "Continue" and then "Allow" to allow the Ameyo to access your account. It shows the list of pages in your Facebook account.
    6. Select the required Facebok page.
    7. Enter the name of your page and click "Register".
    Your Facebok Media Profile is created.
Submit Your Facebok App for Review

Perform the following steps.

  1. Visit "Facebook Developers Portal" and login with your credentials.
  2. Go to "My Apps" and select your application.
  3. Now, click "App Review" in the left panel. It shows the following page.

    Submit App for Review

    Figure: Submit your App for Review to Facebook

  4. Click "Start a Submission" button. It shows the following pop-up.

    Review Form

    Figure: Select App Usage

  5. Select "manage_pages" and "publish_pages" and click "Add 2 Items" button. It shows the following page.

    Review Form

    Figure: Add Details

  6. Click "Add Details" for "publish_pages".

    Final Step

    Figure: Add Details

  7. Here, you have to provide the following inputs.
    1. Tell us how you're using this permission or feature: Click the following link to visit the next page, which contains the text that you can copy and paste in your Facebook App Submission page. Press the back button in the end of the page to come back at this point.

      Required Content to Submit Facebook App

    2. Click "Web" to select Web as your platform.
    3. Now, you have to upload a Video that shows the screen recording of the steps documented in the pop-up (that opens upon clicking the button).

      You can get this video from the Service Delivery Team.

    4. Click Save.
  8. Now, you have to repeat the same steps to add the details for "manage_pages".
  9. Click "Submit for Review" button to submit the App for review.

After approval, you can normally use the Facebok Media Profile in the campaigns.

View and Modify Settings of Facebook Media Profile

Select a Facebook media profile in the list to view its settings on the right side under "Settings" tab.

Settings of Facebook Profile

Figure: Settings of Facebook Media Profile

You can modify the settings here and click "Apply" to apply the same. Rather, you can click "Refresh" to discard the changes.

Delete Facebook Media Profile

The deleted Facebok Media Profile cannot be retrieved back. The campaigns, queues, and users using this Media Profile will be disabled to use the Facebook to interact with your clients.
Also, it is associated with your Facebook App. If you delete it now and again try to create a new Facebok Profile, you have to go through the Command Line Interface to execute the commands and submit the App again to Facebook for review.

Perform the following steps to delete a Facebook media profile.

  1. Select a Facebook media profile.
  2. Click "Delete" to delete it. It shows the following warning message.

    Facebook Profile Deletion Warning

    Figure: Asking to delete the Facebook Media Profile

  3. Click "Yes" to delete the media profile. Rather, you can click "No" to not delete it.
Ticket Resolver for Facebook Profile

This tab lets you manage how the tickets in a campaign (where the selected media profile is added) will be handled. Following is a screenshot of Ticket Resolver Tab of Facebok Media Profile.

Ticket Resolver of Facebook Profile

Figure: Ticket Resolver of Facebook Media Profile