public async Task <IActionResult> Post([FromBody] Activity activity) { // Validate Authorization Header. Should be a jwt token. var authHeader = this.Request.Headers["Authorization"].SingleOrDefault(); try { await JwtTokenValidation.AssertValidActivity(activity, authHeader, this.credentials); } catch (UnauthorizedAccessException) { return(this.Unauthorized()); } // On message activity, reply with the same text if (activity.Type == ActivityTypes.Message) { var reply = activity.CreateReply($"You said: {activity.Text}"); // Reply to Activity using Connector var connector = new ConnectorClient( new Uri(activity.ServiceUrl, UriKind.Absolute), new MicrosoftAppCredentials(this.credentials.AppId, this.credentials.Password)); await connector.Conversations.ReplyToActivityAsync(reply); } return(this.Ok()); }
public async Task ProcessActivty(string authHeader, Activity activity, Func <IBotContext, Task> callback) { BotAssert.ActivityNotNull(activity); await JwtTokenValidation.AssertValidActivity(activity, authHeader, _credentialProvider, _httpClient); await base.ProcessActivityInternal(activity, callback).ConfigureAwait(false); }
public async Task Receive(string authHeader, Activity activity) { BotAssert.ActivityNotNull(activity); await JwtTokenValidation.AssertValidActivity(activity, authHeader, _credentialProvider, _httpClient); if (this.OnReceive != null) { await OnReceive(activity).ConfigureAwait(false); } }