ChatBot在Web模拟器中不起作用,但在Local Bot Framework模拟器中则很好]]

问题描述 投票:1回答:1

[目前,我已经开发了与SharePoint Inmise集成的ChatBot。

当我在模拟器中调试ChatBot时,它的工作。

但是当我使用DirectLine在Azure中的Web Emulator和公司网站中托管的网站上调试时,它不起作用。

有人知道如何解决吗?

这里是我的屏幕截图。左侧来自Web模拟器,右侧来自本地Bot Framework模拟器enter image description here

使用源代码更新(2019年12月12日)

 try
                    {
                        string spurl = @"https://mvponduty.sharepoint.com/_layouts/15/srchrss.aspx?k=*%20ListId:7BC0F2C3-6366-48B8-B88A-8738BE1F9C31";
                        XmlSecureResolver resolver = new XmlSecureResolver(new XmlUrlResolver(), spurl);
                        resolver.Credentials = new NetworkCredential("[email protected]", "Pa$$w0rd", "mvponduty.onnmicrosoft.com"); 

                        XmlReaderSettings settings = new XmlReaderSettings();
                        settings.DtdProcessing = DtdProcessing.Parse;
                        settings.ValidationType = ValidationType.DTD;

                        settings.XmlResolver = resolver;

                        XmlReader reader = XmlReader.Create(spurl, settings);
                        SyndicationFeed feed = SyndicationFeed.Load(reader);

                        reader.Close();

                        var attachments = new List<Attachment>();
                        foreach (SyndicationItem item in feed.Items)
                        {
                            //Get Title,Description,URL
                            String title = item.Title.Text;
                            String description = item.Summary.Text;
                            String link = item.Links.FirstOrDefault().Uri.ToString();

                            //Hero Card
                            var heroCard = new HeroCard(
                                title: item.Title.Text,

                                buttons: new CardAction[]
                                {
                        new CardAction(ActionTypes.OpenUrl,"Learn More",value:link)
                                }
                                ).ToAttachment();
                            attachments.Add(heroCard);

                        }
                        var reply = MessageFactory.Carousel(attachments);
                        await turnContext.SendActivityAsync(reply);
                        await ProcessCosmoDBStorageLUISAsync(turnContext,questionluis,intent, entityfound, respString, cancellationToken);
                    }
                    catch (Exception ex)
                    {
                        await turnContext.SendActivityAsync(ex.ToString());
                    }

我的HTML页面(2019年12月12日)

<body>

    <div id="webchat" role="main"></div>

    <script>

        (async function () {
            const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
                if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
                    // When we receive DIRECT_LINE/CONNECT_FULFILLED action, we will send an event activity using WEB_CHAT/SEND_EVENT
                    dispatch({
                        type: 'WEB_CHAT/SEND_EVENT',
                        payload: {
                            name: 'webchat/join',
                            value: { language: window.navigator.language }
                        }
                    });
                }
                return next(action);
            });

            const styleOptions = {
                //bubbleBackground: 'rgba(0, 0, 255, .1)',
                //bubbleFromUserBackground: 'rgba(0, 255, 0, .1)',
                botAvatarImage:
                    'https://docs.microsoft.com/en-us/azure/bot-service/v4sdk/media/logo_bot.svg?view=azure-bot-service-4.0',
                botAvatarInitials: 'BF',
                userAvatarImage: 'https://avatars1.githubusercontent.com/u/2833325?s=460&v=4',
                userAvatarInitials: 'WC'
            };


      window.WebChat.renderWebChat({
          directLine: window.WebChat.createDirectLine({ secret: 'DirectLineToken'}),
          styleOptions,
          store
      }, document.getElementById('webchat'));

        })().catch(err => console.log(err));


    </script>
</body>

几周前,我感到沮丧,目前,我已经开发了与SharePoint On Premise集成的ChatBot。当我在模拟器中调试ChatBot时,它的工作正常。但是当我在Web上调试时...

botframework sharepoint-2013 azure-bot-service
1个回答
0
投票

ChatBot似乎工作正常?它正在发送和接收消息。在本地运行和托管时,您拥有的某些代码的行为有所不同。有Xml,是文件还是生成的?您需要检查它是否与在本地运行时遵循相同的逻辑并使用相同的数据。也许如果您将某些(非机密)代码粘贴到崩溃的位置,我们可以提供更多帮助的想法

© www.soinside.com 2019 - 2024. All rights reserved.