Dialogflow - Calling an intent on a button click - json

I have two buttons ('Category A' and 'Category B') created through custom payload in the 'Dialogflow Messenger' Integration. Once I click any category I want another intent to be triggered which would show the user few other buttons (sub-categories). I tried putting the welcome event name in the event section of the the code but that did not work for me (there were no changes at all). Could someone help me with this please?
I also do not know how to create new events. (I could not understand much from the 'events' documentation.) The style section does not work too. I want to change the layout of the buttons too. I do not have the knowledge of web-hook and fulfillment too.
"richContent": [
[
{
"icon": {
"color": "#FF9800",
"type": "chevron_right"
},
"event": {
"languageCode": "",
"name": "WELCOME",
"parameters": {}
},
"link": "https://google.com",
"text": "Career",
"type": "button",
"style": {
"background-color": "blue"
}
},
{
"type": "divider"
},
{
"icon": {
"type": "chevron_right",
"color": "#FF9800"
},
"link": "https://google.com",
"text": "Sales Inquiry",
"event": {
"languageCode": "",
"name": "",
"parameters": {}
},
"type": "button"
}
]
]
} ```

You need to enter language code as well.
"event": {
"languageCode": "en",
"name": "login-event",
"parameters": {}
}

I got this method worked for me.
Create intent and indicate matched event name on your button payload to event name created in intent.
"event": {
"name": "event_name_you_indicate",
},
In the same intent, provide action name.
Map your function once action name request received.
TLDR; You can check if this works out for you: https://medium.com/#varungoyal311213/dialogflow-rich-responses-click-event-438b984466ec

Related

Is is possible to make any element other than ActionSet clickable in Actionable message

I know in Microsoft's ActionableMessage, one can have ActionSet which is clickable and you can have it open an URL.
But designs I am working with calls for something like this:
| Some Text. [Icon] |
Is there a way I can define AdaptiveColumn/AdaptiveColumnSet clickable UI element, such that one can open url?
I have found a kind of "hackable" way, where I have created a background with just icon.
Then I set the text in a column and set text value as Some Text
That "kind-of" works but now user has to click on that text. Click on the entire element doesn't work!!
There are many elements you can make clickable, check this here as an example:
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5",
"body": [
{
"type": "TextBlock",
"text": "Clicking this opens google",
"size": "Medium",
"weight": "Bolder",
"id": "googleButton"
},
{
"type": "Image",
"id": "Image",
"url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTK2nG24AYDm6FOEC7jIfgubO96GbRso2Xshu1f8abSYQ&s",
"selectAction": {
"type": "Action.OpenUrl",
"url": "https://www.google.de"
}
},
{
"type": "Container",
"selectAction": {
"type": "Action.OpenUrl",
"url": "https://www.google.de"
},
"items": [
{
"type": "TextBlock",
"text": "New TextBlock",
"wrap": true,
"selectAction": {
"type": "Action.OpenUrl",
"url": "https://www.google.de"
}
}
]
}
]}
Many elements such as container, image etc have the "selectAction" property where you can define an onClick action

Bot framework user selected button text is not displaying in bot

I am developing Microsoft teams bot using ms bot framework. In that, i am using adaptive cards for displaying description and two buttons.
when user clicks the button, that time i need pass json data to backend. If I pass string data ("data": "ONE") on button action then I can able to read the arguments in backend and user clicked button text is coming in bot. Kindly see the code and output image below
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Hi, this is your Botzer personal assistant , how can I help you? Click Here ",
"weight": "bolder",
"isSubtle": false,
"wrap": true
}
],
"actions": [
{
"type": "Action.Submit",
"title": "ONE",
"data": "ONE"
},
{
"type": "Action.Submit",
"title": "TWO",
"data": "TWO"
}
]
}
}
But, when I send json data on button action ("data": { "id": "action2", "name": "two", "value": "TWO"}) that time i can read the data in backend. But, button text is not coming on the bot. Kindly see the code and output image below
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Choose the number",
"weight": "bolder",
"isSubtle": false,
"wrap": true
}
],
"actions": [
{
"type": "Action.Submit",
"title": "ONE",
"data": {
"id": "action1",
"name": "one",
"value": "ONE"}
},
{
"type": "Action.Submit",
"title": "TWO",
"data": {
"id": "action2",
"name": "two",
"value": "TWO"}
}
]
}
}
What you want is called a message back, which combines the functionality of string submit actions and object submit actions. Since you don't have any inputs in your Adaptive Card, you can replace it with a hero card and use a messageBack action directly. If you still want to use an Adaptive Card then you're in luck because Teams actually has special functionality that allows you to put a message back in an Adaptive Card. You can see how to do that in the "Adaptive Cards in Teams" section of the blog post Hessel linked to, or you can consult the documentation directly.

How to get a TextBlock Text via Action.Http?

I am trying to get TextBlock Text/Value ("Click Learn More to learn more about Actionable Messages!) in response when clicking Send Feedback.
I tried {{Heading.text}} and {{Heading.value}} with Heading being id of a field.
Adaptive Card
Getting value from Input.Text via {{feedbackText.value}} works just fine.
Sample:
{
"type": "AdaptiveCard",
"version": "1.0",
"hideOriginalBody": true,
"body": [
{
"type": "TextBlock",
"text": "Visit the Outlook Dev Portal",
"size": "Large"
},
{
"type": "TextBlock",
"text": "Click **Learn More** to learn more about Actionable Messages!",
"id": "Heading"
},
{
"type": "Input.Text",
"id": "feedbackText",
"placeholder": "Let us know what you think about Actionable Messages"
}
],
"actions": [
{
"type": "Action.Http",
"title": "Send Feedback",
"method": "POST",
"url": "https://webhook.site/.....",
"body": "{{feedbackText.value}}\n{{Heading.text}}\n{{Heading.value}}"
},
{
"type": "Action.OpenUrl",
"title": "Learn More",
"url": "https://learn.microsoft.com/outlook/actionable-messages"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"}
Thanks for help.
I had the same issue trying to send the value of the textblock in http body. I used the following workaround:
Created an Input.Number field
Set the Initially Visible property to false
When the Adaptive Card is compose, I used logic app/flow to populate the value of the field
The Action.Http was then set to the id.value value of the input box.

template forms in prismic

I'm new to prismic and trying to figure out if this is right tool for what I need. I need to create multiple form templates. I want prismic user to be able to build out the template, which will get loaded into gatsby where each field will get built out as components based on a title, type, action, name.
Title will be the title or label.
type will be the type of form element, ex: input, button, radio action,
if its a button the action it needs to do.
name the name for the form element.
Does prismic seem like a good candidate for this and does anyone know of any examples of how I might go about setting up the prismic end. Most of what Ive seen so far is full pages with just title and images. Not exactly forms.
In their repository I only see these options to create elements am I missing some important ones ?
Title
Rich Text
Image
Content Relationship
Link
Link to Media
Date
Timestamp
color
number
key text
Select
Embed
GeoPoint
Group
How would I go about creating form elements, Is there a way to create custom objects to export? Every time I try to add a new filed or a custom object to the json editor it says. Unrecognized, property it will be ignored.
I'd like to be able to use the group to group a bunch of form elements together even if they are just custom objects that I can pass custom properties to so when I load the group into React I can use the custom properties to build out my components ?? Can anyone set me straight here on if this is possible using prismic.
Thanks!
I can't say if Prismic is the best tool for this particular job, but i think you're overestimating what exactly you need in order to render a html form.
Consider the following custom type. It really only consists of titles, structured texts, a repeatable zone and a select. What you do with that data is completely up to you on the front end.
{
"Main": {
"uid": {
"type": "UID",
"config": {
"label": "Form UID",
"placeholder": "Form UID"
}
},
"form_title": {
"type": "StructuredText",
"config": {
"single": "heading2",
"label": "Form Title",
"placeholder": "Form Title"
}
},
"action_title": {
"type": "StructuredText",
"config": {
"single": "heading2",
"label": "action title",
"placeholder": "Submit form"
}
},
"form_action_description": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "form action description",
"placeholder": "form action description"
}
},
"success_message": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "success message",
"placeholder": "success message"
}
},
"error_message": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "error message",
"placeholder": "error message"
}
},
"submit_button_text": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "submit button text",
"placeholder": "submit"
}
},
"body": {
"type": "Slices",
"fieldset": "Slice zone",
"config": {
"choices": {
"test": {
"type": "Slice",
"fieldset": "Form Section",
"description": "Section of a form",
"icon": "vertical_align_center",
"display": "list",
"non-repeat": {
"form_section_title": {
"type": "StructuredText",
"config": {
"single": "heading1",
"label": "Form Section title",
"placeholder": "Form Section title"
}
},
"form_section_description": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "Form Section Description",
"placeholder": "Form Section Description"
}
}
},
"repeat": {
"label": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "label",
"placeholder": "label"
}
},
"type": {
"type": "Select",
"config": {
"options": [
"text",
"textarea",
"checkbox",
"radio",
"submit"
],
"default_value": "text",
"label": "type"
}
},
"name": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "name",
"placeholder": "name"
}
}
}
}
}
}
}
}
}

Microsoft Teams Webhook Generating 400 for Adaptive Card

I have a functioning webhook to a Teams channel to which I can successfully post messages. I am now trying to post an adaptive card to the webhook. Using Postman and performing a Post to https://outlook.office.com/webhook/xyz, with Content-Type set to application/json in the header and the following adaptive card set in the body.
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"speak": "Nothing to say.",
"body": [
{
"type": "TextBlock",
"text": "Hello Teams' user"
}
]
}
With this I receive a HTTP 400 Bad Request and Summary or Text is required message. Does anyone know if Teams webhooks support Adaptive Cards yet or if this is an unsupported task currently?
The answer below is now deprecated. Please refer to this answer and this answer.
Webhooks do not yet support Adaptive Cards! We plan to add support for Adaptive Cards shortly after we release them for bots.
I'm using axios to send an Adaptive Card to a Teams Connector and I was getting this same error. In my case, I was able to resolve the issue by wrapping the card as an "attachment" to the message protocol shown in this link (syntax copied here for reference).
https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL#send-adaptive-cards-using-an-incoming-webhook
{
"type":"message",
"attachments":[
{
"contentType":"application/vnd.microsoft.card.adaptive",
"contentUrl":null,
"content":{
"$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
"type":"AdaptiveCard",
"version":"1.4",
"body":[
{
"type": "TextBlock",
"text": "For Samples and Templates, see [https://adaptivecards.io/samples](https://adaptivecards.io/samples)"
}
]
}
}
]
}
By sending the above JSON as the request body (data argument for axios), I successfully got the Adaptive Card to show up in my Teams Channel.
As you can see, the value of "content" is the Adaptive Card structure. The Adaptive Card follows the documented syntax, found here:
https://learn.microsoft.com/en-us/adaptive-cards/authoring-cards/getting-started
https://learn.microsoft.com/en-us/answers/questions/400502/adaptive-cards-with-incoming-webhooks-in-microsoft.html
But ultimately, I found it easier to work with this "Designer" https://www.adaptivecards.io/designer/
which provides a WYSIWYG interface.
I am sending the request to a Connector that I created in Teams by following the instructions found here:
https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook#create-incoming-webhook-1
And now it responds with 200 OK and shows up in the Channel!
For simple use cases POST this to the webhook url:
{
"title": "Action News",
"text": "not **much** happend (markdown)"
}
For advanced use cases try using MessageCard: https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using
Example:
{
"#type": "MessageCard",
"#context": "http://schema.org/extensions",
"themeColor": "0076D7",
"summary": "Larry Bryant created a new task",
"sections": [{
"activityTitle": "![TestImage](https://47a92947.ngrok.io/Content/Images/default.png)Larry Bryant created a new task",
"activitySubtitle": "On Project Tango",
"activityImage": "https://teamsnodesample.azurewebsites.net/static/img/image5.png",
"facts": [{
"name": "Assigned to",
"value": "Unassigned"
}, {
"name": "Due date",
"value": "Mon May 01 2017 17:07:18 GMT-0700 (Pacific Daylight Time)"
}, {
"name": "Status",
"value": "Not started"
}],
"markdown": true
}],
"potentialAction": [{
"#type": "ActionCard",
"name": "Add a comment",
"inputs": [{
"#type": "TextInput",
"id": "comment",
"isMultiline": false,
"title": "Add a comment here for this task"
}],
"actions": [{
"#type": "HttpPOST",
"name": "Add comment",
"target": "http://..."
}]
}, {
"#type": "ActionCard",
"name": "Set due date",
"inputs": [{
"#type": "DateInput",
"id": "dueDate",
"title": "Enter a due date for this task"
}],
"actions": [{
"#type": "HttpPOST",
"name": "Save",
"target": "http://..."
}]
}, {
"#type": "ActionCard",
"name": "Change status",
"inputs": [{
"#type": "MultichoiceInput",
"id": "list",
"title": "Select a status",
"isMultiSelect": "false",
"choices": [{
"display": "In Progress",
"value": "1"
}, {
"display": "Active",
"value": "2"
}, {
"display": "Closed",
"value": "3"
}]
}],
"actions": [{
"#type": "HttpPOST",
"name": "Save",
"target": "http://..."
}]
}]
}
You can actually send your adaptive card body inside the body array of this structure:
{
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"contentUrl": null,
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.4",
"body": [
]
}
}
]
}
Reference: Microsoft
Recently I was facing the same issue and was looking for a solution. The good part is MS Teams support adaptive cards now
youtube video to explain how it can be implemented
Github link to track the progress on the issue
I managed to send messages to the Teams channel without any failure.