axa-group / nlp.js

An NLP library for building bots, with entity extraction, sentiment analysis, automatic language identify, and so more
MIT License
6.3k stars 622 forks source link

Emulator Directline Html Tags #1245

Open SemenKrupin opened 1 year ago

SemenKrupin commented 1 year ago

Hello! Using the emulator in Directline, how can you pass not just text, but text in Html format so that Html elements are drawn in the chat window? image

I looked at the documentation, but did not understand whether it is possible to operate with such Html components as Button, Div, Table, etc.

ericzon commented 1 year ago

Hello @SemenKrupin , we use a webchat client developed by Microsoft. This client can render plain text, adaptive cards and can also show some markdown features. Please, take a look to these links.

SemenKrupin commented 1 year ago

Hello @SemenKrupin , we use a webchat client developed by Microsoft. This client can render plain text, adaptive cards and can also show some markdown features. Please, take a look to these links.

Thank you very much for the information. Tell me, please, how can I apply the Adaptive Card schema with NLP.js? In the documentation, it is indicated that you need to place an object in the response

{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "type": "AdaptiveCard",
  "version": "1.0",
  body: [
    {
      "type": "container",
      "items": [
...

And how to form a response and send it to NLP.js?

aigloss commented 1 year ago

Hi @SemenKrupin ,

bot orchestration is able to send cards using the 'card' command. You can check its executeAction method to figure out how this card thing works. Note that, in the bot's use case, it's loading cards from files like:


{
        "name": "cardOptionsTemplate",
        "type": "message",
        "attachments": [
                {
                        "contentType": "application/vnd.microsoft.card.adaptive",
                        "content": {
                                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
                                "type": "AdaptiveCard",
                                "id": "booleanAnswer",
                                "version": "1.0",
                                "speak": "{{ cardMsg }}",
                                "body": [
                                        {
                                                "type": "TextBlock",
                                                "text": "{{ cardMsg }}",
                                                "size": "Medium",
                                                "wrap": true
                                        }
                                ],
                                "actions": []
                        }
                }
        ]
}