private async Task PerformActionListAsync(ITurnContext turnContext, CancellationToken cancellationToken, List <TriggerAction> actionList) { foreach (var action in actionList) { var userInput = turnContext.Activity.Text; if (action.Type == Model.ActionTypes.SendMessage) { try { var message = this.dialogModel.Messages.Where(x => x.Id == action.MessageId).Select(x => x).First(); message.Text = message.Text.Replace("{input}", userInput); await dialogMessageHandler.SendMessageAsync(turnContext, cancellationToken, message); } catch (System.Exception e) { throw new Exception("[DialogGenerator] Please check, if your messageIds match the actions.", e); } } else if (action.Type == Model.ActionTypes.SendInitMessage) { await dialogMessageHandler.SendInitialMessage(turnContext, cancellationToken); } else if (action.Type == Model.ActionTypes.SendQnaMessage) { try { QnaResponse qnaResponse = await QnaMakerService.GetQnaResultAsync( userInput, dialogModel.QnaSettings.Host, dialogModel.QnaSettings.Route, dialogModel.QnaSettings.EndpointKey); await dialogMessageHandler.SendQnaMessageAsync(turnContext, cancellationToken, qnaResponse); } catch (System.Exception e) { throw new Exception("[DialogGenerator] Qna Message failed to send properly.", e); } } else if (action.Type == Model.ActionTypes.SendLuisMessage) { try { LuisResponse luisResponse = await LuisService.GetLuisResultAsync( userInput, dialogModel.LuisSettings.Region, dialogModel.LuisSettings.AppId, dialogModel.LuisSettings.SubscriptionKey ); var topIntent = luisResponse.TopScoringIntent; if (topIntent.IntentIntent == "None" || topIntent.Score < dialogModel.LuisSettings.Threshold) { await dialogMessageHandler.SendDefaultMessage(turnContext, cancellationToken); } else { // Send the message specified in the dialog structure var message = this.dialogModel.Messages.Where(x => x.Id == topIntent.IntentIntent).First(); message.Text = ReplaceWithLuisEntities(message.Text, luisResponse); await dialogMessageHandler.SendMessageAsync(turnContext, cancellationToken, message); } } catch (System.Exception e) { throw new Exception("[DialogGenerator] LUIS Message failed to send properly.", e); } } else if (action.Type == Model.ActionTypes.SendAzureSearchMessage) { try { string azureSearchResultJson = await AzureSearchService.GetAzureSearchAnswersAsync( userInput, dialogModel.AzureSearchSettings.HostUrl.ToString(), dialogModel.AzureSearchSettings.EndpointKey ); await dialogMessageHandler.SendAzureSearchResultAsync( turnContext, cancellationToken, dialogModel.AzureSearchSettings.MessageMapping, azureSearchResultJson ); } catch (System.Exception e) { throw new Exception("[DialogGenerator] Azure Search message failed to process.", e); } } else if (action.Type == Model.ActionTypes.SendAzureSearchFilterMessage) { try { // Perform an Azure Search filter and return results as string string azureSearchResultJson = await AzureSearchService.GetAzureSearchFilterAnswersAsync( action.Value, action.Parameters, _topicState.TopicStateStrings, dialogModel.AzureSearchSettings.HostUrl.ToString(), dialogModel.AzureSearchSettings.EndpointKey ); // Send the results of the AzureSearchQuery await dialogMessageHandler.SendAzureSearchResultAsync( turnContext, cancellationToken, dialogModel.AzureSearchSettings.MessageMapping, azureSearchResultJson ); } catch (System.Exception e) { throw new Exception("[DialogGenerator] Azure Search message failed to process.", e); } } else if (action.Type == Model.ActionTypes.StoreState) { try { _topicState.TopicStateStrings["dialogState"] = action.Value; } catch (System.Exception e) { throw new Exception("[DialogGenerator] State could not be stored properly.", e); } } else if (action.Type == Model.ActionTypes.StoreCustomValue) { try { // store the userInput in a state variable that is specified in the triggerAction of the dialog structure _topicState.TopicStateStrings[action.Value] = userInput; } catch (System.Exception e) { throw new Exception("[DialogGenerator] State could not be stored properly.", e); } } else { await dialogMessageHandler.SendDefaultMessage(turnContext, cancellationToken); } } }