示例#1
0
        partial void sendMessage(UIButton sender)
        {
            Console.WriteLine("Message is " + messageText);
            //sendMessageApi(messageText.Text);
            messages.Add("You: " + messageText.Text);
            tableView.ReloadData();

            AmazonLexClient lexClient = new AmazonLexClient(accessKey, accessKeySecret, accessSessionToken, Amazon.RegionEndpoint.USEast1);

            PostTextRequest request = new PostTextRequest();

            request.BotName   = "GolfNowReservation";
            request.BotAlias  = "GolfNowTest";
            request.UserId    = "250";
            request.InputText = messageText.Text;


            var task = lexClient.PostTextAsync(request);

            messages.Add("Bot: " + task.Result.Message);


            messageText.Text = "";
            tableView.ReloadData();
            //throw new NotImplementedException();
        }
示例#2
0
        protected void InitLexService()
        {
            awsCredentials = new CognitoAWSCredentials(
                _awsOptions.CognitoPoolID, // Identity pool ID
                RegionEndpoint.USEast1);   // Region

            awsLexClient = new AmazonLexClient(awsCredentials, RegionEndpoint.USEast1);
        }
示例#3
0
        public static AmazonLexClient GetAmazonLexClient()
        {
            string AWSKey = ConfigurationSettings.AppSettings["AWSKey"];

            string AWSSecKey = ConfigurationSettings.AppSettings["AWSSecKey"];

            lexClient = new AmazonLexClient(AWSKey, AWSSecKey, RegionEndpoint.USEast1);
            return(lexClient);
        }
        public AmazonLexService(IOptions <AmazonLexLutherConfig> amazonLexOptions)
        {
            _amazonLexConfig = amazonLexOptions.Value;

            var regionEndpoint = Amazon.RegionEndpoint.GetBySystemName(_amazonLexConfig.BotRegion);

            var awsCredentials = new CognitoAWSCredentials(_amazonLexConfig.CognitoPoolId, regionEndpoint);

            _amazonLexClient = new AmazonLexClient(awsCredentials, regionEndpoint);
        }
示例#5
0
        protected void InitializeLex() //-> Pull the Cognito code out and use the CognitoLexLibrary we created
        {
            Amazon.RegionEndpoint svcRegionEndpoint;
            svcRegionEndpoint = Amazon.RegionEndpoint.GetBySystemName(_awsOptions.LexBotRegion);

            awsCredentials = new CognitoAWSCredentials(
                _awsOptions.CognitoPoolID,
                svcRegionEndpoint);

            // Init lex
            awsLexClient = new AmazonLexClient(awsCredentials, svcRegionEndpoint);
        }
        protected IAmazonLex CreateClient(AWSCredentials credentials, RegionEndpoint region)
        {
            var config = new AmazonLexConfig {
                RegionEndpoint = region
            };

            Amazon.PowerShell.Utils.Common.PopulateConfig(this, config);
            this.CustomizeClientConfig(config);
            var client = new AmazonLexClient(credentials, config);

            client.BeforeRequestEvent += RequestEventHandler;
            client.AfterResponseEvent += ResponseEventHandler;
            return(client);
        }
        protected void InitLexService()
        {
            Amazon.RegionEndpoint svcRegionEndpoint;

            //Grab region for Lex Bot services
            svcRegionEndpoint = Amazon.RegionEndpoint.GetBySystemName(_awsOptions.BotRegion);

            //Get credentials from Cognito
            awsCredentials = new CognitoAWSCredentials(
                _awsOptions.CognitoPoolID,          // Identity pool ID
                svcRegionEndpoint);                 // Region

            //Instantiate Lex Client with Region
            awsLexClient = new AmazonLexClient(awsCredentials, svcRegionEndpoint);
        }
示例#8
0
        private async Task <string> GetIntentFromLexAsync(String customerContact)
        {
            try
            {
                AmazonLexClient lexClient   = new AmazonLexClient(primaryRegion);
                PostTextRequest textRequest = new PostTextRequest();
                textRequest.UserId    = "MailBot";
                textRequest.BotAlias  = "DEV";
                textRequest.BotName   = "NBC_Mailbot_Intents";
                textRequest.InputText = customerContact;
                PostTextResponse textRespone = await lexClient.PostTextAsync(textRequest);

                return(textRespone.IntentName);
            }
            catch (Exception error)
            {
                await SendFailureAsync("Getting Intent", error.Message);

                Console.WriteLine("ERROR : GetIntentFromLexAsync : " + error.StackTrace);
                return("GeneralEnquiries");
            }
        }
示例#9
0
 public LexService(DataService dataService)
 {
     _lex         = new AmazonLexClient(Amazon.RegionEndpoint.USEast1);
     _dataService = dataService;
 }
示例#10
0
 public AWSLexService(AmazonLexClient awsLexClient, ILogger <AWSLexService> logger, IOptions <LexOptions> lexOptions)
 {
     _awsLexClient = awsLexClient;
     _logger       = logger;
     _lexOptions   = lexOptions.Value;
 }