SlideShare a Scribd company logo
Building more contextual message with
Block Kit
1
@girlie_mac
Hello world!
Tomomi Imura
( @girlie_mac)
2
Quick Intro of Slack API
and
Block Kit
3
Slack: A Collaboration Hub
File
sharing
DevOps
Meetings
Sales /
Analytics
Expense /
Finance
Integration
4
NASA JPL
5
Integration at LA Times
Sharing breaking news
Connecting their CMS with Slack
https://source.opennews.org/articles/slack-buttons/
6
Carter, Popcorn Robot at Nvidia
7
Slack API
8
@girlie_mac
Web APIs
Query information, post messages,
change things! with the Web API.
Use it on the fly for ad-hoc queries or
as part of a more complex tapestry of
platform features.
It's all HTTP-RPC methods and not
quite REST.
Example: chat.postMessage sends a
message
9
@girlie_mac
Events APIs
The Events API is a subscription model for apps
and bots to process & react to activities in Slack.
All you need is a Slack app and a secure place for
Slack to send your events.
Features:
- Events are sent as HTTP requests
- Only subscribe to the events your app needs
- Limit your app’s scopes to only those needed
- Most up to date collection of Slack workspace
and user events
Example: team_join is emitted when a new
member joins your team
10
@girlie_mac
RTM API
The Real Time Messaging API is a
WebSocket-based API that allows you to
receive events from Slack in real time and
send messages as users. It's sometimes
referred to as simply the "RTM API".
Doesn’t require an HTTP server
Does require an always-on websocket
connection
May not contain many newer Slack
Event types, like bot_mention
11
Sending a Simple Message with Web API
12
Hello!chat.postMessage
via HTTP POST
POST /api/chat.postMessage
Content-type: application/json
Authorization: Bearer xoxb-xxxxxxxxx-xxxx
{"channel":"C061EG9SL","text":"Hello!"}
Sending a Styled Message
13
Before...
14
chat.postMessage
{
"channel": "CBADA55JP",
"attachments": [
…
]
}
15
chat.postMessage - attachments
{
"channel": "CBADA55JP",
"attachments": [{
"mrkdwn_in": ["text"],
"color": "#36a64f",
"pretext": "Optional pre-text that appears above the attachment block",
"author_name": "author_name",
"author_link": "http://flickr.com/bobby/",
"author_icon": "https://placeimg.com/16/16/people",
"title": "title",
"title_link": "https://api.slack.com/",
"text": "Optional `text` that appears within the attachment",
"fields": [{
"title": "A field's title",
"value": "This field's value",
}...],
"thumb_url": "http://placekitten.com/g/200/200",
"footer": "footer",
"footer_icon": "https://example.com/default_application_icon.png",
"ts": 123456789 }
]
}
16
Sending a Message with an Attachment
17
chat.postMessage
POST /api/chat.postMessage
Content-type: application/json
Authorization: Bearer xoxb-xxxxxxxxx-xxxx
{"channel":"C061EG9SL","attachment":[......]}
Now with Block Kit
18
Block Kit
● New message UI framework
● Stackable bits of message UI
● Block Kit Builder -
visual prototyping tool
19
Context collection
Image
Text collection
Text
Divider
Thumbnail
Interactive collection
Inline select
Inline overflow
Date picker
20
Basic Block
[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hello World!"
}
},
{
"type": "divider"
}
]
21
Add Interactivity
[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hello World!"
}
},
{
"type": "divider"
}
"accessory": {
...
}
]
22
[
...
 
"accessory": {
 "type": "button",
 "text": {
"type": "plain_text",
"text": "Farmhouse",
"emoji": true
},
"value": "click_me_123"
 }
]
Add Interactivity
23
Blocks: Section
24
Blocks: Section with Accessory
25
Blocks: Image
26
Blocks: Context
27
Blocks: Actions
28
Blocks: Divider
29
Block Kit Builder
30
Block Kit Builder https://api.slack.com/tools/block-kit-builder
31
Sending a Message with a Block
32
chat.postMessage
POST /api/chat.postMessage
Content-type: application/json
Authorization: Bearer xoxb-xxxxxxxxx-xxxx
{"channel":"C061EG9SL","blocks":[......]}
Doodle (Scheduling App)
33
NaviTime (Japanese Public Transit Finder App)
34
Node.js Example
A Slash Command Result w/ Block Kit
35
+ @/find-food pizza, san francisco
Using Slack API & Yelp API
36
Payload sent via HTTP POST
token=gIkuvaNzQIHg97ATvDxqgjtO
team_id=T0001
team_domain=example
channel_id=C2147483705
channel_name=general
user_id=U2147483697
user_name=girlie_mac
command=/find-food
text=pizza%2C%20san%20francisco
response_url=https://hooks.slack.com/commands/1234/5678
trigger_id=13345224609.738474920.8088930838d88f008e0
37
“pizza, san francisco”
Slash Command Endpoint (Express.js)
const express = require('express');
const app = express();
app.post('/command', async (req, res) => {
// log the payload and see what you got
console.log(req.body);
// reply the command
const message = {
response_type: 'in_channel',
text: replyText
}
res.json(message);
} 38
req.body.text is the slash command
query, “pizza, san francisco”
Reply with a Yelp Restaurant Search Result
app.post('/command', async (req, res) => {
// Extract the slash command query
const query = req.body.text ? req.body.text : 'lunch, San Francisco';
const queries = query.split(',');
const term = queries.shift(); // "Pizza"
const location = queries; // "San Francisco, CA"
const places = await getPlaces(query, location);
const message = {
response_type: 'in_channel',
text: places[0].name
}
res.json(message);
}
Passing the info to Yelp REST
API to get the result in an
array
Sending the result to Slack channel
39
Sending back 200 OK w/ JSON response
const message = {
response_type: 'in_channel',
text: places[0].name
}
res.json(message);
40
By default, it’s ‘ephemeral’
Showing the first result, the
name of the restaurant
Send 200 w/ the message
@girlie_mac
Result (so far, with a plain text)
41
Block-Kit-fy the message
We are going to re-format the JSON message we just created to display a
plain text into this rich message format using Block Kit:
42
BlockKit!
43
Compose Message with Block Kit Builder
2
1
Compose
Copy the
generated
JSON
http://api.slack.com/tools/block-kit-builder
Preview
44
Sending back 200 OK w/ JSON response
const message = {
response_type: 'in_channel',
text: places[0].name
}
res.json(message);
45
Sending back 200 OK w/ JSON response
const message = {
response_type: 'in_channel',
blocks: [
// the message in JSON generated from block kit builder
]
}
res.json(message);
46
const message = {
response_type: 'in_channel',
blocks: [
{
type: 'section',
text: {
type: 'mrkdwn',
text: `*<${places[0].url}|${places[0].name}>* n.. nPrice: ${places[0].price}`
},
accessory: {
type: 'image',
image_url: `${places[0].image_url}`,
alt_text: 'venue image'
}
},
{
'type': 'context',
'elements': [{
'type': 'plain_text',
'text': `${places[0].review_count} Yelp reviews`,
'emoji': true
}]
},
{
'type': 'divider'
},
}
]
};
47
Result w/ Block Kit
48
Tutorial & Source Code
● Tutorial:
https://api.slack.com/tutorials/slash-block-kit
● Source code on Glitch:
https://glitch.com/edit/#!/slash-blockkit
49
@girlie_mac
Resources
★ Slack API Docs: https://api.slack.com
★ Slack events types: https://api.slack.com/events
★ Block Kit: https://api.slack.com/block-kit
★ Block Kit Builder: https://api.slack.com/tools/block-kit-builder
50
51
https://serverless-developer-summit.splashthat.com/
July26th
You’re invited to Spec, a developer conference by Slack.
Learn more at slack.com/spec
Get 30% off registration with code -S19_SPC30
Thank you!
Tomomi Imura (@girlie_mac)
53

More Related Content

What's hot

Flask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuthFlask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuthEueung Mulyana
 
Seaside - The Revenge of Smalltalk
Seaside - The Revenge of SmalltalkSeaside - The Revenge of Smalltalk
Seaside - The Revenge of SmalltalkLukas Renggli
 
Rest presentation
Rest  presentationRest  presentation
Rest presentationsrividhyau
 
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREYBUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREYCodeCore
 
40+ tips to use Postman more efficiently
40+ tips to use Postman more efficiently40+ tips to use Postman more efficiently
40+ tips to use Postman more efficientlypostmanclient
 
Rest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyRest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyAlessandro Cucci
 
Best practices for RESTful web service design
Best practices for RESTful web service designBest practices for RESTful web service design
Best practices for RESTful web service designRamin Orujov
 
Designing a beautiful REST json api
Designing a beautiful REST json apiDesigning a beautiful REST json api
Designing a beautiful REST json api0x07de
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flaskJim Yeh
 
Using an API
Using an APIUsing an API
Using an APIAdam Culp
 
Understanding and testing restful web services
Understanding and testing restful web servicesUnderstanding and testing restful web services
Understanding and testing restful web servicesmwinteringham
 
Introduction to OAuth 2.0 - Part 1
Introduction to OAuth 2.0 - Part 1Introduction to OAuth 2.0 - Part 1
Introduction to OAuth 2.0 - Part 1Nabeel Yoosuf
 
How to Leverage APIs for SEO #TTTLive2019
How to Leverage APIs for SEO #TTTLive2019How to Leverage APIs for SEO #TTTLive2019
How to Leverage APIs for SEO #TTTLive2019Paul Shapiro
 
Web Development in Perl
Web Development in PerlWeb Development in Perl
Web Development in PerlNaveen Gupta
 
PHP And Web Services: Perfect Partners
PHP And Web Services: Perfect PartnersPHP And Web Services: Perfect Partners
PHP And Web Services: Perfect PartnersLorna Mitchell
 

What's hot (17)

Flask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuthFlask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuth
 
Seaside - The Revenge of Smalltalk
Seaside - The Revenge of SmalltalkSeaside - The Revenge of Smalltalk
Seaside - The Revenge of Smalltalk
 
Rest presentation
Rest  presentationRest  presentation
Rest presentation
 
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREYBUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
 
40+ tips to use Postman more efficiently
40+ tips to use Postman more efficiently40+ tips to use Postman more efficiently
40+ tips to use Postman more efficiently
 
Rest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyRest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemy
 
PHP Function
PHP Function PHP Function
PHP Function
 
Best practices for RESTful web service design
Best practices for RESTful web service designBest practices for RESTful web service design
Best practices for RESTful web service design
 
Designing a beautiful REST json api
Designing a beautiful REST json apiDesigning a beautiful REST json api
Designing a beautiful REST json api
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flask
 
Using an API
Using an APIUsing an API
Using an API
 
Understanding and testing restful web services
Understanding and testing restful web servicesUnderstanding and testing restful web services
Understanding and testing restful web services
 
Introduction to OAuth 2.0 - Part 1
Introduction to OAuth 2.0 - Part 1Introduction to OAuth 2.0 - Part 1
Introduction to OAuth 2.0 - Part 1
 
Web services tutorial
Web services tutorialWeb services tutorial
Web services tutorial
 
How to Leverage APIs for SEO #TTTLive2019
How to Leverage APIs for SEO #TTTLive2019How to Leverage APIs for SEO #TTTLive2019
How to Leverage APIs for SEO #TTTLive2019
 
Web Development in Perl
Web Development in PerlWeb Development in Perl
Web Development in Perl
 
PHP And Web Services: Perfect Partners
PHP And Web Services: Perfect PartnersPHP And Web Services: Perfect Partners
PHP And Web Services: Perfect Partners
 

Similar to [2019 south bay meetup] Building more contextual message with Block Kit

Integrating dialog flow (api.ai) into qiscus sdk chat application
Integrating dialog flow (api.ai) into qiscus sdk chat applicationIntegrating dialog flow (api.ai) into qiscus sdk chat application
Integrating dialog flow (api.ai) into qiscus sdk chat applicationErick Ranes Akbar Mawuntu
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPressTaylor Lovett
 
The Journey to conversational interfaces
The Journey to conversational interfacesThe Journey to conversational interfaces
The Journey to conversational interfacesRomin Irani
 
KubeCon EU 2016: Getting the Jobs Done With Kubernetes
KubeCon EU 2016: Getting the Jobs Done With KubernetesKubeCon EU 2016: Getting the Jobs Done With Kubernetes
KubeCon EU 2016: Getting the Jobs Done With KubernetesKubeAcademy
 
Running gRPC Services for Serving Legacy API on Kubernetes
Running gRPC Services for Serving Legacy API on KubernetesRunning gRPC Services for Serving Legacy API on Kubernetes
Running gRPC Services for Serving Legacy API on KubernetesSungwon Lee
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responsesdarrelmiller71
 
Cocoapods and Most common used library in Swift
Cocoapods and Most common used library in SwiftCocoapods and Most common used library in Swift
Cocoapods and Most common used library in SwiftWan Muzaffar Wan Hashim
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsTom Johnson
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platformNelson Kopliku
 
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech TalkContract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech TalkRed Hat Developers
 
Extensible RESTful Applications with Apache TinkerPop
Extensible RESTful Applications with Apache TinkerPopExtensible RESTful Applications with Apache TinkerPop
Extensible RESTful Applications with Apache TinkerPopVarun Ganesh
 
Data-Analytics using python (Module 4).pptx
Data-Analytics using python (Module 4).pptxData-Analytics using python (Module 4).pptx
Data-Analytics using python (Module 4).pptxDRSHk10
 
Office Dev Day 2018 - Extending Microsoft Teams
Office Dev Day 2018 - Extending Microsoft TeamsOffice Dev Day 2018 - Extending Microsoft Teams
Office Dev Day 2018 - Extending Microsoft TeamsAndré Vala
 
Serverless with Spring Cloud Function, Knative and riff #SpringOneTour #s1t
Serverless with Spring Cloud Function, Knative and riff #SpringOneTour #s1tServerless with Spring Cloud Function, Knative and riff #SpringOneTour #s1t
Serverless with Spring Cloud Function, Knative and riff #SpringOneTour #s1tToshiaki Maki
 
AtlasCamp2014: Introducing the Confluence REST API
AtlasCamp2014: Introducing the Confluence REST APIAtlasCamp2014: Introducing the Confluence REST API
AtlasCamp2014: Introducing the Confluence REST APIAtlassian
 
Enter the app era with ruby on rails (rubyday)
Enter the app era with ruby on rails (rubyday)Enter the app era with ruby on rails (rubyday)
Enter the app era with ruby on rails (rubyday)Matteo Collina
 
How fiddling with GraphQL enhanced communications between our back and front ...
How fiddling with GraphQL enhanced communications between our back and front ...How fiddling with GraphQL enhanced communications between our back and front ...
How fiddling with GraphQL enhanced communications between our back and front ...CALLR
 

Similar to [2019 south bay meetup] Building more contextual message with Block Kit (20)

Integrating dialog flow (api.ai) into qiscus sdk chat application
Integrating dialog flow (api.ai) into qiscus sdk chat applicationIntegrating dialog flow (api.ai) into qiscus sdk chat application
Integrating dialog flow (api.ai) into qiscus sdk chat application
 
2012: ql.io and Node.js
2012: ql.io and Node.js2012: ql.io and Node.js
2012: ql.io and Node.js
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
 
The Journey to conversational interfaces
The Journey to conversational interfacesThe Journey to conversational interfaces
The Journey to conversational interfaces
 
KubeCon EU 2016: Getting the Jobs Done With Kubernetes
KubeCon EU 2016: Getting the Jobs Done With KubernetesKubeCon EU 2016: Getting the Jobs Done With Kubernetes
KubeCon EU 2016: Getting the Jobs Done With Kubernetes
 
Running gRPC Services for Serving Legacy API on Kubernetes
Running gRPC Services for Serving Legacy API on KubernetesRunning gRPC Services for Serving Legacy API on Kubernetes
Running gRPC Services for Serving Legacy API on Kubernetes
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responses
 
Cocoapods and Most common used library in Swift
Cocoapods and Most common used library in SwiftCocoapods and Most common used library in Swift
Cocoapods and Most common used library in Swift
 
Building a chatbot – step by step
Building a chatbot – step by stepBuilding a chatbot – step by step
Building a chatbot – step by step
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platform
 
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech TalkContract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
 
Extensible RESTful Applications with Apache TinkerPop
Extensible RESTful Applications with Apache TinkerPopExtensible RESTful Applications with Apache TinkerPop
Extensible RESTful Applications with Apache TinkerPop
 
Data-Analytics using python (Module 4).pptx
Data-Analytics using python (Module 4).pptxData-Analytics using python (Module 4).pptx
Data-Analytics using python (Module 4).pptx
 
Office Dev Day 2018 - Extending Microsoft Teams
Office Dev Day 2018 - Extending Microsoft TeamsOffice Dev Day 2018 - Extending Microsoft Teams
Office Dev Day 2018 - Extending Microsoft Teams
 
Serverless with Spring Cloud Function, Knative and riff #SpringOneTour #s1t
Serverless with Spring Cloud Function, Knative and riff #SpringOneTour #s1tServerless with Spring Cloud Function, Knative and riff #SpringOneTour #s1t
Serverless with Spring Cloud Function, Knative and riff #SpringOneTour #s1t
 
AtlasCamp2014: Introducing the Confluence REST API
AtlasCamp2014: Introducing the Confluence REST APIAtlasCamp2014: Introducing the Confluence REST API
AtlasCamp2014: Introducing the Confluence REST API
 
Enter the app era with ruby on rails (rubyday)
Enter the app era with ruby on rails (rubyday)Enter the app era with ruby on rails (rubyday)
Enter the app era with ruby on rails (rubyday)
 
How fiddling with GraphQL enhanced communications between our back and front ...
How fiddling with GraphQL enhanced communications between our back and front ...How fiddling with GraphQL enhanced communications between our back and front ...
How fiddling with GraphQL enhanced communications between our back and front ...
 

More from Tomomi Imura

ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)
ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)
ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)Tomomi Imura
 
[POST.Dev Japan] VS Code で試みる開発体験の向上
[POST.Dev Japan] VS Code で試みる開発体験の向上[POST.Dev Japan] VS Code で試みる開発体験の向上
[POST.Dev Japan] VS Code で試みる開発体験の向上Tomomi Imura
 
[Japan M365 Dev UG] Teams Toolkit v4 を使ってみよう!
[Japan M365 Dev UG] Teams Toolkit v4 を使ってみよう![Japan M365 Dev UG] Teams Toolkit v4 を使ってみよう!
[Japan M365 Dev UG] Teams Toolkit v4 を使ってみよう!Tomomi Imura
 
[#DevRelAsia Keynote 2020] Developer Centric Design for Better Experience
[#DevRelAsia Keynote 2020] Developer Centric Design for Better Experience[#DevRelAsia Keynote 2020] Developer Centric Design for Better Experience
[#DevRelAsia Keynote 2020] Developer Centric Design for Better ExperienceTomomi Imura
 
Engineering career is not a single ladder! - Alternative pathway to develope...
Engineering career is not a single ladder!  - Alternative pathway to develope...Engineering career is not a single ladder!  - Alternative pathway to develope...
Engineering career is not a single ladder! - Alternative pathway to develope...Tomomi Imura
 
Being a Tech Speaker with Global Mindset
Being a Tech Speaker with Global MindsetBeing a Tech Speaker with Global Mindset
Being a Tech Speaker with Global MindsetTomomi Imura
 
#TinySpec2019 Slack Dev Meetup in Osaka & Tokyo (in Japanese)
#TinySpec2019 Slack Dev Meetup in Osaka & Tokyo (in Japanese)#TinySpec2019 Slack Dev Meetup in Osaka & Tokyo (in Japanese)
#TinySpec2019 Slack Dev Meetup in Osaka & Tokyo (in Japanese)Tomomi Imura
 
Slack × Twilio - Uniquely Powering Communication
Slack × Twilio - Uniquely Powering CommunicationSlack × Twilio - Uniquely Powering Communication
Slack × Twilio - Uniquely Powering CommunicationTomomi Imura
 
[2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func...
 [2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func... [2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func...
[2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func...Tomomi Imura
 
[TechWorldSummit Stockholm 2019] Building Bots for Human with Conversational ...
[TechWorldSummit Stockholm 2019] Building Bots for Human with Conversational ...[TechWorldSummit Stockholm 2019] Building Bots for Human with Conversational ...
[TechWorldSummit Stockholm 2019] Building Bots for Human with Conversational ...Tomomi Imura
 
Building a Bot with Slack Platform and IBM Watson
Building a Bot with Slack Platform and IBM WatsonBuilding a Bot with Slack Platform and IBM Watson
Building a Bot with Slack Platform and IBM WatsonTomomi Imura
 
[日本語] Slack Bot Workshop + Intro Block Kit
[日本語] Slack Bot Workshop + Intro Block Kit[日本語] Slack Bot Workshop + Intro Block Kit
[日本語] Slack Bot Workshop + Intro Block KitTomomi Imura
 
[DevRelCon Tokyo 2019] Developer Experience Matters
[DevRelCon Tokyo 2019] Developer Experience Matters [DevRelCon Tokyo 2019] Developer Experience Matters
[DevRelCon Tokyo 2019] Developer Experience Matters Tomomi Imura
 
[DevRel Summit 2018] Because we all learn things differently
[DevRel Summit 2018] Because we all learn things differently[DevRel Summit 2018] Because we all learn things differently
[DevRel Summit 2018] Because we all learn things differentlyTomomi Imura
 
[DevRelCon July 2018] Because we all learn things differently
[DevRelCon July 2018] Because we all learn things differently[DevRelCon July 2018] Because we all learn things differently
[DevRelCon July 2018] Because we all learn things differentlyTomomi Imura
 
[Japanese] Developing a bot for your workspace 翻訳ボットを作る!
[Japanese] Developing a bot for your workspace 翻訳ボットを作る![Japanese] Developing a bot for your workspace 翻訳ボットを作る!
[Japanese] Developing a bot for your workspace 翻訳ボットを作る!Tomomi Imura
 
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi [Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi Tomomi Imura
 
Future of the Web with Conversational Interface
Future of the Web with Conversational InterfaceFuture of the Web with Conversational Interface
Future of the Web with Conversational InterfaceTomomi Imura
 
[DevRelCon Tokyo 2017] Creative Technical Content for Better Developer Experi...
[DevRelCon Tokyo 2017] Creative Technical Content for Better Developer Experi...[DevRelCon Tokyo 2017] Creative Technical Content for Better Developer Experi...
[DevRelCon Tokyo 2017] Creative Technical Content for Better Developer Experi...Tomomi Imura
 
[日本語・Japanese] Creative Technical Content for Better Developer Experience
[日本語・Japanese] Creative Technical Content for Better Developer Experience[日本語・Japanese] Creative Technical Content for Better Developer Experience
[日本語・Japanese] Creative Technical Content for Better Developer ExperienceTomomi Imura
 

More from Tomomi Imura (20)

ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)
ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)
ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)
 
[POST.Dev Japan] VS Code で試みる開発体験の向上
[POST.Dev Japan] VS Code で試みる開発体験の向上[POST.Dev Japan] VS Code で試みる開発体験の向上
[POST.Dev Japan] VS Code で試みる開発体験の向上
 
[Japan M365 Dev UG] Teams Toolkit v4 を使ってみよう!
[Japan M365 Dev UG] Teams Toolkit v4 を使ってみよう![Japan M365 Dev UG] Teams Toolkit v4 を使ってみよう!
[Japan M365 Dev UG] Teams Toolkit v4 を使ってみよう!
 
[#DevRelAsia Keynote 2020] Developer Centric Design for Better Experience
[#DevRelAsia Keynote 2020] Developer Centric Design for Better Experience[#DevRelAsia Keynote 2020] Developer Centric Design for Better Experience
[#DevRelAsia Keynote 2020] Developer Centric Design for Better Experience
 
Engineering career is not a single ladder! - Alternative pathway to develope...
Engineering career is not a single ladder!  - Alternative pathway to develope...Engineering career is not a single ladder!  - Alternative pathway to develope...
Engineering career is not a single ladder! - Alternative pathway to develope...
 
Being a Tech Speaker with Global Mindset
Being a Tech Speaker with Global MindsetBeing a Tech Speaker with Global Mindset
Being a Tech Speaker with Global Mindset
 
#TinySpec2019 Slack Dev Meetup in Osaka & Tokyo (in Japanese)
#TinySpec2019 Slack Dev Meetup in Osaka & Tokyo (in Japanese)#TinySpec2019 Slack Dev Meetup in Osaka & Tokyo (in Japanese)
#TinySpec2019 Slack Dev Meetup in Osaka & Tokyo (in Japanese)
 
Slack × Twilio - Uniquely Powering Communication
Slack × Twilio - Uniquely Powering CommunicationSlack × Twilio - Uniquely Powering Communication
Slack × Twilio - Uniquely Powering Communication
 
[2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func...
 [2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func... [2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func...
[2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Func...
 
[TechWorldSummit Stockholm 2019] Building Bots for Human with Conversational ...
[TechWorldSummit Stockholm 2019] Building Bots for Human with Conversational ...[TechWorldSummit Stockholm 2019] Building Bots for Human with Conversational ...
[TechWorldSummit Stockholm 2019] Building Bots for Human with Conversational ...
 
Building a Bot with Slack Platform and IBM Watson
Building a Bot with Slack Platform and IBM WatsonBuilding a Bot with Slack Platform and IBM Watson
Building a Bot with Slack Platform and IBM Watson
 
[日本語] Slack Bot Workshop + Intro Block Kit
[日本語] Slack Bot Workshop + Intro Block Kit[日本語] Slack Bot Workshop + Intro Block Kit
[日本語] Slack Bot Workshop + Intro Block Kit
 
[DevRelCon Tokyo 2019] Developer Experience Matters
[DevRelCon Tokyo 2019] Developer Experience Matters [DevRelCon Tokyo 2019] Developer Experience Matters
[DevRelCon Tokyo 2019] Developer Experience Matters
 
[DevRel Summit 2018] Because we all learn things differently
[DevRel Summit 2018] Because we all learn things differently[DevRel Summit 2018] Because we all learn things differently
[DevRel Summit 2018] Because we all learn things differently
 
[DevRelCon July 2018] Because we all learn things differently
[DevRelCon July 2018] Because we all learn things differently[DevRelCon July 2018] Because we all learn things differently
[DevRelCon July 2018] Because we all learn things differently
 
[Japanese] Developing a bot for your workspace 翻訳ボットを作る!
[Japanese] Developing a bot for your workspace 翻訳ボットを作る![Japanese] Developing a bot for your workspace 翻訳ボットを作る!
[Japanese] Developing a bot for your workspace 翻訳ボットを作る!
 
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi [Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
 
Future of the Web with Conversational Interface
Future of the Web with Conversational InterfaceFuture of the Web with Conversational Interface
Future of the Web with Conversational Interface
 
[DevRelCon Tokyo 2017] Creative Technical Content for Better Developer Experi...
[DevRelCon Tokyo 2017] Creative Technical Content for Better Developer Experi...[DevRelCon Tokyo 2017] Creative Technical Content for Better Developer Experi...
[DevRelCon Tokyo 2017] Creative Technical Content for Better Developer Experi...
 
[日本語・Japanese] Creative Technical Content for Better Developer Experience
[日本語・Japanese] Creative Technical Content for Better Developer Experience[日本語・Japanese] Creative Technical Content for Better Developer Experience
[日本語・Japanese] Creative Technical Content for Better Developer Experience
 

Recently uploaded

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backElena Simperl
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...Product School
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1DianaGray10
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform EngineeringJemma Hussein Allen
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Thierry Lestable
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesThousandEyes
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaRTTS
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 

Recently uploaded (20)

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 

[2019 south bay meetup] Building more contextual message with Block Kit

  • 1. Building more contextual message with Block Kit 1
  • 3. Quick Intro of Slack API and Block Kit 3
  • 4. Slack: A Collaboration Hub File sharing DevOps Meetings Sales / Analytics Expense / Finance Integration 4
  • 6. Integration at LA Times Sharing breaking news Connecting their CMS with Slack https://source.opennews.org/articles/slack-buttons/ 6
  • 7. Carter, Popcorn Robot at Nvidia 7
  • 9. @girlie_mac Web APIs Query information, post messages, change things! with the Web API. Use it on the fly for ad-hoc queries or as part of a more complex tapestry of platform features. It's all HTTP-RPC methods and not quite REST. Example: chat.postMessage sends a message 9
  • 10. @girlie_mac Events APIs The Events API is a subscription model for apps and bots to process & react to activities in Slack. All you need is a Slack app and a secure place for Slack to send your events. Features: - Events are sent as HTTP requests - Only subscribe to the events your app needs - Limit your app’s scopes to only those needed - Most up to date collection of Slack workspace and user events Example: team_join is emitted when a new member joins your team 10
  • 11. @girlie_mac RTM API The Real Time Messaging API is a WebSocket-based API that allows you to receive events from Slack in real time and send messages as users. It's sometimes referred to as simply the "RTM API". Doesn’t require an HTTP server Does require an always-on websocket connection May not contain many newer Slack Event types, like bot_mention 11
  • 12. Sending a Simple Message with Web API 12 Hello!chat.postMessage via HTTP POST POST /api/chat.postMessage Content-type: application/json Authorization: Bearer xoxb-xxxxxxxxx-xxxx {"channel":"C061EG9SL","text":"Hello!"}
  • 13. Sending a Styled Message 13
  • 16. chat.postMessage - attachments { "channel": "CBADA55JP", "attachments": [{ "mrkdwn_in": ["text"], "color": "#36a64f", "pretext": "Optional pre-text that appears above the attachment block", "author_name": "author_name", "author_link": "http://flickr.com/bobby/", "author_icon": "https://placeimg.com/16/16/people", "title": "title", "title_link": "https://api.slack.com/", "text": "Optional `text` that appears within the attachment", "fields": [{ "title": "A field's title", "value": "This field's value", }...], "thumb_url": "http://placekitten.com/g/200/200", "footer": "footer", "footer_icon": "https://example.com/default_application_icon.png", "ts": 123456789 } ] } 16
  • 17. Sending a Message with an Attachment 17 chat.postMessage POST /api/chat.postMessage Content-type: application/json Authorization: Bearer xoxb-xxxxxxxxx-xxxx {"channel":"C061EG9SL","attachment":[......]}
  • 18. Now with Block Kit 18
  • 19. Block Kit ● New message UI framework ● Stackable bits of message UI ● Block Kit Builder - visual prototyping tool 19
  • 20. Context collection Image Text collection Text Divider Thumbnail Interactive collection Inline select Inline overflow Date picker 20
  • 21. Basic Block [ { "type": "section", "text": { "type": "mrkdwn", "text": "Hello World!" } }, { "type": "divider" } ] 21
  • 22. Add Interactivity [ { "type": "section", "text": { "type": "mrkdwn", "text": "Hello World!" } }, { "type": "divider" } "accessory": { ... } ] 22
  • 23. [ ...   "accessory": {  "type": "button",  "text": { "type": "plain_text", "text": "Farmhouse", "emoji": true }, "value": "click_me_123"  } ] Add Interactivity 23
  • 25. Blocks: Section with Accessory 25
  • 31. Block Kit Builder https://api.slack.com/tools/block-kit-builder 31
  • 32. Sending a Message with a Block 32 chat.postMessage POST /api/chat.postMessage Content-type: application/json Authorization: Bearer xoxb-xxxxxxxxx-xxxx {"channel":"C061EG9SL","blocks":[......]}
  • 34. NaviTime (Japanese Public Transit Finder App) 34
  • 35. Node.js Example A Slash Command Result w/ Block Kit 35
  • 36. + @/find-food pizza, san francisco Using Slack API & Yelp API 36
  • 37. Payload sent via HTTP POST token=gIkuvaNzQIHg97ATvDxqgjtO team_id=T0001 team_domain=example channel_id=C2147483705 channel_name=general user_id=U2147483697 user_name=girlie_mac command=/find-food text=pizza%2C%20san%20francisco response_url=https://hooks.slack.com/commands/1234/5678 trigger_id=13345224609.738474920.8088930838d88f008e0 37 “pizza, san francisco”
  • 38. Slash Command Endpoint (Express.js) const express = require('express'); const app = express(); app.post('/command', async (req, res) => { // log the payload and see what you got console.log(req.body); // reply the command const message = { response_type: 'in_channel', text: replyText } res.json(message); } 38 req.body.text is the slash command query, “pizza, san francisco”
  • 39. Reply with a Yelp Restaurant Search Result app.post('/command', async (req, res) => { // Extract the slash command query const query = req.body.text ? req.body.text : 'lunch, San Francisco'; const queries = query.split(','); const term = queries.shift(); // "Pizza" const location = queries; // "San Francisco, CA" const places = await getPlaces(query, location); const message = { response_type: 'in_channel', text: places[0].name } res.json(message); } Passing the info to Yelp REST API to get the result in an array Sending the result to Slack channel 39
  • 40. Sending back 200 OK w/ JSON response const message = { response_type: 'in_channel', text: places[0].name } res.json(message); 40 By default, it’s ‘ephemeral’ Showing the first result, the name of the restaurant Send 200 w/ the message
  • 41. @girlie_mac Result (so far, with a plain text) 41
  • 42. Block-Kit-fy the message We are going to re-format the JSON message we just created to display a plain text into this rich message format using Block Kit: 42
  • 44. Compose Message with Block Kit Builder 2 1 Compose Copy the generated JSON http://api.slack.com/tools/block-kit-builder Preview 44
  • 45. Sending back 200 OK w/ JSON response const message = { response_type: 'in_channel', text: places[0].name } res.json(message); 45
  • 46. Sending back 200 OK w/ JSON response const message = { response_type: 'in_channel', blocks: [ // the message in JSON generated from block kit builder ] } res.json(message); 46
  • 47. const message = { response_type: 'in_channel', blocks: [ { type: 'section', text: { type: 'mrkdwn', text: `*<${places[0].url}|${places[0].name}>* n.. nPrice: ${places[0].price}` }, accessory: { type: 'image', image_url: `${places[0].image_url}`, alt_text: 'venue image' } }, { 'type': 'context', 'elements': [{ 'type': 'plain_text', 'text': `${places[0].review_count} Yelp reviews`, 'emoji': true }] }, { 'type': 'divider' }, } ] }; 47
  • 48. Result w/ Block Kit 48
  • 49. Tutorial & Source Code ● Tutorial: https://api.slack.com/tutorials/slash-block-kit ● Source code on Glitch: https://glitch.com/edit/#!/slash-blockkit 49
  • 50. @girlie_mac Resources ★ Slack API Docs: https://api.slack.com ★ Slack events types: https://api.slack.com/events ★ Block Kit: https://api.slack.com/block-kit ★ Block Kit Builder: https://api.slack.com/tools/block-kit-builder 50
  • 52. You’re invited to Spec, a developer conference by Slack. Learn more at slack.com/spec Get 30% off registration with code -S19_SPC30
  • 53. Thank you! Tomomi Imura (@girlie_mac) 53