Pass callback_id without attachments in Slack - callback

I'm using Slack Api to send message.
So, I have this block message:
{
"blocks": [
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Do you have access ?"
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Yes"
},
"style": "primary",
"value": "click_me_123"
},
{
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Skip"
},
"style": "danger",
"value": "click_me_123"
}
]
}
]
}
As you see, this is block message and it have no any attachments. So, it doesn't send any callback_id when click button Yes or No. But I need send callback_id when click button Yes or No. How can do that?
Or another hack. Anyway to remove border left of attachments?
Thanks.

Am assuming you are looking to have a way to let your code parse the choices when the button is pressed. You need to assign the unique value that you can parse and determine the choice. Something like
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Yes"
},
"style": "primary",
"value": "yes"
},
{
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Skip"
},
"style": "danger",
"value": "skip"
}
]
}

Related

Sending WhatsApp interactive message of list type fails when sent with image header

I am able to send interactive message with "button" type and 3 buttons with image header.
But sending interactive message with "list" type and same image header fails with error:
{
"meta": {
"api_status": "stable",
"version": "2.39.4"
},
"errors": [
{
"code": 1008,
"title": "Required parameter is missing",
"details": "Failed building interactive message. Invalid Header."
}
]
}
Is it possible that "list" interactive messages doesn't support "image" header without stating it in documentation?
Successful "button" interactive payload (image URL changed):
{
"to": "972000000000",
"type": "interactive",
"interactive": {
"body": {
"text": "Select a branch for the takeaway by writing the name/number"
},
"action": {
"buttons": [
{
"reply": {
"id": "MQ==",
"title": "1"
},
"type": "reply"
},
{
"reply": {
"id": "Mg==",
"title": "2"
},
"type": "reply"
}
]
},
"type": "button",
"header": {
"image": {
"link": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_light_color_272x92dp.png"
},
"type": "image"
}
}
}
Successful "button" interactive message result:
Failed "list" interactive payload (image URL changed):
{
"to": "972000000000",
"type": "interactive",
"interactive": {
"body": {
"text": "Select a branch for the takeaway by writing the name/number"
},
"action": {
"button": "Options",
"sections": [
{
"rows": [
{
"id": "MQ==",
"title": "1"
},
{
"id": "Mg==",
"title": "2"
},
{
"id": "Mw==",
"title": "3"
},
{
"id": "NA==",
"title": "4"
},
{
"id": "NQ==",
"title": "5"
},
{
"id": "Ng==",
"title": "6"
},
{
"id": "Nw==",
"title": "7"
},
{
"id": "OA==",
"title": "8"
},
{
"id": "OQ==",
"title": "9"
},
{
"id": "MTA=",
"title": "10"
}
]
}
]
},
"type": "list",
"header": {
"image": {
"link": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_light_color_272x92dp.png"
},
"type": "image"
}
}
}
Well, it does state it in the docs. I'm just blind:
Kinda weird though "image" header not supported for "list".

Why does Adaptive Card Input.Date subtract 1 day from the selected date?

Using botframework with msteams channel.
The adaptive card. Nothing special, just a few textblocks and date inputs. The input values are saved to memory.
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.3",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"style": "emphasis",
"width": 2,
"items": [
{
"type": "TextBlock",
"text": "Please enter the information below",
"size": "Large"
},
{
"type": "Container",
"style": "emphasis",
"items": [
{
"type": "TextBlock",
"text": "End Of Last Month",
"wrap": true
},
{
"type": "Input.Date",
"id": "Date_EndOfLastMonth",
"value": "${dialog.requestForm.Date_EndOfLastMonth}",
"placeholder": ""
},
{
"type": "TextBlock",
"text": "${dialog.requestForm.Date_EndOfLastMonthError}",
"size": "small",
"wrap": true,
"color": "attention"
}
]
},
{
"type": "Container",
"style": "emphasis",
"items": [
{
"type": "TextBlock",
"text": "End Of Last Year",
"wrap": true
},
{
"type": "Input.Date",
"id": "Date_EndOfLastYear",
"value": "${dialog.requestForm.Date_EndOfLastYear}",
"placeholder": ""
},
{
"type": "TextBlock",
"text": "${dialog.requestForm.Date_EndOfLastYearError}",
"size": "small",
"wrap": true,
"color": "attention"
}
]
},
{
"type": "Container",
"style": "emphasis",
"items": [
{
"type": "TextBlock",
"text": "Valuation Key Date",
"wrap": true
},
{
"type": "Input.Date",
"id": "ValuationKeyDate",
"value": "${dialog.requestForm.ValuationKeyDate}",
"placeholder": ""
},
{
"type": "TextBlock",
"text": "${dialog.requestForm.ValuationKeyDateError}",
"size": "small",
"wrap": true,
"color": "attention"
}
]
},
{
"type": "Container",
"style": "emphasis",
"items": [
{
"type": "ActionSet",
"actions": [
{
"type": "Action.Submit",
"title": "Submit",
"data": {
"msteams": {
"type": "messageBack",
"displayText": "Form Submitted",
"text": "submitform"
}
}
}
]
}
]
}
]
}
]
}
]
}
The code that goes with the card. I save the input values to memory, so when there is a reprompt happening, I can fill them back to the form. In the last part are the lines for debugging. I am printing out the values directly from the activity, so nothing happens between the submission and the debug.
new CodeAction(async (dc, options) =>
{
dc.State.SetValue("dialog.requestForm.Date_EndOfLastMonth", "");
dc.State.SetValue("dialog.requestForm.Date_EndOfLastYear", "");
dc.State.SetValue("dialog.requestForm.ValuationKeyDate", ""); //ValuationKeyDate
dc.State.SetValue("dialog.requestForm.Date_EndOfLastMonthError", "");
dc.State.SetValue("dialog.requestForm.Date_EndOfLastYearError", "");
dc.State.SetValue("dialog.requestForm.ValuationKeyDateError", "");
return await dc.EndDialogAsync();
}),
new TextInput()
{
Id = "repromptTRT",
Prompt = new ActivityTemplate("${TreasuryCase()}"),
AllowInterruptions = true,
MaxTurnCount = "if(turn.activity.text != 'submitform', '0', '100')",
},
// deal with interrupt, cancel everything else
new IfCondition()
{
Condition = "turn.activity.text != 'submitform'",
Actions = new List<Dialog>()
{
new EndDialog()
}
},
// save form
new CodeAction(async (dc, options) =>
{
var json = JsonConvert.SerializeObject(dc.Context.Activity.Value);
await dc.Context.SendActivityAsync(MessageFactory.Text(json));
var d = JsonConvert.SerializeObject(DateTime.Now);
await dc.Context.SendActivityAsync(MessageFactory.Text(d));
var o = JsonConvert.DeserializeObject<TC>(json);
dc.State.SetValue("dialog.requestForm", o);
return await dc.EndDialogAsync();
}),
For more visibility, adding answer here from comment section:
The fix should be rolling through the rings, so the change should manifest in public clients in a couple of weeks.

Get Google Assistant Action to respond to "Quit" or "Cancel"

I've tried to follow the documentation about App Exit handling, but it doesn't seem to be working correctly. (See the screen shot of my Intent below).
When I do it this way, it seems to resort to my Default Fallback Intent, although it does indicate that the resolvedQuery is actions_intent_CANCEL, which should be correct. (See the JSON body below.)
Am I doing something wrong, or is the documentation wrong?
Intent trying to handle it:
JSON Body:
{
"originalRequest": {
"source": "google",
"version": "2",
"data": {
"isInSandbox": true,
"surface": {
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
}
]
},
"inputs": [
{
"rawInputs": [
{}
],
"intent": "actions.intent.CANCEL"
}
],
"user": {
"locale": "en-US",
"userId": "AETml1QP6omTPEXBfrOBdvNlwHxY"
},
"conversation": {
"conversationId": "1509314271837",
"type": "ACTIVE",
"conversationToken": "[]"
},
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
}
]
}
]
}
},
"id": "bbd363aa-f555-4543-a748-294751194fa9",
"timestamp": "2017-10-29T21:58:00.691Z",
"lang": "en-us",
"result": {
"source": "agent",
"resolvedQuery": "actions_intent_CANCEL",
"speech": "",
"action": "input.unknown",
"actionIncomplete": false,
"parameters": {},
"contexts": [
{
"name": "actions_intent_cancel",
"parameters": {},
"lifespan": 0
},
{
"name": "actions_capability_screen_output",
"parameters": {},
"lifespan": 0
},
{
"name": "actions_capability_audio_output",
"parameters": {},
"lifespan": 0
}
],
"metadata": {
"intentId": "25f6e14b-a92c-479b-8943-76c4b6914579",
"webhookUsed": "true",
"webhookForSlotFillingUsed": "false",
"nluResponseTime": 2,
"intentName": "Default Fallback Intent"
},
"fulfillment": {
"speech": "I'm sorry. I didn't quite grasp what you just said.",
"messages": [
{
"type": 0,
"id": "535c3b80-f13d-4b61-8c1d-bb58fa3f5e44",
"speech": "I'm a bit confused by that last part."
}
]
},
"score": 1
},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": "1509314271837"
}
In addition to the steps in the documentation, I found that I had to tell the simulator to update to the most recent version!
Here is my video outlining the steps I took.
https://www.youtube.com/watch?v=ZvZDokjhUIY
Although this isn't what the documentation suggests, I've found a workaround that seems to be correct.
Since there doesn't seem to be any spoken input registered, it looks like it would make sense for a Fallback Intent. Since Fallback Intents other than the default one require a Context, and not just an Event, and it looks like the actions_intent_cancel context is created, it seems reasonable to use it.
A Fallback Intent for this might look something like this:

Gupshup consume post to create Embedding form

im working with Gupshup and I want to add subview in my chat.
To make this I create this vars:
var url="https://api.gupshup.io/sm/api/facebook/smartmsg/form/create";
var header = {"apikey":"xxxxxxxxxxxxxxxxxxx","Content-Type": "application/x-www-form-urlencoded","Accept":"application/json"};
var param={"formJSON":{
"title": "This is a test.",
"autoClose": false,
"message": "Thank You",
"callback-url": "https://www.gupshup.io/developer/bot/Cotizador/public",
"fields": [{
"type": "fbid",
"name": "fbname",
"label": "fbName"
}, {
"type": "input",
"name": "name",
"label": "Name",
"validations": [{
"regex": "^[A-Z a-z]+$",
"msg": "Only alphabets are allowed in this field"
}, {
"regex": "^[A-Z a-z]{6,}$",
"msg": "Minimum 6 characters required"
}]
}, {
"type": "radio",
"name": "gender",
"label": "Gender",
"options": [
"Male",
"Female"
],
"validations": [{
"regex": "",
"msg": ""
}]
}, {
"type": "select",
"name": "account",
"label": "AccountType",
"options": [
"current",
"savings"
],
"validations": [{
"regex": "",
"msg": ""
}]
}, {
"type": "checkbox",
"name": "interest",
"label": "Interests",
"options": [
"Cooking",
"Reading"
],
"validations": [{
"regex": "",
"msg": ""
}]
}],
"users": [
"Testing"
]
}}
And call post with:
context.simplehttp.makePost(url,JSON.stringify(param),header,parser);
And my call back
function parser(context, event) {
context.console.log("Handler https")
var result= JSON.parse(event.getresp);
if(result=="success"){
context.sendResponse("We have successfully stored your data");
}else{
context.sendResponse("We dont shoot");
}
}
But when, make the request post, but don't show me response in chat or in callback. What im doing wrong?
Sohan from Gupshup here.
The result from the API that you are using is this:
[{
"embedlink": "https://api.gupshup.io/sm/api/facebook/smartmsg/embed/66438dde-ec76-4d6e-a0d0-8cfc0c730e57",
"expired": false,
"fb-button": {
"title": "This is a test.",
"type": "web_url",
"url": "https://api.gupshup.io/sm/api/facebook/smartmsg/embed/66438dde-ec76-4d6e-a0d0-8cfc0c730e57",
"webview_height_ratio": "tall"
},
"id": "66438dde-ec76-4d6e-a0d0-8cfc0c730e57",
"signed-for": {
"display": "Testing",
"subdisplay": "Testing"
},
"smid": "1009"
}]
Thus when you do:
var result= JSON.parse(event.getresp);
if(result=="success"){
context.sendResponse(result) will display the entire JSON that you see above. To display the 'expired' field you can use result.expired.
Check this document for more information.

I need receive the messages created in response texts in some intentions of the API.AI

My issue:
I have two responses, but my chat return only one specified "the speech", but i need that return the two, like do the console of api
example of response JSON from API:
{
"id": "XXXXXXXXXXX",
"timestamp": "2017-07-12T20:08:48.101Z",
"lang": "es",
"result": {
"source": "agent",
"resolvedQuery": "Hello how are you?",
"action": "",
"actionIncomplete": false,
"parameters": {},
"contexts": [
{
"name": "intent",
"parameters": {},
"lifespan": 1
}
],
"metadata": {
"intentId": "XXXXXXXXXXXXXXXXXXXXXXXX",
"webhookUsed": "false",
"webhookForSlotFillingUsed": "false",
"intentName": "welcome"
},
"fulfillment": {
"speech": "Hello!",
"messages": [
{
"type": 0,
"speech": "Hello!"
},
{
"type": 0,
"speech": "Bye!"
}
]
},
"score": 1
},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": ""
}
I need show the black messages.