Exemplo n.º 1
0
        public async static Task <string> PostMessage(string message)
        {
            BotClient botClient = new BotClient();

            //这里测试的是贩卖机的Bot
            string botFrom         = "Demo";
            string botConnectorKey = "Put your DL3.0 key here";

            ConversationResult result = await botClient.Conversation(message, botConnectorKey);

            if (result.botActivities != null)
            {
                foreach (Activities activities in result.botActivities.activities.Where(item => item.from.id == botFrom))
                {
                    replyMessages = activities.text;
                }
            }
            return(replyMessages);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 开始测试
        /// </summary>
        /// <param name="botClient"></param>
        /// <param name="inputText"></param>
        /// <param name="botFrom"></param>
        /// <param name="botConnectorKey"></param>
        public static async void Start(BotClient botClient, string inputText, string botFrom, string botConnectorKey)
        {
            Console.WriteLine("正在通信,请稍等...");

            ConversationResult result = await botClient.Conversation(inputText, botConnectorKey);

            if (result.resultMessage != null)
            {
                Console.WriteLine(result.resultMessage);
            }

            if (result.botActivities != null)
            {
                foreach (Activities activities in result.botActivities.activities.Where(item => item.from.id == botFrom))
                {
                    Console.WriteLine();
                    Console.WriteLine("贩卖机Bot:" + activities.text);
                }

                Console.WriteLine();
                Console.Write("请输入:");
            }
        }