Example #1
1
        public static async Task <List <CRMOptionDisplayValue> > GetOptionSetUserLabels(this CRMWebAPI api, string optionSetName)
        {
            var response = new List <CRMOptionDisplayValue>();

            dynamic optionSet = await api.GetOptionSetByName(optionSetName);

            foreach (dynamic option in optionSet.Options)
            {
                CRMOptionDisplayValue odv = new CRMOptionDisplayValue();
                odv.Value = option.Value;
                odv.Label = option.Label.UserLocalizedLabel.Label;
                response.Add(odv);
            }

            return(response);
        }
Example #2
0
        public static async Task GetAccountCounts(CRMWebAPI api, ITurnContext <IMessageActivity> context)
        {
            await Task.Run(async() =>
            {
                dynamic whoamiResults = await api.ExecuteFunction("WhoAmI");
                var opt = new CRMGetListOptions
                {
                    Top    = 5000,
                    Filter = "_createdby_value eq " + whoamiResults.UserId + " or _modifiedby_value eq " + whoamiResults.UserId
                };
                var count = await api.GetList("accounts", QueryOptions: opt);
                if (count == null)
                {
                    count      = new Xrm.Tools.WebAPI.Results.CRMGetListResult <ExpandoObject>();
                    count.List = new List <ExpandoObject>();
                }
                else if (count.List == null)
                {
                    count.List = new List <ExpandoObject>();
                }

                var card = new HeroCard();

                var action = new CardAction()
                {
                    Type  = ActionTypes.MessageBack,
                    Title = $"Accounts owned by me: {count.List.Count}",
                    Value = count.ToString()
                };
                card.Buttons = new List <CardAction>();
                card.Buttons.Add(action);
                await DisplayMessage(card, context);
            });
        }
        public CRMWebAPI GetAPI()
        {

            CRMWebAPI api = new CRMWebAPI("https://org.api.crm.dynamics.com/api/data/v8.0/", "access token goes here");
            return api;

        }
        public static bool IsTokenValid(ITurnContext <IMessageActivity> context, string accessToken, IConfiguration ConfigurationManager)
        {
            var result = false;

            Task.Run(async() =>
            {
                string crmBaseUrl = ConfigurationManager["CrmServerUrlProd"];
                var api           = new CRMWebAPI(crmBaseUrl + "/api/data/v8.1/", accessToken);
                try
                {
                    var results = await api.GetList("accounts", new CRMGetListOptions()
                    {
                        Top = 1
                    });
                    if (results != null && results.Count >= 0)
                    {
                        result = true;
                    }
                }
                catch (Exception ex)
                {
                }
            }).Wait();

            return(result);
        }
Example #5
0
        public CRMWebAPI GetAPI()
        {
            CRMWebAPI api = new CRMWebAPI("https://tr22a.api.crm.dynamics.com/api/data/v8.0/",
                                          "<token goes here>");

            return(api);
        }
Example #6
0
        public static async Task GetTopAccounts(CRMWebAPI api, ITurnContext <IMessageActivity> context, int count)
        {
            await Task.Run(async() =>
            {
                var card  = new HeroCard();
                var names = new List <string>();
                //var results = await api.GetList("accounts", new CRMGetListOptions() { Top = 5, FormattedValues = true });
                string fetchXml  = "<fetch mapping='logical' count='{0}'><entity name='account'><attribute name='accountid'/><attribute name='name'/></entity></fetch>";
                fetchXml         = string.Format(fetchXml, count);
                var fetchResults = await api.GetList("accounts", QueryOptions: new CRMGetListOptions()
                {
                    FetchXml = fetchXml
                });

                foreach (var item in fetchResults.List)
                {
                    IDictionary <string, object> propertyValues = item;

                    foreach (var property in propertyValues.Keys)
                    {
                        if (property.ToLowerInvariant() == "name")
                        {
                            names.Add(propertyValues[property].ToString());
                        }
                        //await context.PostAsync(String.Format("{0} : {1}", property, propertyValues[property]));
                    }
                }
                card.Buttons = CreateButtons(names);
                await DisplayMessage(card, context);
            });
        }
Example #7
0
        public static async Task <Guid> CopyEntityAttribute(this CRMWebAPI api, Guid fromEntityID, Guid toEntityID, Guid fromAttributeID, string attributeType, string logicalName)
        {
            var ec = "EntityDefinitions(" + fromEntityID.ToString() + ")/Attributes(" + fromAttributeID + ")";

            if (attributeType == "Boolean")
            {
                ec += "/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$expand=OptionSet";
            }
            if (attributeType == "Picklist")
            {
                ec += "/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$expand=OptionSet,GlobalOptionSet";
            }

            dynamic fromAttrib = await api.Get(ec, Guid.Empty);

            IDictionary <string, object> fromAttribValues = (IDictionary <string, object>)fromAttrib;

            fromAttribValues.Remove("MetadataId");
            fromAttribValues.Remove("EntityLogicalName");
            if (attributeType == "Boolean")
            {
                fromAttribValues["@odata.type"] = "Microsoft.Dynamics.CRM.BooleanAttributeMetadata";
                fromAttribValues.Remove("*****@*****.**");
                if (fromAttrib.OptionSet != null)
                {
                    IDictionary <string, object> fromOptionSetValues = (IDictionary <string, object>)fromAttrib.OptionSet;
                    fromOptionSetValues.Remove("Name");
                    fromOptionSetValues.Remove("MetadataId");
                    fromOptionSetValues.Remove("MetadataId");
                    fromOptionSetValues["IsCustomOptionSet"] = true;
                }
            }
            if (attributeType == "Picklist")
            {
                fromAttribValues["@odata.type"] = "Microsoft.Dynamics.CRM.PicklistAttributeMetadata";


                if (fromAttrib.OptionSet != null)
                {
                    IDictionary <string, object> fromOptionSetValues = (IDictionary <string, object>)fromAttrib.OptionSet;
                    fromOptionSetValues.Remove("Name");
                    fromOptionSetValues.Remove("MetadataId");
                    fromOptionSetValues.Remove("MetadataId");
                    fromOptionSetValues["IsCustomOptionSet"] = true;
                }
                else
                {
                    fromAttribValues.Remove("OptionSet");
                    fromAttribValues["*****@*****.**"] = "/GlobalOptionSetDefinitions(" + fromAttrib.GlobalOptionSet.MetadataId + ")";
                    fromAttribValues.Remove("*****@*****.**");
                    fromAttribValues.Remove("GlobalOptionSet");
                }
            }
            fromAttrib.LogicalName = logicalName;
            fromAttrib.SchemaName  = logicalName;


            return(await api.Create("EntityDefinitions(" + toEntityID.ToString() + ")/Attributes", fromAttrib));
        }
        public CRMWebAPI GetAPI()
        {

            CRMWebAPI api = new CRMWebAPI("https://tr22a.api.crm.dynamics.com/api/data/v8.0/",
                    "<token goes here>");
            return api;

        }
        public EraseRecordDataWebApi(ErasePiiObjectWebApi erasePiiObject)
        {
            _entityName    = erasePiiObject.EntityName;
            _entityRecords = erasePiiObject.EntityRecords;
            _entityId      = erasePiiObject.EntityId;
            _api           = erasePiiObject.API;

            if (_entityRecords.Count > 0)
            {
                BulkDeleteRecordsWebApi();
            }
        }
Example #10
0
        public static CRMWebAPI GetAPI()
        {
            string authority  = ConfigurationManager.AppSettings["AdOath2AuthEndpoint"];// "https://login.microsoftonline.com/common";
            string clientId   = ConfigurationManager.AppSettings["AdClientId"];
            string crmBaseUrl = ConfigurationManager.AppSettings["CrmServerUrl"];

            var            authContext = new AuthenticationContext(authority);
            UserCredential userCreds   = new UserCredential(ConfigurationManager.AppSettings["CrmUsername"], ConfigurationManager.AppSettings["CrmPassword"]);
            var            result      = authContext.AcquireToken(crmBaseUrl, clientId, userCreds);
            CRMWebAPI      api         = new CRMWebAPI(crmBaseUrl + "/api/data/v8.1/", result.AccessToken);

            return(api);
        }
        static void Main(string[] args)
        {
            var response = GetAPI();

            response.Wait();

            CRMWebAPI api = response.Result;

            Task.Run(async() =>
            {
                Xrm.Tools.WebAPI.Results.CRMGetListResult <System.Dynamic.ExpandoObject> results = await GetAccounts(api);
                dynamic result = results.List[0];
                Console.WriteLine($"Name: {result.name}\nID: {result.accountid}");
            }).Wait();
        }
        public EraseFieldDataWebApi(ErasePiiObjectWebApi erasePiiObject)
        {
            _fieldCollectionDictionary = erasePiiObject.FieldCollectionDictionary;
            _entity              = erasePiiObject.Entity;
            _fieldName           = erasePiiObject.FieldName;
            _entityName          = erasePiiObject.EntityName;
            _entityId            = erasePiiObject.EntityId;
            _entityIdLogicalName = erasePiiObject.EntityIdLogicalName;
            _resource            = erasePiiObject.Resource;
            _accessToken         = erasePiiObject.AccessToken;
            _api        = erasePiiObject.API;
            _fieldValue = erasePiiObject.FieldValue;
            _fieldType  = erasePiiObject.FieldType;
            CheckFieldType(_fieldType);

            //Task.WaitAll(Task.Run(async () => await EraseTextFieldTypeAsync()));
        }
Example #13
0
        public static void CreateNewLead(CRMWebAPI api, LeadRegisterForm result)
        {
            Task.Run(async() =>
            {
                dynamic data     = new ExpandoObject();
                data.subject     = $"New Lead Registration Request by {result.Name}";
                data.firstname   = result.Name;
                data.description = $@"New Lead registration request summary:
                                    {Environment.NewLine}Product Requested : {result.Product},
                                    {Environment.NewLine}Accounts Interested In: {result.Accounts},
                                    {Environment.NewLine}Requester's Gender: {result.Gender},
                                    {Environment.NewLine}Customer Name: {result.Name},
                                    {Environment.NewLine}Total Registrations: {result.TotalAttendees},
                                    {Environment.NewLine}Complementary Drink: {result.ComplementoryDrink}";

                var leadGuid = await api.Create("leads", data);
            }).Wait();
        }
Example #14
0
        public static async Task GetAllAccountCounts(CRMWebAPI api, ITurnContext <IMessageActivity> context)
        {
            await Task.Run(async() =>
            {
                var count = await api.GetCount("accounts");
                var card  = new HeroCard();

                var action = new CardAction()
                {
                    Type  = ActionTypes.MessageBack,
                    Title = $"Accounts in CRM: {count}",
                    Value = count.ToString()
                };
                card.Buttons = new List <CardAction>();
                card.Buttons.Add(action);
                await DisplayMessage(card, context);
            });
        }
Example #15
0
        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);
            });
        }
Example #16
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press S for clientid/secret, C for certificate auth");
            var key = Console.ReadKey();

            Task.Run(async() =>
            {
                string clientId     = ConfigurationManager.AppSettings["ClientId"];
                string clientSecret = ConfigurationManager.AppSettings["ClientSecret"];
                string apiUrl       = ConfigurationManager.AppSettings["ApiUrl"];
                string thumb        = ConfigurationManager.AppSettings["CertThumb"];

                var authParams  = await AuthenticationParameters.CreateFromResourceUrlAsync(new Uri(apiUrl));
                var authContext = new AuthenticationContext(authParams.Authority);

                // clientid/secret
                var clientCreds = new ClientCredential(clientId, clientSecret);

                // certificate
                X509Store store = new X509Store(StoreLocation.CurrentUser);
                store.Open(OpenFlags.ReadOnly);
                var certs     = store.Certificates.Find(X509FindType.FindByThumbprint, thumb, false);
                var cert      = certs[0];
                var certCreds = new ClientAssertionCertificate(clientId, certs[0]);

                AuthenticationResult result;
                if (key.Key == ConsoleKey.S)
                {
                    result = await authContext.AcquireTokenAsync(authParams.Resource,
                                                                 clientCreds);
                }
                else
                {
                    result = await authContext.AcquireTokenAsync(authParams.Resource,
                                                                 certCreds);
                }

                CRMWebAPI api  = new CRMWebAPI(apiUrl, result.AccessToken);
                dynamic whoAmI = await api.ExecuteFunction("WhoAmI");
                Console.WriteLine($"{whoAmI.OrganizationId},{whoAmI.BusinessUnitId},{whoAmI.UserId}");
                Console.ReadLine();
            }).Wait();
        }
Example #17
0
        public static async Task <CRMWebAPI> GetAPI(IConfiguration ConfigurationManager)
        {
            string clientSecret = ConfigurationManager["ClientSecret"];
            string authority    = ConfigurationManager["AdOath2AuthEndpoint"]; // "https://login.microsoftonline.com/common?client_secret=";
            string clientId     = ConfigurationManager["AdClientId"];
            string crmBaseUrl   = ConfigurationManager["CrmServerUrl"];        //+ "?client_secret=" + clientSecret;
            string tenantID     = ConfigurationManager["TenantId"];
            string authResource = "https://login.windows.net/" + tenantID + "/";

            var authContext = new AuthenticationContext(authResource, false);
            //UserCredential userCreds = new UserCredential(ConfigurationManager.AppSettings["CrmUsername"], ConfigurationManager.AppSettings["CrmPassword"]);
            var userCreds = new UserCredential();
            //var result = authContext.AcquireToken(crmBaseUrl, clientId, new Uri("http://localhost:3979"),PromptBehavior.Auto,UserIdentifier.AnyUser,"client_secret=" + clientSecret);
            var result = await authContext.AcquireTokenAsync(crmBaseUrl, clientId, userCreds);

            CRMWebAPI api = new CRMWebAPI(crmBaseUrl + "/api/data/v8.1/", result.AccessToken);

            return(api);
        }
Example #18
0
        public static Tuple <string, string, CRMWebAPI> ConnectToCRMWithApplicationUser(string authority, string appSecret,
                                                                                        string clientId, string resource)
        {
            //Console.WriteLine("Authority is: " +authority);
            //Console.WriteLine("App Secret is: " +appSecret);
            //Console.WriteLine("Client Id is: " + clientId);
            //Console.WriteLine("Resource is: " + resource);
            if (authority == null)
            {
                throw new ArgumentNullException(nameof(authority));
            }
            if (resource == null)
            {
                throw new ArgumentNullException(nameof(resource));
            }
            if (appSecret == null)
            {
                throw new ArgumentNullException(nameof(appSecret));
            }
            if (clientId == null)
            {
                throw new ArgumentNullException(nameof(clientId));
            }

            try
            {
                var clientCredential = new ClientCredential(clientId, appSecret);

                var authContext          = new AuthenticationContext(authority);
                var authenticationResult = authContext.AcquireToken(resource, clientCredential);
                var crmToken             = authenticationResult.AccessToken;
                crmWebApi = new CRMWebAPI(resource + "/api/data/v9.1/", authenticationResult.AccessToken);
                //Console.WriteLine("The CRM Token is: " + crmToken);
                //Console.WriteLine("The client crendential is: " +clientCredential);
                return(new Tuple <string, string, CRMWebAPI>(crmToken, resource, crmWebApi));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Example #19
0
        public static async Task <ExpandoObject> GetOptionSetByName(this CRMWebAPI api, string optionSetName)
        {
            CRMGetListOptions options = new CRMGetListOptions()
            {
                Select = new[] { "Name" }
            };

            var queryResult = await api.GetList("GlobalOptionSetDefinitions", options);

            foreach (dynamic optionSet in queryResult.List)
            {
                if ((optionSet != null) && (optionSet.Name == optionSetName))
                {
                    var matchingOptionSet = await api.Get("GlobalOptionSetDefinitions", Guid.Parse(optionSet.MetadataId));

                    return(matchingOptionSet);
                }
            }

            return(null);
        }
 public DynamicsListsGateway(CRMWebAPI api)
 {
     this.api = api;
 }
Example #21
0
 public AccountRepo()
 {
     _api = new API().Connection;
 }
Example #22
0
 public SubmissionDynamicsCustomActionHandler(CRMWebAPI api, ILogger <SubmissionDynamicsCustomActionHandler> logger, ICachedListsProvider cachedListsProvider)
 {
     this.api    = api;
     this.logger = logger;
     this.cachedListsProvider = cachedListsProvider;
 }
        public CRMWebAPI GetAPI()
        {
            CRMWebAPI api = new CRMWebAPI("https://orgname.api.crm.dynamics.com/api/data/v9.0/", "");

            return(api);
        }
Example #24
0
 public OrderRepo()
 {
     _api = new API().Connection;
 }
Example #25
0
 public ODataClient(string crmUrl, string accessToken, double crmVersion = 9.1)
 {
     this.CrmApiUrl = $"{crmUrl}/api/data/v{crmVersion}/";
     AccessToken    = accessToken;
     ApiClient      = new CRMWebAPI(CrmApiUrl, this.AccessToken);
 }
Example #26
0
 public ConfigHealthProvider(IConfiguration configuration, CRMWebAPI api, ILogger <ConfigHealthProvider> logger)
 {
     conf        = configuration;
     this.api    = api;
     this.logger = logger;
 }
Example #27
0
        public static async Task <List <CRMAttributeDisplayName> > GetAttributeDisplayNameList(this CRMWebAPI api, Guid entityID, int LCID = 0)
        {
            var result = new List <CRMAttributeDisplayName>();

            CRMGetListOptions options = new CRMGetListOptions()
            {
                Filter = "((IsValidForRead eq true) and (AttributeOf eq null))",

                Select = new[] { "MetadataId", "DisplayName", "LogicalName", "SchemaName", "AttributeType", "IsPrimaryId" }
            };

            var queryResults = await api.GetList("EntityDefinitions(" + entityID.ToString() + ")/Attributes", options);

            foreach (dynamic attrib in queryResults.List)
            {
                CRMAttributeDisplayName edm = new CRMAttributeDisplayName();
                edm.MetadataId    = Guid.Parse(attrib.MetadataId);
                edm.LogicalName   = attrib.LogicalName;
                edm.SchemaName    = attrib.SchemaName;
                edm.IsPrimaryId   = attrib.IsPrimaryId;
                edm.AttributeType = attrib.AttributeType;
                if (attrib.AttributeType == "Lookup" || attrib.AttributeType == "Customer" || attrib.AttributeType == "Owner")
                {
                    edm.ODataLogicalName = "_" + attrib.LogicalName + "_value";
                }
                else
                {
                    edm.ODataLogicalName = attrib.LogicalName;
                }

                if ((attrib.DisplayName.LocalizedLabels != null) && (attrib.DisplayName.LocalizedLabels.Count > 0))
                {
                    edm.DisplayName = attrib.DisplayName.LocalizedLabels[0].Label;
                    if (LCID != 0)
                    {
                        foreach (dynamic label in attrib.DisplayName.LocalizedLabels)
                        {
                            if (label.LanguageCode == LCID)
                            {
                                edm.DisplayName = label.Label;
                            }
                        }
                    }
                }
                else
                {
                    edm.DisplayName = edm.LogicalName;
                }
                edm.LogicalDisplayName = edm.DisplayName + "(" + edm.LogicalName + ")";
                result.Add(edm);
            }



            return(result);
        }
 public ErasePiiBuilderWebApi(CRMWebAPI api)
 {
     _api = api;
 }
Example #29
0
 public ProductRepo()
 {
     _api = new API().Connection;
 }
        // Retrieve all accounts
        public static async Task <Xrm.Tools.WebAPI.Results.CRMGetListResult <System.Dynamic.ExpandoObject> > GetAccounts(CRMWebAPI api)
        {
            var results = await api.GetList("accounts",
                                            new Xrm.Tools.WebAPI.Requests.CRMGetListOptions()
            {
                TrackChanges = true, FormattedValues = true
            });

            return(results);
        }
Example #31
0
        public static async Task <List <CRMEntityDisplayName> > GetEntityDisplayNameList(this CRMWebAPI api, int LCID = 0)
        {
            var result = new List <CRMEntityDisplayName>();

            CRMGetListOptions options = new CRMGetListOptions()
            {
                Filter = "IsPrivate eq false",

                Select = new[] { "MetadataId", "EntitySetName", "DisplayName",
                                 "DisplayCollectionName", "LogicalName", "LogicalCollectionName", "PrimaryIdAttribute" }
            };

            var queryResults = await api.GetList("EntityDefinitions", options);

            foreach (dynamic entity in queryResults.List)
            {
                CRMEntityDisplayName edm = new CRMEntityDisplayName();
                edm.MetadataId            = Guid.Parse(entity.MetadataId);
                edm.EntitySetName         = entity.EntitySetName;
                edm.LogicalName           = entity.LogicalName;
                edm.LogicalCollectionName = entity.LogicalCollectionName;
                edm.PrimaryIdAttribute    = entity.PrimaryIdAttribute;
                if ((entity.DisplayName.LocalizedLabels != null) && (entity.DisplayName.LocalizedLabels.Count > 0))
                {
                    edm.DisplayName = entity.DisplayName.LocalizedLabels[0].Label;
                    if (LCID != 0)
                    {
                        foreach (dynamic label in entity.DisplayName.LocalizedLabels)
                        {
                            if (label.LanguageCode == LCID)
                            {
                                edm.DisplayName = label.Label;
                            }
                        }
                    }
                }
                else
                {
                    edm.DisplayName = edm.LogicalName;
                }
                if ((entity.DisplayCollectionName.LocalizedLabels != null) && (entity.DisplayCollectionName.LocalizedLabels.Count > 0))
                {
                    edm.DisplayCollectionName = entity.DisplayCollectionName.LocalizedLabels[0].Label;
                    if (LCID != 0)
                    {
                        foreach (dynamic label in entity.DisplayCollectionName.LocalizedLabels)
                        {
                            if (label.LanguageCode == LCID)
                            {
                                edm.DisplayCollectionName = label.Label;
                            }
                        }
                    }
                }
                else
                {
                    edm.DisplayCollectionName = entity.LogicalCollectionName;
                }
                edm.LogicalDisplayName           = edm.DisplayName + "(" + edm.LogicalName + ")";
                edm.LogicalDisplayCollectionName = edm.DisplayCollectionName + "(" + edm.LogicalCollectionName + ")";

                result.Add(edm);
            }

            return(result);
        }
Example #32
0
        public static async Task GetProductInfo(CRMWebAPI api, ITurnContext <IMessageActivity> context, string product)
        {
            var isTeams = context.Activity.ChannelId.ToLowerInvariant() == "msteams";
            var isSkype = context.Activity.ChannelId.ToLowerInvariant() == "skypeforbusiness";
            await Task.Run(async() =>
            {
                var card      = new HeroCard();
                var adaptCard = new AdaptiveCard(new AdaptiveSchemaVersion());
                var factSet   = new AdaptiveChoiceSetInput()
                {
                    Choices = new List <AdaptiveChoice>(), Spacing = AdaptiveSpacing.Medium
                };
                //card.Body.Add(factSet);

                var names        = new List <string>();
                string fetchXml  = @"<fetch mapping='logical'>
                                        <entity name='product'> 
                                          <attribute name='productid'/> 
                                          <attribute name='name'/> 
                                        <filter type='and'> 
                                            <condition attribute='name' operator='eq' value='{0}' /> 
                                        </filter> 
                                       </entity> 
                                </fetch>";
                fetchXml         = string.Format(fetchXml, product);
                var fetchResults = await api.GetList("products", QueryOptions: new CRMGetListOptions()
                {
                    FetchXml = fetchXml
                });

                foreach (var item in fetchResults.List)
                {
                    IDictionary <string, object> propertyValues = item;

                    foreach (var property in propertyValues.Keys)
                    {
                        string text = $"*{property}* : {propertyValues[property].ToString()}";
                        if (isTeams || isSkype)
                        {
                            card.Buttons.Add(new CardAction()
                            {
                                Text = text, Value = text, Type = ActionTypes.MessageBack
                            });
                        }
                        else
                        {
                            adaptCard.Body.Add(new AdaptiveTextBlock()
                            {
                                Text = text
                            });
                        }
                    }
                }
                if (isTeams || isSkype)
                {
                    await DisplayMessage(card, context);
                }
                else
                {
                    await DisplayMessage(adaptCard, context);
                }
            });
        }