I am trying to create an adaptive card for an elastic alert. The payload I receive for the card kind of looks like the following json:
{
"hits": {
"max_score": null,
"hits": [
{
"fields": {
"log.#m":
"some log message"
,
"kubernetes.node.name": [
"node name"
],
"log.#l": [
"Error"
]
}
}
]
}
}
I, however, have some problems getting the fields into a TextBlock because of the dot notation or the .# in the fields names. If I remove them (only possible in the adaptive card designer with the sample data editor) I can display the data just fine. It is not possible to change the property names since this is an Elastic thing.
I tried a lot of possibilities for the text field.
through the UI editor
using [] brackets
using single quotes
combinations of the above...
{
"type": "Container",
"items": [
{
"$when": "${$index < 2}",
"type": "TextBlock",
"text": "${log.m}",
"$data": "${fields}"
}
],
"$data": "${$root.hits.hits}"
}
Does anyone have an idea how I could go about displaying the fields in a textblock?
Related
I'm using contentful. Authors are using a rich text editor for this portion. For my purpose, i just want to be able to take out the text from the rich text editor (but still use the same JSON for other things, so i don't want to get rid of it either), how do i do so?
Currently, the JSON looks like this. What is the most effective way to just get "This text is important".
All i've gotten is to do something similar to the below, but it is inefficient and wordy especially when a post gets really big and complicated.
content[0].content[0].map((content) => content.value)
{
"nodeType": "document",
"data": {},
"content": [
{
"nodeType": "paragraph", // Can be paragraphs, images, lists, embedded entries
"data": {},
"content": [
{
"nodeType": "text",
"value": "This text is ",
"data": {},
"marks": []
},
{
"nodeType": "text",
"value": "important",
"data": {},
"marks": [
"type": "bold" // Can be bold, underline, italicss
]
}
]
}
]
}
The best approach is to use Contentful's provided rich-text-plain-text-renderer package.
If you want to implement it yourself, the source code is well documented and basically a recursive function calling itself until it reaches all the document leafs.
How do we send a formatted text like italicized text to the Dialog Flow Messenger using the Custom Payload
when we try the following Custom Payload, it does not format the text properly,
{
"richContent": [
[
{
"type": "description",
"title": "Description title",
"text": [
"This is text line 1.",
"<I>This is text line 2.</I>"
]
}
]
]
}
Thanks in advance!
It might be not formatting correctly because you are using a different JSON formatting for a custom payload, your JSON format should look something like this:
{
"facebook": {
"attachment": {
"type": "",
"payload": {}
}
},
"slack": {
"text": "",
"attachments": []
}
}
You can read more about rich responses and custom payloads in this documentation that Google provides.
Edit: To italicize text, add one asterisk or underscore before and after a word or phrase
{
"richContent": [
[
{
"type": "description",
"title": "Description title",
"text": [
"This is text line 1.",
"_This is text line 2._"
]
}
]
]
}
I have a slack bot that uses a menu drop down, and it has a color bar on the side.
See the screenshot of what I have
here in the green circle
I want the bar to extend the whole message like this image
Note: This image is edited to show the example of the red bar (and because the actual slack bot message isn't important)
My code has something like
let slackPost = {
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": myText
}
} // ... some other blocks
],
"attachments": [
{
"text": menuTitle,
"color": menuBarColor,
"attachment_type": "default",
"actions": [
{
"name": menuName,
"text": menuPlaceHolder,
"type": "select",
"options": menuOptions
}
]
}
]
}
The new slack blocks layout doesn't allow the old color attachments property. You can find official documentation here.
There is one exception, and that's the color parameter, which currently does not have a block alternative. If you are strongly attached (🎺) to the color bar, use the blocks parameter within an attachment.
You can nest blocks inside the attachment property, like this:
let slackPost = {
"attachments": [{
"color": message.color,
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": myText
}
} // ... some other blocks
]
}]
Good morning!
I am starting with BotFramework Composer tool using the template RespondingWithCardsSample and I am having problems testing the send of value from one card to another.
On the one hand, I have edited the AdaptivecardJson card with the following basic code.
#adaptivecardjson
- ```
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0",
"type": "AdaptiveCard",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "Input.ChoiceSet",
"placeholder": "Adults",
"choices": [
{
"title": "1",
"value": "1"
},
{
"title": "2",
"value": "2"
},
{
"title": "3",
"value": "3"
},
{
"title": "4",
"value": "4"
}
],
"id": "InputAdultos"
}
]
}
]
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Send"
}
]
}
This card simply contains an input text indicating the number of adults, the send button and inflates the following card:
#AdaptiveCard
[Activity
Attachments = #{json(adaptivecardjson())}
]
Finally, I created another card which simply writes the number of adults received:
# HeroCardAdults(InputAdults)
[HeroCard
text = The number of adults is #{InputAdults}
]
But I just didn't understand how it works and it gives me the following error:
common.lg: Error occurs when evaluating expression bfdactivity-028800 (): Error occurs when evaluating expression HeroCardAdults (): Specified argument was out of the range of valid values.
Parameter name: ‘inputadults’ does not match memory scopes: user, conversation, turn, settings, dialog, class, this
Has it happened to someone else?
Thanks!
Change your template to
# HeroCardAdults(InputAdults)
[HeroCard
text = The number of adults is {InputAdults}
]
or if you want to use memory scopes, set your value to dialog.InputAdults and use this template
# HeroCardAdults
[HeroCard
text = The number of adults is {dialog.InputAdults}
]
I am developing an web app using Codeigniter and MongoDB. Users can save their favorites sounds in as "bookmarks". Each user get one document and then each sound is appended to an array in that document called sounds. Each sound got a set of tags that is also saved to the bookmark. How can I search a users bookmarks in their bookmark document? I want them to be able to search by tags (from the tag array).
This is my MongoDB document:
{
"_id": ObjectId("4f15846a112bf6b725000000"),
"owner": {
"user_id": ObjectId("4f147e1709ab662061000000"),
"session_id": "3424e3155a01e78c50a8498f78cc51d9"
},
"sound_files": [
{
"sound_id": ObjectId("4f1480ff09ab661a61000001"),
"sound_url": "http://s3.amazonaws.com/4c/864ea8e92e6ec4408e248cc9brf008bd/18.wav",
"sound_tags": [
"sound",
"new york",
"cool"
]
},
{
"sound_id": ObjectId("4f1480ff09ab661a61000001"),
"sound_url": "http://s3.amazonaws.com/4c/864ea8e92e6ec4408e248cc9brf008bd/12.wav",
"sound_tags": [
"sound",
"happy",
"ocean"
]
}
],
"total": 1
}
db.col.find({'sound_files.sound_tags':"sound"})
EDIT: Not exactly what OP is looking for apparently. Waiting for a more precise description of the requirement.