public async Task <RecastBot> GetBotAsync(string botSlug) { RecastBot bot = new RecastBot(); var response = await Get($"bots/{botSlug}"); if (response != null) { object result = JsonConvert.DeserializeObject <ServiceResponse>(response).Results; bot = JsonConvert.DeserializeObject <RecastBot>(result.ToString()); } return(bot); }
static async Task MainAsync() { // Create Helper Instance RecastAIHelper.RecastAIClient client = new RecastAIHelper.RecastAIClient(token, userSlug); // Retrieve all bots of specific user IReadOnlyCollection <RecastBotLight> bots = await client.GetAllBotsAsync(); // Obtain specific bot details RecastBot bot = await client.GetBotAsync(botSlug); // Update Bot details bot = await client.UpdateBotAsync(botSlug, description : "Description via SDK"); // Obtain List of Entities for specific bot IReadOnlyCollection <Entity> entities = await client.GetAllEntitiesAsync(botSlug); // Obtain List of Intents for specific bot IReadOnlyCollection <Intent> intents = await client.GetAllIntentsAsync(botSlug); // Retrieve Intent pagewise IReadOnlyCollection <Intent> intentsPageWise = await client.GetIntentsPagewiseAsync(botSlug, 1, 2); // Obtain specific intent details Intent intent = await client.GetIntentDetailsAsync(botSlug, "intentSlug"); // Create new Intent intent = await client.CreateIntentAsync(botSlug, "intentSlug", "description", new List <Expression> { new Expression("Hello From SDK", "en") }); // Update Intent intent = await client.UpdateIntentAsync(botSlug, "intentSlug", "Intent Name", "Intent Desciption"); // Delete Intnet await client.DeleteIntentAsync(botSlug, "intentSlug"); // Obtain Entities of Intent pagewise IReadOnlyCollection <Entity> entitiesForIntent = await client.GetEntitiesOfIntentAsync(botSlug, "intentSlug", 1, 1); // Obtain List of Expressions IReadOnlyCollection <Expression> expressions = await client.GetExpressionsAsync(botSlug, "intentSlug", 1, 2); // Obtain expression Expression expression = await client.GetExpressionDetailsAsync(botSlug, "intentSlug", "expressionGuid"); // Update Expression Expression updatedExpression = await client.UpdateExpressionAsync(botSlug, "intentSlug", "expressionGuid", "sourceText"); // Delete specific Expression from Intent bool status = await client.DeleteExpressionAsync(botSlug, "intentSlug", "expressionGuid"); }
public async Task <RecastBot> UpdateBotAsync(string botSlug, string name = null, string description = null, int?strictness = null, bool? @public = null, string language = null) { RecastBot updatedBot = null; dynamic requestBody = new ExpandoObject(); if (!string.IsNullOrEmpty(name)) { requestBody.name = name; } if (!string.IsNullOrEmpty(description)) { requestBody.description = description; } if (strictness >= 0 && strictness <= 100) { requestBody.strictness = strictness; } if (@public.HasValue) { requestBody.@public = @public; } if (!string.IsNullOrEmpty(language)) { requestBody.language = language; } var response = await Put($"bots/{botSlug}", requestBody); if (response != null) { ServiceResponse serviceResponse = JsonConvert.DeserializeObject <ServiceResponse>(response); if (serviceResponse.Message.Equals("Bot rendered with success")) { updatedBot = JsonConvert.DeserializeObject <RecastBot>(serviceResponse.Results.ToString()); } } return(updatedBot); }