Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

把您的 Amazon Lex Chatbot 與訊息服務集成

866 views

Published on

Amazon Lex 提供與 Slack、Twilio、Marketo、Salesforce、Quickbooks、Microsoft Dynamics、Zendesk 和 Hubspot 的內置集成。除此之外,您還可以透過組合 Lex API 和 AWS API Gateway 將 Amazon Lex 與任何其他應用程式進行集成,毫不費力的將您的聊天機器人擴展到幾乎任何用例。

這場線上研討會,我們將向您展示如何做到這點。 我們所演示的設計模式能還您學習到如何在 Lex 上構建預處理層或將信息送到到多個特定的聊天機器人。

把您的 Amazon Lex Chatbot 與訊息服務集成

  1. 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Jhen-Wei Huang (黃振維) Solutions Architect, AWS Integrate Your Amazon Lex Chatbot with Any Messaging Service October 12, 2017
  2. 2. Sponsor
  3. 3. Overview • “Alexa, What is Amazon Lex?” • Going Serverless (AWS Lambda & Amazon API Gateway) • Integrating with Facebook • Teach Your Bot How to Text with Twilio SMS • Can we talk? Adding Support for Voice
  4. 4. The Need for Amazon Lex Amazon Lex Graphical User Interface Conversational Interface
  5. 5. Text and Speech Language Understanding Speech Recognition Natural Language Understanding Powered by the same Deep Learning technology as Alexa
  6. 6. Lex Bot Structure Utterances Spoken or typed phrases that invoke your intent BookHotel Intents An Intent performs an action in response to natural language user input Slots Slots are input data required to fulfill the intent Fulfillment Fulfillment mechanism for your intent
  7. 7. “Book a Hotel” Book Hotel Taipei “Book a Hotel in Taipei” Automatic Speech Recognition Hotel Booking Taipei City Natural Language Understanding Intent/Slot Model Utterances Hotel Booking City Taipei City Check In Nov 30th Check Out Dec 2nd “Your hotel is booked for Nov 30th” Amazon Polly Confirmation: “Your hotel is booked for Nov 30th” a in “Can I go ahead with the booking?
  8. 8. Versioning and Alias Support AliasVersioning v1 v2 v3 latest • Supported for Intents, Slots and Bots • Enables multi-developer environment • Rollback to previous versions v1 Dev v2 Stage v3 Prod • Deploy different aliases to different platforms • Run different stacks for dev, stage and prod environments • Target different user groups with different aliases
  9. 9. Save, Build, Test, and Publish Save Build Preserve the current state on the server Create versions you can test Publish Create a version of your bot with an alias for your clients Test Test your bot in a chat window on the console
  10. 10. Amazon Lex: Use Cases Informational Bots Manage everyday consumer requests Application Bots Build powerful interfaces to mobile applications • News updates • Weather information • FAQs …. • Book tickets • Order food • Manage bank accounts …. Enterprise Productivity Bots Streamline enterprise work activities • Check sales numbers • Marketing performance • Inventory status …. Internet of Things (IoT) Bots Enable conversational interfaces for device interactions • Wearables • Appliances • Auto ….
  11. 11. Lex Console: Designed for Builders
  12. 12. Serverless, event-driven compute service AWS Lambda = microservice without servers AWS Lambda
  13. 13. Components of AWS Lambda • An AWS Lambda function (that you write) • An event source • The AWS Lambda service • The function networking environment
  14. 14. Amazon API Gateway Create Configure Publish Maintain Monitor Secure Fully Managed Service for Your APIs
  15. 15. Built-in integrating Amazon Lex with Facebook
  16. 16. #1: Create Facebook App http://docs.aws.amazon.com/lex/latest/dg/fb-bot-association.html
  17. 17. #2: Create Page
  18. 18. #3: Create Page Access Token
  19. 19. #4: Create Lex Bot
  20. 20. #5: Setup Facebook Channel
  21. 21. #6: Setup Webhook
  22. 22. Testing the Integration
  23. 23. Integrating Amazon Lex with Twilio SMS
  24. 24. Amazon LexLambda Function Amazon API Gateway End User Twilio Programmable SMS Architecture / Message Flow https://aws.amazon.com/blogs/ai/integrate-your-amazon-lex-bot-with-any-messaging-service/
  25. 25. Multi-Bot Design “Concierge” Bot AWS Lambda Function Amazon API Gateway End User Multiple Messaging Services Amazon DynamoDB “Flight-Booking” Bot “Cruise-Booking” Bot user-id current- intent bot ttl 867-5309 BookCruise Cruise-Booking 1494013599 “I want to book a cruise”
  26. 26. #1: Creating an Amazon Lex bot https://console.aws.amazon.com/lex/home?region=us-east-1
  27. 27. #2: Setting up a Twilio Phone Number https://www.twilio.com/try-twilio
  28. 28. #3: IAM Policy & the AWS Lambda Function { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "lex:PostText" ], "Resource": [ "*" ] } ] } AWS.config.region = 'us-east-1'; var lexruntime = new AWS.LexRuntime(); var userNumber = twilioSMS.From.replace('+', ''); var params = { botAlias: process.env.BOT_ALIAS, botName: process.env.BOT_NAME, inputText: twilioSMS.Body, userId: userNumber, sessionAttributes: { } }; lexruntime.postText(params, function(err, data) { var twimlResponse = new twilio.TwimlResponse(); if (err) { console.log(err, err.stack); // an error occurred twimlResponse.message('Sorry, we ran into a problem at our end.'); callback(err, twimlResponse.toString()); } else { console.log(data); // got something back from Amazon Lex twimlResponse.message(data.message); callback(null, twimlResponse.toString()); } });
  29. 29. #4: HTTPS Endpoint using Amazon API Gateway
  30. 30. #5: Configuring the Twilio Webhook https://www.twilio.com/console
  31. 31. Your bot can now text!
  32. 32. Adding Support for Voice • Amazon Lex can support both Text and Voice • Use the Twilio <record> verb to prompt/record user input • Utilize Amazon Lex’s PostContent API call (instead of PostText) • Accept: text/plain • Convert to TwiML and send back to Twilio
  33. 33. Getting Started https://console.aws.amazon.com/lex
  34. 34. Remember to complete your evaluations!
  35. 35. Thank you! Get Started: https://aws.amazon.com/lex Lex Console: https://console.aws.amazon.com/lex

×