public async Task ProcessIntent(AIResponse aIResponse) { AccessToken accessToken = await _tokenManager.GetAccessTokenFromCache().ConfigureAwait(false); _lineMessagingClient = new LineMessagingClient(accessToken.access_token); var app = new LineBotApp(_lineMessagingClient); // try case IntentName to IntentType Enum IntentType intentType = IntentType.Unknown; if (Enum.TryParse <IntentType>(aIResponse.Result.Metadata.IntentName, out intentType)) { aIResponse.Result.Metadata.IntentType = intentType; } Event tempEvent = new Event(); switch (aIResponse.Result.Metadata.IntentType) { case IntentType.ButtonIntent: // Down Cast tempEvent = aIResponse.OriginalRequest.Event; MessageEvent messageEventTemp = (MessageEvent)tempEvent; TextEventMessage eventMessageTemp = (TextEventMessage)messageEventTemp.Message; eventMessageTemp.Text = "buttons"; break; default: break; } await app.RunAsync(new List <WebhookEvent>(){ (WebhookEvent)tempEvent }); }
public async Task <IActionResult> Post([FromBody] JsonElement req) { var events = WebhookEventParser.Parse(req.ToString()); var app = new LineBotApp(lineMessagingClient, appSettings); await app.RunAsync(events); return(new OkResult()); }
public async Task <IActionResult> Post([FromBody] JToken req) { var events = WebhookEventParser.Parse(req.ToString()); var app = new LineBotApp(LineMessagingClientManager.GetInstance(), _context, _tContext, _services); await app.RunAsync(events); return(new OkResult()); }
public async Task <IActionResult> Post([FromBody] JsonElement req) { // 受け取ったリクエストをLINEのSDK上で扱えるイベントに変換 var events = WebhookEventParser.Parse(req.ToString()); // アプリ実行 var app = new LineBotApp(lineMessaingClient, this.cosmosDbService); await app.RunAsync(events); return(new OkResult()); }
public async Task <IActionResult> Post(HttpRequestMessage request) { var events = await request.GetWebhookEventsAsync(configuration["Line:ChannelSecret"]); var connectionString = configuration["StorageConnectionString"]; var talkLog = await TableStorage <TalkLog> .CreateAsync(connectionString, "ChildsNotification"); var app = new LineBotApp(line, talkLog); await app.RunAsync(events); return(new OkResult()); }
public async Task<HttpResponseMessage> Post(HttpRequestMessage request) { var events = await request.GetWebhookEventsAsync(channelSecret); var connectionString = ConfigurationManager.AppSettings["StorageConnectionString"]; var blobStorage = await BlobStorage.CreateAsync(connectionString, "linebotcontainer"); var eventSourceState = await TableStorage<EventSourceState>.CreateAsync(connectionString, "eventsourcestate"); var app = new LineBotApp(lineMessagingClient, eventSourceState, blobStorage); await app.RunAsync(events); return Request.CreateResponse(HttpStatusCode.OK); }
public async Task <IActionResult> Post([FromBody] JToken req) { var events = WebhookEventParser.Parse(req.ToString()); var connectionString = appsettings.LineSettings.StorageConnectionString; var blobStorage = await BlobStorage.CreateAsync(connectionString, "linebotcontainer"); var eventSourceState = await TableStorage <EventSourceState> .CreateAsync(connectionString, "eventsourcestate"); var app = new LineBotApp(lineMessagingClient, eventSourceState, blobStorage); await app.RunAsync(events); return(new OkResult()); }
public async Task <IActionResult> Post() { AccessToken accessToken = await _tokenManager.GetAccessTokenFromCache().ConfigureAwait(false); _messagingClient = new LineMessagingClient(accessToken.access_token); var events = await Request.GetWebhookEventsAsync(_botCredential.AppSecret); var app = new LineBotApp(_messagingClient); await app.RunAsync(events); return(Ok()); }
public async Task <IActionResult> Post() { try { var events = await _httpContext.Request.GetWebhookEventsAsync(_lineBotConfig.channelSecret); var lineMessagingClient = new LineMessagingClient(_lineBotConfig.accessToken); var lineBotApp = new LineBotApp(lineMessagingClient); await lineBotApp.RunAsync(events); } catch (Exception ex) { //需要 Log 可自行加入 //_logger.LogError(JsonConvert.SerializeObject(ex)); } return(Ok()); }
/// <summary> /// Main run method /// </summary> /// <param name="req">HttpRequestMessage</param> /// <param name="log">TraceWriter</param> /// <returns>Result</returns> public static async Task <IActionResult> Run(HttpRequestMessage req, TraceWriter log) { try { log.Info("C# HTTP trigger function processed a request."); var channelSecret = Environment.GetEnvironmentVariable("ChannelSecret"); var events = await req.GetWebhookEventsAsync(channelSecret); var connectionString = Environment.GetEnvironmentVariable("AzureWebJobsStorage"); var eventSourceState = await TableStorage <EventSourceState> .CreateAsync(connectionString, "eventsourcestate"); var blobStorage = await BlobStorage.CreateAsync(connectionString, "linebotcontainer"); // Create the LineBotApp and run it. var app = new LineBotApp(lineMessagingClient, eventSourceState, blobStorage, log); await app.RunAsync(events); } catch (InvalidSignatureException e) { return(new ObjectResult(e.Message) { StatusCode = (int)HttpStatusCode.Forbidden }); } catch (LineResponseException e) { log.Error(e.ToString()); var debugUserId = Environment.GetEnvironmentVariable("DebugUser"); if (debugUserId != null) { await lineMessagingClient.PushMessageAsync(debugUserId, $"{e.StatusCode}({(int)e.StatusCode}), {e.ResponseMessage.ToString()}"); } } catch (Exception e) { log.Error(e.ToString()); var debugUserId = Environment.GetEnvironmentVariable("DebugUser"); if (debugUserId != null) { await lineMessagingClient.PushMessageAsync(debugUserId, e.Message); } } return(new OkObjectResult("OK")); }
public async Task <IActionResult> Confirm() { // transactionId を取得して、キャッシュから決済予約を取得 var transactionId = Int64.Parse(HttpContext.Request.Query["transactionId"]); var reserve = CacheService.Cache[transactionId] as Reserve; // 決済確認の作成 var confirm = new Confirm() { Amount = reserve.Amount, Currency = reserve.Currency }; var response = await linePayClient.ConfirmAsync(transactionId, confirm); var app = new LineBotApp(lineMessagingClient, linePayClient, appsettings); await app.SendPayConfirm(reserve); return(new OkResult()); }
// POST api/values public async Task <IHttpActionResult> PostAsync(HttpRequestMessage request) { string jsonContent = request.Content.ReadAsStringAsync().Result; DataClasses1DataContext db = new DataClasses1DataContext(); JSONLog a = new JSONLog() { Message = jsonContent }; db.JSONLogs.InsertOnSubmit(a); db.SubmitChanges(); var events = await request.GetWebhookEventsAsync(channelSecret); //var connectionString = ConfigurationManager.AppSettings["StorageConnectionString"]; //var blobStorage = await BlobStorage.CreateAsync(connectionString, "linebotcontainer"); //var eventSourceState = await TableStorage<EventSourceState>.CreateAsync(connectionString, "eventsourcestate"); var app = new LineBotApp(lineMessagingClient); await app.RunAsync(events); return(Ok()); }
public LineController(LineBotApp app) { _app = app; }