bots


How can I use the same bot on multiple facebook pages using bot framework


I have several facebook pages and I would like to run the same bot on each page. I am using the bot framework and everything works perfectly for one page now. How do I associate with multiple pages?
Each page needs its own facebook application. Once you have created your applications you can link them to the same bot but they will use a different page token in case that you are validating the signature in your code and probably you want to use a different url for each of them.
When you call the Facebook Send API, you pass a page access token through the access_token parameter. You can specify which page to direct your message by modifying this access token. To know which page initiated the message, you can access the id field of the entry of the message post.
app.post('/webhook', (req, res) => {
const data = req.body
// Make sure this is a page subscription
if (data.object === 'page') {
// Iterate over each entry
data.entry.forEach((pageEntry) => {
// get the pageId
const pageId = pageEntry.id
...
You would then need to maintain an object mapping page ids to the access token associated with each page id:
const accessTokens = {
myPageId1: 'myPageAccessToken1',
myPageId2: 'myPageAccessToken2',
}
Then when sending the response, just specify the corresponding page access_token
const callSendAPI = (pageId, messageData) =>
rp({
uri: 'https://graph.facebook.com/v2.8/me/messages',
qs: { access_token: accessTokens[pageId] },
method: 'POST',
body: messageData,
json: true,
})

Related Links

Skype bot in “In Review” Status
Bot framework documentation qna maker [closed]
How to make telegram bot to remove links?
Testing in Bot Framework returns 401 Unauthorized
Bot Framework .Net Activity reply = activity.CreateReply(
How to access the filled data when using Formflow Namespace in Skype Bot Framework?
Microsoft bot framework getting the users time zone
How to get credentials for the Direct Line API microsoft bot framework?
Telegram bots: How much API keys can I generate?
Weird rendering in “Fetch as Google”
Effective way of training the bot, language processing APIs
What would be the right way to ask the person to enter a city inside a bot?
What is the right way to save/track state inside a Facebook Messenger bot?
How to implement a chatbot to human executive switch using Microsoft Bot Framework?
How to stop or throttle bot traffic
Skype bot card images not showing up

Categories

HOME
user-interface
typelite
eclipse-plugin
d3.js
workflow
mousemove
dafny
nsview
hdfs
informatica
docker-cloud
mosquitto
position
firebase-dynamic-links
eddystone
spring-security-oauth2
vimeo
amazon-elb
complexity-theory
corona
global-variables
google-tasks-api
pinterest
c#-7.0
boomi
high-availability
jackrabbit-oak
google-play-developer-api
dotcms
winsock
cloudera-manager
cloveretl
image-optimization
devtools
directfb
cups
textmate2
assertions
aurelia-cli
mv
android-alarms
task-parallel-library
icepdf
elasticsearch-aggregation
type-inference
flume-twitter
spongycastle
sonicmq
hibernate-ogm
sonatype
mongodb-aggregation
gmaps.js
mechanicalturk
hmmlearn
rational-performance-test
system.net.mail
groovyfx
rails-engines
maximize
mathnet
polymerfire
univocity
voronoi
mixins
jnlp
espresso
gql
green-threads
bootstrap-wysiwyg
flow-js
scala-swing
android-audiomanager
mojo
juttle
thoughtworks-go
quantify
squeezebox
webautomation
reference-counting
wso2bam
oxygene
pre
usb-flash-drive
eclim
colon
bcdedit
jquery-lazyload
spiral
proc-open
xmlwriter
xcode4.5
struts2-json-plugin
stretch
server-name
server-variables
uipasteboard
tablet-pc
resharper-5.1
asdoc
oracle-pro-c
eventaggregator
jquery-effects
subtext
autobench
rendering-engine
rootkit

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App