Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Create a Facebook application https://developers.facebook.com/apps/ (or use existing one)
  • Add the Messenger and Webhook Products to your app
    • You need to add BOTH products in order to receive a page feed
  • Link to a Facebook Page you want to track - recommended guide: Facebook Application Quick Start
  • Get the access token for the page - copy this to notepad
  • Don't fill out the webhook section yet

...

Code Block
languagesql
titleCreate chan2Profile
linenumberstrue
collapsetrue
CREATE TABLE chan2Profile (
  channelId varchar(100) NOT NULL COMMENT 'The cookie, twitter handle etc',
  cidType varchar(20) NOT NULL COMMENT 'The channel ID type "web", "twitter" etc ',
  pId varchar(4060) NOT NULL COMMENT 'The unqiue profile id - foreign key to kwProfile',
  PRIMARY KEY (channelId,cidType,pId) COMMENT 'Composite key',
  UNIQUE KEY kwChan2Profile_UNIQUE (channelId,cidType,pId),

 UNIQUE KEY channelId_UNIQUE (channelId,cidType) COMMENT 'No duplicate keys for the same channel',
  KEY pidIndex (pId),
  KEY channelIndex (channelId)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

...

Code Block
languagesql
titleCreate interaction
linenumberstrue
collapsetrue
CREATE TABLE interaction (
  kwInteractionId int(11) NOT NULL AUTO_INCREMENT,
  pId varchar(4560) NOT NULL,
  channel varchar(30) DEFAULT NULL,
  interactionType varchar(20) DEFAULT NULL,
  ts datetime DEFAULT CURRENT_TIMESTAMP,
  direction varchar(45) DEFAULT NULL,
  PRIMARY KEY (kwInteractionId),
  KEY idx_pid (pId)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

...

Code Block
languagesql
titleCreate profile
linenumberstrue
collapsetrue
CREATE TABLE profile (
  pId varchar(4060) NOT NULL,
  statusCode varchar(10) DEFAULT NULL,
  firstName varchar(45) DEFAULT NULL,
  lastName varchar(145) DEFAULT NULL,
  country varchar(145) DEFAULT NULL,
  city varchar(145) DEFAULT NULL,
  industry varchar(45) DEFAULT NULL,
  loyaltyPoints int(11) DEFAULT '0',
  favoriteProduct varchar(45) DEFAULT NULL,
  productsInterestedIn varchar(145) DEFAULT NULL,
  lastUpdated timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
  PRIMARY KEY (pId)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

...

Code Block
languagesql
titleCreate profileFacebook
linenumberstrue
collapsetrue
CREATE TABLE profileFacebook (
  pId varchar(5060) NOT NULL,
  firstName varchar(100) DEFAULT NULL,
  surname varchar(100) DEFAULT NULL,
  lastInteractionTs datetime(3) DEFAULT NULL,
  lastInboundMsgTs datetime(3) DEFAULT NULL,
  lastOutboundMsgTs datetime(3) DEFAULT NULL,
  metaRaw text,
  PRIMARY KEY (pId),
  KEY pId (pId)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

...