Johnny Sung introduced various messaging platforms and APIs that can be used to build messaging bots, including Slack, Line, Facebook Messenger, Skype, and others. He covered the key features of each platform's bot APIs, including how to set up webhooks, send and receive messages, and provided code examples in PHP. The presentation aimed to help developers learn how to connect their services to popular messaging platforms through bots.
15. S L A C K
• Incoming Webhooks
• Send messages into Slack with customization and rich formatting.
• Outgoing Webhooks
• Send messages from Slack to your service in real-time.
• Bot Users
• Connect to Slack to read and write as a real-time bot.
16. I N C O M I N G W E B H O O K S
https://api.slack.com/incoming-webhooks
Your server Slack
POST
200 OK
17. curl -X POST -H 'Content-type: application/json' --data ‘{“text”:"Hello,
World!”}’ https://hooks.slack.com/services/T00000000/B00000000/
XXXXXXXXXXXXXXXXXXXXXXXX
I N C O M I N G W E B H O O K S
https://api.slack.com/incoming-webhooks
18. I N C O M I N G W E B H O O K S
https://api.slack.com/incoming-webhooks
19. • Trigger keyword(s)
• Callbacks
• Cons: Public channel only
O U T G O I N G W E B H O O K S
https://api.slack.com/outgoing-webhooks
20. O U T G O I N G W E B H O O K S
https://api.slack.com/outgoing-webhooks
Slack
1. Detect if have certain keyword
Bonjour
안녕하세요
สวัสดี
नमस्ते
မဂ#လ%ပ'
21. O U T G O I N G W E B H O O K S
https://api.slack.com/outgoing-webhooks
Slack Your Server
200 OK
2. POST user message
POST
22. O U T G O I N G W E B H O O K S
https://api.slack.com/outgoing-webhooks
Slack Your Server
200 OK
POST
3. Return bot message
23.
24. B O T U S E R S ( R E A L T I M E M E S S A G I N G A P I )
https://api.slack.com/bot-users
Your server Slack
WebSocket
33. #!/usr/bin/python
# -*- coding: utf-8 -*-
import time
from slackclient import SlackClient
# Token found at https://api.slack.com/web#authentication
token = "xoxb-52095439187-CYPqixxxxxzwR9MoriR"
sc = SlackClient(token)
if sc.rtm_connect():
while True:
results = sc.rtm_read()
for result in results:
if 'type' in result:
if result['type'] == u'message' and not('subtype' in result):
channel = result['channel']
text = result['text']
user = result['user']
if channel != u'C02HKPG5U' and user != u'U1J2TCX5H':
# Filter out:
# C02HKPG5U ==> General channel
# U07SJTAMC ==> Bot it's self
try:
sc.rtm_send_message(channel, text)
except Exception, e:
print e
print result
time.sleep(5)
else:
print "Connection Failed, invalid token?"
Python
57. C R E AT I N G M E S S E N G E R B O T
• 1. Create a Facebook App and Page
• 2. Setup Webhook
• 3. Get a Page Access Token
• 4. Subscribe the App to the Page
https://messengerplatform.fb.com/
64. 4 . S U B S C R I B E T H E A P P T O T H E PA G E
curl -X POST "https://graph.facebook.com/v2.6/me/
subscribed_apps?access_token=<PAGE_ACCESS_TOKEN>"
72. Your server Skype
S K Y P E B O T
https://developer.microsoft.com/en-us/skype/bots/docs/api/chat
Messages
https://
73. Your server Skype
Post Messages
S K Y P E B O T
https://developer.microsoft.com/en-us/skype/bots/docs/api/chat
74. S K Y P E B O T
• 1. Create Skype bot
• 2. Create Microsoft Application
• 3. Paste Application ID to Skype bot
• 4. Add your bot to contact
https://developer.microsoft.com/en-us/skype/bots/docs/api/chat
75.
76.
77.
78.
79.
80.
81. T H E R E S O U R C E M O D E L
Conversation ID
• 8:<USERNAME>
• 28:<BOTID>
• 19:<GROUP CONVERSATION>
• ….
https://developer.microsoft.com/en-us/skype/bots/docs/api/chat