DialogFlow Messenger Formatted Text using Custom Payload - dialogflow-cx

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._"
]
}
]
]
}

Related

How to display text coming from property with special character - adaptive cards

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?

I would like to use Blocks instead of Attachments in my Slack App but the app fails to return the message

I recently made my first Slack app - a sort of Tech Support FAQs tool for my workplace workspace.
I originally wanted the responses to be much more complex using the Slack Block Kit, and having trawled the documentation on the Slack API site it looked like I could simply exchange Attachments for Blocks:
function respondWithFaq(text, callbackId, respond, choice) {
frequentlyAskedQuestions.callback_id = callbackId
frequentlyAskedQuestions.text = 'What are you trying to do?'
respond({
text: text,
attachments: [frequentlyAskedQuestions[choice]], //All different choices are saved in a .json array and then saved at the top in a variable called frequentlyAskedQuestions
replace_original: true
})
}
However, when I swap that tag out the messages never print. I have used the Block Kit builder to try and construct more complex and useful responses using multiple sections but it doesn't seem to like more than 1 section in it's responses.
My .json files are structured in arrays depending on which choice was made in the previous select menu like so:
[
{
"fallback": "Upgrade your Slack client to use messages like these.",
"color": "#3AA3E3",
"attachment_type": "default",
"callback_id" : "slack_help",
"actions": [
{
"name": "subject_list",
"text": "Select one",
"type": "select",
"options": [
{
"text": "Add somebody to a channel",
"value": "addToChannel"
},
{
"text": "Find an old message",
"value": "oldMessageThread"
},
{
"text": "Fix my camera",
"value": "cameraBroken"
},
{
"text": "Fix my audio",
"value": "audioBroken"
},
{
"text": "Add a new workspace",
"value": "addWorkspace"
},
{
"text": "Submit a support ticket",
"value": "submitTicket"
}
]
}
]
},
{
"fallback": "Upgrade your Slack client to use messages like these.",
"color": "#3AA3E3",
"attachment_type": "default",
"callback_id" : "box_help",
"actions": [
{
"name": "subject_list",
"text": "Select one",
"type": "select",
"options": [
{
"text": "Fix Box Tools",
"value": "boxTools"
},
{
"text": "Unable to open a file from Box",
"value": "microsoftOnline"
},
{
"text": "Find a file or folder",
"value": "findFile"
},
{
"text": "Edit a file that has been shared with me",
"value": "editFile"
},
{
"text": "Merge my Box accounts",
"value": "accountMerge"
},
{
"text": "Submit a support ticket",
"value": "submitTicket"
}
]
}
]
},
and so on...
I wondered if this was something to do with the Response URL formatting but having read that documentation it appears that Blocks can be used within that.
Any advice or documentation that could help me with this?
I recognise that I am quite new to coding and perhaps I've done something really obvious - please point it out so I can learn!
I followed this tutorial online to create the app, and as they used attachments so did I. Then I tried to adapt from there.

Extend slack bot menu color bar across full message (node, slack block kit, slack api)

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
]
}]

Sending values between cards with BotFramework Composer

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}
]

Microsoft Botframework encode image bytes into message cards

I am using the Bot framework to create a chat bot. And I want to create message card (Hero or Thumbnail).
If you look at the skype bot api doc, there is a way to encode image bytes directly as the content url. https://docs.botframework.com/en-us/skype/chat/
"type": "message/image",
"attachments": [
{
"contentUrl": "<base64 encoded image>",
"thumbnailUrl": "<base64 encoded thumbnail>", // optional
"filename": "bear.jpg" // optional
}
]
This works fine for showing an image only. But I want the image to be part of a card.
The card is
{
"type":"message/card.carousel",
"attachments":[
{
"contentType":"application/vnd.microsoft.card.hero",
"content":{
"images":[
{
"image":"https://foo.com/path/image.jpg",
}
I have tried to set the image url property to the encoded bytes, but the client can't show it. What's the best way to achieve this?
You've got the basic idea. Use this instead:
"attachments": [
{
"contentType": "application/vnd.microsoft.card.hero",
"content": {
"title": "Title",
"subtitle": "SubTitle",
"text": "Text",
"images": [
{
"url": "image/jpeg;base64,{YOUR IMAGE}",
"alt": "Alt Image Description"
}
]
}
}
],

Resources