O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

[2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Functions

My talk at Serverless Developer Summit, organized by IBM San Francisco on July 26, 2019

  • Entre para ver os comentários

[2019 Serverless Summit] Building Serverless Slack Chatbot on IBM Cloud Functions

  1. 1. Let’s Get Chatty! Building Serverless Slack Chatbot on IBM Cloud Functions Serverless Dev Summit | July 26, 2019
  2. 2. @girlie_mac Hello world! Tomomi Imura ( @girlie_mac) 2
  3. 3. What Are Bots? A bot is a software application that runs automated tasks (scripts). Typically, bots perform tasks that are both simple and structurally repetitive, at a much higher rate than would be possible for a human alone. https://en.wikipedia.org/wiki/Internet_bot @girlie_mac
  4. 4. Also, it is a user experience that can expose services to users via conversational engagement and rich interactions. What Are Bots? @girlie_mac
  5. 5. "Bots are like new applications that you can converse with." -- Satya Nadella, Microsoft (2016)
  6. 6. Future of computing revolves around three principal factors: ● Humans ● Digital assistants ● Bots
  7. 7. Conversational User Interactions
  8. 8. Conversational User Interactions Voice Assistance Alexa, how is the weather? Hey Siri @girlie_mac
  9. 9. Conversational User Interactions Google Assistant (Voice & Text) Hi, how can I help? @girlie_mac
  10. 10. Conversational User Interactions Bots on Chat Apps (Text) ! @girlie_mac
  11. 11. Conversational Bots on Facebook Messanger KLM Royal Dutch Airlines BlueBot (BB) On Facebook Messenger
  12. 12. Conversational Bots on Multiple Platforms UPS Chatbot On ● Facebook Messenger ● Skype ● Google Assistant ● Amazon Alexa
  13. 13. Conversational Bots on Slack Geekbot @girlie_mac
  14. 14. Conversational Bots on Slack Taco Bot https://www.tacobell.com/feed/tacobot@girlie_mac
  15. 15. Building A Conversational App on Slack
  16. 16. Example: A simple bot that responds to “Hi” Hi Hello @girlie_mac
  17. 17. with Slack API ● Events API to listen to an event (message.im) when a user sends a direct message to your bot ● When an event is triggered, receive a payload to get a message text ● Use Web API method, chat.postMessage to post a message on Slack @girlie_mac
  18. 18. User DM a message Sends payload to request URL USER Bot SLACK chat.postMessage Reply to the user Hello Hi message.im event is triggered Process the payload. Extract the user’s message & see if the message contains a word, “Hi”
  19. 19. Chatbot with RegEx = Not so conversational if(/hi/i.test(event.text)) { reply(‘Hello’); } Hi Hello @girlie_mac
  20. 20. Make it Smarter with NLP if(/hi/i.test(event.text)) { reply(...); } Hi I need help Guide me Show me the floor map @girlie_mac
  21. 21. What is Natural Language Processing? Process and analyze natural language data to make the interactions between computers & human, artificial & natural languages possible Conversational Bots & NLP @girlie_mac
  22. 22. Using Watson Assistant
  23. 23. Watson Assistant makes it smarter!
  24. 24. Sends payload to request URL USER BOT SLACK chat.postMessage Reply to the user Hi here’s some info! Show me office directory! WATSON Extract user-sent message & pass Process & return User DM a message message.im event is triggered
  25. 25. bot.js (Receive Slack events & Post message) exports.handler = async function handler(params) { const {challenge, event} = params; await reply(event.channel, event.text); return {statusCode: 200}; } // Get a reply from Watson Assistant const reply = async(channel, text) => { const params = { assistant_id: WATSON_ASSISTANT_ID, input: { text: text } }; const result = await assistant.message(params); sendToSlack(channel, result.output.generic[0].text); When DM is sent in Slack Pass the message text from the user to the function that handles: 1. Get a reply message via Watson API 2. Post it on Slack Watson returns the response Post the response to Slack
  26. 26. Going serverless
  27. 27. Why do you wanna go serverless? 1 Cost-effective Lowerinfrastructure& operationalcost 2 Scalable From prototypetoproduction 3 Sim plefunctions Sim plifiedprogram m ingm odel @girlie_mac
  28. 28. IBM Cloud Functions HTTP User Cloud (IBM Cloud Functions) Chatbot (Slack App) HTTP API Gateway IBM Watson Assistant @girlie_mac
  29. 29. IBM Cloud Functions - Create an Action @girlie_mac
  30. 30. . ├── .env ├── index.js ├── bot.js ├── package.json ├── readme.md └── node_modules ├── some_module ... My Files const botEndpoint = require('./bot'); module.exports = { main: botEndpoint.handler }; index.js @girlie_mac
  31. 31. IBM Cloud CLI tomomi: ~/dev/slack/ibm/slack-bot-watson (zsh) > zip -r chatbot.zip * > ibmcloud fn action create slack-chatbot chatbot.zip --kind nodejs:10 @girlie_mac
  32. 32. Receiving HTTP Events 1 @girlie_mac
  33. 33. Expose API Endpoint to Create a Public URL 1 2 Click Create Managed API to open the pop-up 3 Define the API endpoint. Select your Action. 4 @girlie_mac
  34. 34. Send Slack Events the URL 1 2 3 4 Go to Slack Config page Use the public URL @girlie_mac
  35. 35. Result @girlie_mac
  36. 36. Source Code Source code on GitHub: https://github.com/girliemac/serverless-slack-watson not yet,sorry! @girlie_mac
  37. 37. Resources ★ Slack API Docs: https://api.slack.com ★ Slack events types: https://api.slack.com/events ★ Watson Assistant: https://cloud.ibm.com/docs/services/assistant ★ Watson Node SDK: https://www.npmjs.com/package/watson-developer-cloud ★ IBM Cloud Functions: https://www.ibm.com/cloud/functions ★ Cloud Functions CLI: https://cloud.ibm.com/docs/cloud-functions-cli-plugin @girlie_mac
  38. 38. Slack x IBM Watson Webinar (Recorded) https://www.crowdcast.io/e/online-meetup-build-a @girlie_mac
  39. 39. You’re invited to Spec, a developer conference by Slack. Learn more at slack.com/spec Get 30% off registration with code -S19_SPC30
  40. 40. Thank you! Tomomi Imura (@girlie_mac)

×