Updating your Post method

Let's use the following code to update your Post method:

public async Task<HttpResponseMessage> Post([FromBody]Activity activity)         {             if (activity.Type == ActivityTypes.Message)             {                 ConnectorClient connector = new ConnectorClient(new                 Uri(activity.ServiceUrl));                 StateClient stateClient = activity.GetStateClient();                 Query Result = new Query();                 try                 {                     if (activity.Text != null)                     {                         string strContextId = "";                         BotData userData = await                          stateClient.BotState.GetUserDataAsync                        (activity.ChannelId, activity.From.Id);                         if (userData.GetProperty<string>                        ("contextId")!=null)                         {                             // If we have a ContextId saved in TempData                             // retrieve it                             strContextId = userData.GetProperty<string>                             ("contextId").ToString();                         }  LUIS objLUISResult ...

Get Building Bots with Microsoft Bot Framework now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.