external event/task poc - sas institute · we are using ci360 to serve as a facebook messenger chat...

18
Copyright © SAS Institute Inc. All rights reserved. External event/task PoC Working with facebook messenger

Upload: others

Post on 23-Jun-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

External event/task PoCWorking with facebook messenger

Page 2: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Disclaimer

• The information contained in this document is for proving of external event/task concept purposes only.

• You must strictly follow the terms and conditions of external system and take your own risk when you are trying to implement such a scenario.

Page 3: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

PoC Briefing

We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox, external task will be triggered by external event and relevant creative contents will be shown as automatic response in chatbox.

Page 4: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Technical Architecture

Heroku(Webhook)

External system

Facebookmessenger

APP

CI360

CI360

ExternalEvent

ExternalTask

Creative

Application

Agent

• Connect to webhook

• Manage facebook page

• Manage access token

• Contact with messenger API

Server as public webhook server

Make 360 event API call to create external event based on information in chatbox

• Handle event created by external task

• Make messenger API call to send back response data based on creative content in external task

• Trig by external event(inbound)

• Combine agent and creative

• Create external event(outbound) to agent

Agent

Page 5: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailFacebook & Heroku configuration

• Step 1: Create Facebook Page• Step 2: Create Facebook App• Step 3: Add Messenger to Facebook App• Step 4: Setup Webhook

• Step 5: Deploy Webhook to Heroku• Step 6: Link up the app with a facebook Page

Detailed configuration information for above steps can be found in the following pages:https://medium.com/@viviancpy/part-1-facebook-chatbot-with-heroku-webhook-b14090a136c7

https://developers.facebook.com/docs/messenger-platform/getting-started/app-setup#app_and_page_setup

Page 6: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailFacebook & Heroku configuration

Webhook code snippet

Use node.js to handle chatbox contents and send relevant external event to CI360

External event APIeventname:FBMsgEventsubject_id:messenger sender idapplicationid:FBMessengertext: messenger sender text

External event defined in CI360

Page 7: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailCI360 configuration

• Step 1: Create agent

Add association ids

Page 8: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailCI360 configuration

• Step 2: Create application

Page 9: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailCI360 configuration

• Step 3: Create external event

Add text attribute to store messenger sender text

Page 10: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailCI360 configuration

• Step 4: Create creative

Store campaign contents, eg: coupon, offer etc.

Page 11: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailCI360 configuration

• Step 5: Create external task1 to handle text campaign

Trig the task when customer input “text campaign”

Define outgoing event nameFBMsgOutgoing_1

Define agent

Bind creative created in step4

Page 12: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailCI360 configuration

• Step 6: Create external task2 to handle image campaign

Trig the task when customer input “image campaign”

Define outgoing event nameFBMsgOutgoing_2

Define agent

Bind creative created in step4

Page 13: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailAgent configuration

• Step 1: Download agent sdk from CI360 -> agent

Page 14: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailAgent configuration

• Step 2:Download and install java sdk 1.8 or higher from Oracle(1.8 recommended)

• Step 3:Download and install maven 3.5.3 or higher from maven.apache.org

• Step 4:Add maven bin directory to $PATH or %PATH%

• Step 5:Set/export JAVA_HOME environment variable to point at java install root directory

• Step 6:Extract CI360 SDK jar(downloaded from Step 1) into your local repository

• Step 7:Run mvn install:install-file -Dfile=<path where CI360 agent was downloaded>/sdk/mkt-agent-sdk-jar-1.<current release>.jar ¥-DpomFile=<path where CI360 agent was downloaded>/sdk/pom.xml

• Step 8:Create directory for building the sample agent(<sample agent> folder)

Page 15: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailAgent configuration

• Step 9: Copy <path where CI360 agent was downloaded>/sdk/sample/pom.xml and logback.xml to the <sample agent> folder

• Step 10: Create src/main/java/sample subfolder under the <sample agent> folder

• Step 11: Copy <path where CI360 agent was downloaded>/sdk/sample/*.java to the <sample agent>/src/main/java/sample folder.

Page 16: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailAgent configuration

• Step 12:Create sample.properties file under <sample agent> folder and add the following information into this file.

app_id = <messenger app id>

verify_token = <webhook verify token>

page_access_token = <messenger app access token>

Page 17: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailAgent configuration

• Step 13: Make your own logic in SampleAgent.java under <sample agent>/src/main/java/sample folder

• Step 14:Build the sample agents by running mvn compile

Get event name from external task, when event name is FBMsgOutgoing_1, send text reponse data to messenger, when event name is FBMsgOutgoing_2,send image reponse data to messenger

Page 18: External event/task PoC - Sas Institute · We are using CI360 to serve as a facebook messenger chat bot. External event will be created based on customer’s input text in chatbox,

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Configuration detailAgent configuration

• Step 15:Start the sample agent with the following command.

mvn exec:java -Dci360.gatewayHost=extapigwservice-demo.cidemo.sas.com -Dci360.tenantID=cdfcdb975400013bfd3c345e -Dci360.clientSecret=MTA1MTFpYjg0aG5maTRjNzllaGdtNmhtNjlmMmFiZzc5 -Dlogback.configurationFile=logback.xml -Dexec.mainClass="sample.SampleAgent" -Ddir="C:¥30.CNS Related¥mkt-agent-sdk-1.1906.1904251112¥sample_agent" -Dsource="sample"

2

3

4 5

6

2

3

4

5

6

Access -> cidemo01

General Settings -> Access