I am able to create Amazon lex chat bot. I am also able to publish the same in Facebook messenger. Also I found sdk's for iOS and Android.
What I want is to publish lex bot as a webservice which can be called from any rest client, so that it can be integrated to any user interface with rest calls.
I heard of Javascript sdk's for publishing lex bots as service, but I am not able to find any proper documentation on this.
The lex-runtime is accessible from the Javascript SDKs. AWS documentation is here: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/LexRuntime.html
The trickiest part is authentication. The recommendation from Amazon is usually to route your Lex requests through a Lambda function in front of an API gateway. An alternative is to have a Cognito unauthenticated role that has permissions to call Lex and then have the clients call it directly.
The getting started guide may be of use if you are unfamiliar with calling AWS from the browser: http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-started-browser.html
You can use AWS API Gateway which will get the requests from your Rest Client and forward it to Lex.
Your architecture will be like:
Chat client <==> AWS API Gateway <==> AWS Lex
Check this link for details.
Related
For the AWS marketplace integration, we have checked the sample code of Serverless integration for SaaS products. The samples provided, it is based on AWS Lambda functions for registering new subscribers, subscribing to SQS etc.
Can we implement all these functionalities with our database, functions etc, instead of using AWS lambda and dynamo DB?
Also in the examples, some lambda functions are there like stream handler, entitlement-SQS, subscription-SQS-handler, grant-revoke-access-to-product etc. How can we trigger if we use our APIS?
Yes, the AWS Marketplace SaaS integration documentation states:
When a customer subscribes to your product, they are redirected to your registration URL which is an HTTP POST request with a temporary x-amzn-marketplace-token token.
All you need is an endpoint that can receive that POST in order to integrate. If you want to trigger any additional AWS API calls, your endpoint could make use of an AWS SDK. There are also requirements surrounding what your POST endpoint must do in order to be approved by the AWS Marketplace team. I suggest reviewing the documentation above or this AWS Marketplace
SaaS Listing Process & Integration Guide.
I have set up the amazon lex bot in AWS and I am able to test this successfully in the Test bot section.
I started exploring accessing the amazon lex bot from the external web ui (my local application) and I found the tool called amazon aws lex web UI (https://github.com/aws-samples/aws-lex-web-ui) and It seems very complex to setup, I have few queries here
1) Is this (https://github.com/aws-samples/aws-lex-web-ui) the only way to use amazon lex bot from my local web application?
2) This section has the notes for running locally (https://github.com/aws-samples/aws-lex-web-ui#running-locally)
How to generate the amazon Cognito pool Id for the amazon lex bot?
Thanks,
Harry
1) No
Amazon Lex is ultimately a service, which means it can be called from any application that calls the API appropriately. The sample provided by AWS is just an example of how to call that API. So, this is not the only way to use Amazon Lex bots from your local web application.
You can create a fully custom Bot UI from scratch (like I did) that calls the Amazon Lex API to service your application. (More on this can be found at this question that another user has asked - note that the response for this question is done in C#)
2)
There is an example provided by AWS at the following link which has a section on how to set up Cognito for this purpose (again, this is what I used to set up my own Bot)
Hope this helps you!
https://github.com/aws-samples/aws-lex-web-ui is an utility tool, which you may use, but in most cases you will end up implementing your own display logic. It most cases it is connecting it to sms, facebook, whatsapp... You have an API https://docs.aws.amazon.com/lex/latest/dg/API_runtime_PostText.html in which you can interact with Lex, I suggest using that.
I currently have a Lex chatbot that I would like to integrate with both Twilio and Cognito (in the sense that only Cognito authenticated users will be able to communicate with Twilio and the lex bot).
To this end, I've created an API Gateway that handles Twilio requests and pushes them to a Lambda function that interacts with Lex. I've also added a Cognito authorizer to my API Gateway that blocks users from interacting with Twilio if they are unauthenticated.
I don't currently have a back end app (long story), so for now users login to a Cognito-hosted UI that redirects to Google's homepage.
The problem? I haven't yet found a way to connect the authentication credentials given out at a user's Cognito log-in (which occurs on a web browser) to the API Gateway that communicates with Twilio (since Twilio is making the initial API calls). Currently there is no such connection, so all communication with Twilio (and therefore the lexbot) is blocked. I can't push the relevant tokens to Twilio when it makes the API call.
I have two feelings:
The issue probably comes from the fact that there is no connection between the web-based login and the text messages the end user sends to Twilio to kick-off the whole process
It seems like I will have to use a Custom Lambda Function Authorizer (I'd like to avoid this, if possible)
If it helps, I used this tutorial as a starting point.
Any ideas?
Any and all help or suggestions would be greatly appreciated!
Twilio developer evangelist here.
The HTTP requests that Twilio makes to the API gateway are completely disconnected from your user in a browser. About the best thing you can do to exclude users that haven't signed in is to somehow store their phone number within AWS somewhere and, like you said, use a custom authorizer to check the From phone number on the incoming webhook matches one of your users.
When you download an auto-generated API client for Java or JavaScript they reference base helper components. Is a version of these available for Xamarin, or is there any way to make or sign requests to the API Gateway using the Xamarin AWS SDK? The only thing I see is the 'test' method in the AWSSDK.APIGateway client, which seems intended for management operations.
My API requires authentication, I'm using Cognito to authenticate users.
UPDATE:
So I didn't realize at first that it was possible to call my Lambda functions directly using the AWS SDK and I don't need to use the API Gateway at all.
the auto-generated API clients are only available for iOS, Android, and JavaScript at this time. We have received requests for multiple other languages, which are on our backlog.
The API Gateway client in all of the traditional AWS SDKs is only built for the API Gateway control APIs, which are used to configure and deploy your RestApis.
You'll have to write/extend your own signer. This may be helpful: https://github.com/awslabs/aws-sdk-xamarin/blob/master/AWS.XamarinSDK/AWSSDK_Core/Amazon.Runtime/Pipeline/Handlers/Signer.cs
or the public signature docs: http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
I am trying to create a simple service using AWS API gateway and Lambda.
I want to manage small amount of user/password pairs such that they can login in to get an access token to proceed with future API calls.
I am not sure if I have chosen the right tools for this, but I am wondering if there is any existing package or model that I can use to implement this functionality?
A document titled "Amazon API Gateway + AWS Lambda + OAuth" describes what you need to do to protect a Web API implemented using Amazon API Gateway + AWS Lambda with an OAuth 2.0 access token. The introspection API (= an API to get information about an access token) used in the document is Authlete's one, but you can replace it with another different one you like. For example, if you use an authorization server implementation that supports RFC 7662 (OAuth 2.0 Token Introspection), you can use the introspection API defined in the specification.
Updated on 2016-Apr-6
On Feb 11, 2016, a blog entry of AWS Compute Blog, "Introducing custom authorizers in Amazon API Gateway", announced that Custom Authorizer had been introduced into Amazon API Gateway. Thanks to this mechanism, an API built on Amazon API Gateway can delegate validation of a Bearer token (such as an OAuth or SAML token) presented by a client application to an external authorizer.
How to protect APIs built on Amazon API Gateway by OAuth access tokens utilizing the new mechanism, Custom Authorier, is described in "Amazon APi Gateway Custom Authorizer + OAuth".