pinecallDocs
Integrations / Messenger & Instagram

Messenger & Instagram

A Facebook Page and its Instagram account, answered by the same agent, in writing.

Connect a Facebook Page and the same agent that answers your phone answers its Messenger, and the Instagram account linked to the Page, in writing. Each contact is one conversation, and your team reads and joins it from the console like any call.

How it works#

A Page is an account of your org, like a WhatsApp number. Its id points at one agent with the channel messenger, and its Instagram account's id with the channel instagram, in the sandbox or in production. When a contact writes:

Your agent's code does not change. The call's channel is messenger or instagram, both written, and the prompt tells the model how to write for each: Pinecall's own words, or yours with channelRules = { messenger: "…", instagram: "…" } (The prompt).

The agent only answers on these channels. Meta lets a Page reply within 24 hours of a contact's last message (up to 7 days after an ad that opened the conversation), and nothing writes to a contact first.

Connect a Page#

A Page and its Instagram account are answered through a Meta app that you own, the one your WhatsApp number may already live in. The steps below take about twenty minutes the first time: the Instagram account and the Page are linked, the app is given the permissions, a Page token is made, and the Page is connected to Pinecall, which sets the app's webhook itself.

1. Make the Instagram account professional#

Instagram lets an app read and answer only a professional account.

  1. Signed in to Instagram as the account, open instagram.com/accounts/convert_to_professional_account (or Settings ▸ Account type and tools ▸ Switch to professional account).
  2. Pick a category and choose Business. A business account is public.
  3. In the Instagram app on the phone: profile ▸ ☰ ▸ Settings and privacy ▸ Messages and story replies ▸ Connected tools, and turn on Allow access to messages. Without it Instagram keeps the account's messages from every app, and nothing reaches Pinecall.
  1. On Facebook, open your Page and switch to it (act as the Page).
  2. Open facebook.com/settings/?tab=linked_instagram ▸ Connect account, sign in to Instagram and accept.
  3. If that page does not offer it, use Meta Business Suite: pick the Page at the top ▸ Connect Instagram account.

Facebook answers "The your Page Facebook Page is now connected to the @account Instagram profile".

3. The Meta app#

  1. In developers.facebook.com/apps open your app, or Create app with the use case Engage with customers on Messenger from Meta, in your business portfolio.
  2. In the use case's Permissions and features, pages_messaging, pages_manage_metadata, pages_read_engagement, pages_show_list, instagram_basic and instagram_manage_messages are Ready for testing (press Add on any that is not).
  3. App settings ▸ Basic ▸ App secret ▸ Show: keep it for step 5. It signs every message Meta delivers for the Page and its Instagram account.

4. A Page token that answers both#

The token Messenger API Settings ▸ Generate access tokens makes carries pages_messaging alone: it answers Messenger and nothing on Instagram. A token for both comes from the Graph API Explorer:

  1. Open the Graph API Explorer, pick your app under Meta App, and User Token under User or Page.
  2. Under Permissions, add pages_show_list, pages_messaging, pages_manage_metadata, pages_read_engagement, instagram_basic, instagram_manage_messages and business_management.
  3. Generate Access Token. In Meta's window choose Opt in to current … only at each step and tick just your Page, your business and your Instagram account; then Save.
  4. That token lasts an hour. Make it a long one, and take the Page's token from it, which does not expire (in a terminal; USER_TOKEN is the Explorer's, APP_ID and APP_SECRET your app's):
Terminal
$ curl -s "https://graph.facebook.com/v21.0/oauth/access_token?grant_type=fb_exchange_token&client_id=$APP_ID&client_secret=$APP_SECRET&fb_exchange_token=$USER_TOKEN"
{"access_token":"EAA…","token_type":"bearer"}
$ curl -s "https://graph.facebook.com/v21.0/PAGE_ID?fields=access_token,instagram_business_account{id,username}&access_token=LONG_USER_TOKEN"
{"access_token":"EAA…","instagram_business_account":{"id":"17841400000000001","username":"your_account"},"id":"PAGE_ID"}

The second answer's access_token is the Page token, and instagram_business_account.id is the Instagram account's id. The Page's id is in your Page's About, or in the app's Messenger API Settings.

5. Connect it#

There is nothing to type at Meta for the webhook: as the Page is connected, Pinecall gives your app its webhook (the same Callback URL and Verify token your WhatsApp number uses, shown by pinecall carriers show <page id>) and subscribes it to the message fields of the Page and of its Instagram account. Verifying a webhook in Meta's dashboard alone subscribes no field, and Meta then delivers nothing.

6. Try it before Meta's review#

While the app is in development, Meta delivers only the messages of people with a role on it:

  • Messenger: the app's administrators, developers and testers (App roles ▸ Roles). Write to the Page from one of their Facebook accounts, at m.me/<page id>.
  • Instagram: an Instagram account given the Instagram Tester role (App roles ▸ Roles ▸ Add People ▸ Instagram Tester, by its username). The account accepts it in instagram.com/accounts/manage_access ▸ Tester invites. Then write to your account from it, at ig.me/m/<your account>: a message from the account to itself is not delivered.

The conversation shows in the console's Calls within seconds, with the agent's replies.

Conversations#

A contact is Meta's id of them on your Page or your Instagram account, never a phone number; their name is asked of Meta once, when their conversation opens. Text, buttons they tap and voice notes all reach the agent (a voice note is heard as on a call). A conversation stays open between messages while it has idle time left; a contact who writes again later is carried on with what was said before.

Because Meta gives no phone number, an agent that hands a conversation to a person asks the contact for one, as it would on your website's chat.

Reading and joining#

The console's Calls lists every Messenger and Instagram conversation beside your calls, under Open, waiting for a reply while it is open; Showing narrows the list to either. Open one to read it as it happens, whisper to the agent, or write to the contact yourself.

Before your public writes#

Answering anybody, not only the people with a role on the app, takes Advanced Access for pages_messaging, instagram_basic and instagram_manage_messages, which Meta grants after its App Review (a short screencast of the agent answering) and your business's verification. Until then, messages from the public never reach Pinecall.