public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> argument) { var message = await argument; //CrmDataConnection.GetAPI(); if (message.Text.Contains("test drive")) { testDriveDetail = new TestDriveDetail(); PromptDialog.Text( context: context, resume: CarMakeHandler, prompt: "What car make do you want to test?", retry: "Sorry, I don't understand that." ); } else if (message.Text == "No") { } else { await context.PostAsync("Hi there, anything that I can help for you today?"); context.Wait(MessageReceivedAsync); } }
public async Task BrocureRequest(IDialogContext context, LuisResult result) { testDriveDetail = new TestDriveDetail(); PromptDialog.Text( context: context, resume: BrochureRequestHandler, prompt: "Which car do you want to get the brochure information?", retry: "Sorry, I don't understand that." ); }
public async Task TestDrive(IDialogContext context, LuisResult result) { testDriveDetail = new TestDriveDetail(); PromptDialog.Text( context: context, resume: CarMakeHandler, prompt: "What car make do you want to test?", retry: "Sorry, I don't understand that." ); }
public static void CreateTestDrive(TestDriveDetail testDrive, IOrganizationService crmService) { var lead = new Microsoft.Xrm.Sdk.Entity(EntityName); //lead.Attributes lead.Attributes.Add(Field_Subject, $"Test Drive Request by {testDrive.CustomerName}"); lead.Attributes.Add(Field_FirstName, testDrive.CustomerName); lead.Attributes.Add(Field_Description, $@"Test drive request summary: {Environment.NewLine}Car Make: {testDrive.CarMake}, {Environment.NewLine}Car Model: {testDrive.CarModel}, {Environment.NewLine}Requested Time: {testDrive.RequestedTime}, {Environment.NewLine}Customer Name: {testDrive.CustomerName}, {Environment.NewLine}Phone Number: {testDrive.PhoneNumber}"); crmService.Create(lead); }
public static void CreateTestDrive(TestDriveDetail testDrive, CRMWebAPI api) { Task.Run(async() => { dynamic data = new ExpandoObject(); data.subject = $"Test Drive Request by {testDrive.CustomerName}"; data.firstname = testDrive.CustomerName; data.description = $@"Test drive request summary: {Environment.NewLine}Car Make: {testDrive.CarMake}, {Environment.NewLine}Car Model: {testDrive.CarModel}, {Environment.NewLine}Requested Time: {testDrive.RequestedTime}, {Environment.NewLine}Customer Name: {testDrive.CustomerName}, {Environment.NewLine}Phone Number: {testDrive.PhoneNumber}"; var leadGuid = await api.Create("leads", data); }); }
public static IForm <CarInquiryFormFlow> BuildForm() { OnCompletionAsyncDelegate <CarInquiryFormFlow> processRequest = async(context, state) => { await context.PostAsync($@"Your test drive request summary: {Environment.NewLine}Car Make: {state.CarMake.ToString()}, {Environment.NewLine}Car Model: {state.CarModel.ToString()}, {Environment.NewLine}Requested Time: {state.PreferredTime}, {Environment.NewLine}Customer Name: {state.Name}, {Environment.NewLine}Phone Number: {state.ContactNumber}"); var testDriveDetail = new TestDriveDetail { CarMake = state.CarMake.ToString(), CarModel = state.CarModel.ToString(), RequestedTime = state.PreferredTime, CustomerName = state.Name, PhoneNumber = state.ContactNumber }; // save the data to CRM CrmLead.CreateTestDrive(testDriveDetail, CrmDataConnection.GetOrgService()); }; return(new FormBuilder <CarInquiryFormFlow>() .Message("Welcome to the car test drive bot!") .Field(nameof(CarMake)) .Field(nameof(CarModel)) .Field(nameof(PreferredTime)) .Field(nameof(Name)) .Field(nameof(ContactNumber)) .AddRemainingFields() .Message("Thank you for your interest, your request has been logged. Our sales team will get back to you shortly.") .OnCompletion(processRequest) .Build()); }