Ext.Net.X.MessageBox' is a 'property' but is used like a 'type' - ext.net

when implementing this code and building the project I got the error someting like this.
Error 3'Ext.Net.X.MessageBox' is a 'property' but is used like a 'type'
am I doing someting wrong?
(I use visual studio,and .net4 framework)
X.Msg.Confirm("Message", "Confirm?", new X.MessageBox.ButtonsConfig
{
Yes = new X.MessageBox.ButtonConfig
{
Handler = "CompanyX.DoYes()",
Text = "Yes Please"
},
No = new X.MessageBox.ButtonConfig
{
Handler = "CompanyX.DoNo()",
Text = "No Thanks"
}
}).Show();

Please use:
X.Msg.Confirm("Message", "Confirm?", new MessageBoxButtonsConfig()
{
Yes = new MessageBoxButtonConfig()
{
Handler = "CompanyX.DoYes()",
Text = "Yes Please"
},
No = new MessageBoxButtonConfig()
{
Handler = "CompanyX.DoNo()",
Text = "No Thanks"
}
}).Show();

Related

Telegraf.js: leave WizardScene with a button

I would put a button after a message in a WizardScene with a "Cancel" Button. But i retrieve some error:
This is my wizard scene:
const superWizard = new WizardScene('super-wizard',
async ctx => {
ctx.wizard.state.data = {};
ctx.telegram.sendMessage(ctx.from.id, "Insert name", {
parse_mode: 'MarkdownV2',
reply_markup: cancelOrder()
})
return ctx.wizard.next();
},
ctx => {
ctx.wizard.state.data.name = ctx.message.text;
ctx.reply("here is your name: "+ctx.wizard.state.data.name);
return ctx.scene.leave();
}
);
const stage = new Stage([superWizard]);
bot.use(session());
bot.use(stage.middleware());
Here is my cancel order function:
function cancelOrder() {
const annullaBtn = Markup.inlineKeyboard([
Markup.callbackButton('CANCEL', `cancelOrder_btn`),
])
return annullaBtn;
}
and the button action:
bot.action("cancelOrder_btn", (ctx) => {
ctx.replyWithMarkdown(`Ordine *ANNULLATO* correttamente`)
return ctx.scene.leave('super-wizard');
});
The program writes correctly the text, and puts the button. But if i press "CANCEL" it gives error at:
ctx.wizard.state.data.name = ctx.message.text;
as "text is undefined" because i press cancel and i didn't write anything.
So how can i leave the scene without going forward, but if i write a text it goes forward in the wizardScene?
Thank you
Replace
ctx.message.text;
with
ctx.update.callback_query.data;
as there is no message returned by callback button

Dynamic JSON in Terraform

I am using Terraform to Invoke a lambda function, and need to pass an input JSON which includes a list of string values.
data "aws_lambda_invocation" "invo6" {
function_name = "my_function"
input = <<JSON
{
"pairs":[
{
"principal":"arn:aws:iam::12345678901:role/myRole",
"databases":[
"my_db_apple", "my_db_banana", "my_db_orange"
]
}
]
}
JSON
}
Instead of hard-coding these database names, I want to pull in from a map that already exists elsewhere in my tf files.
variable "gluedb_map" {
type = map(map(string))
default = {
"apple" = {
description = "my apple db"
catalog = ""
location_uri = "s3://mybucket/"
params = ""
}
"banana" = {
description = "my banana db"
catalog = ""
location_uri = "s3://anotherpath/"
params = ""
}
I tried swapping out the 'databases' code for this :
input = <<JSON
{
"pairs":[
{
"principal":"arn:aws:iam::12345678901:role/myRole",
${jsonencode("databases": [for each in var.gluedb_map : "my_db_${each}"], )}
}
]
}
JSON
but i then get error :
A comma is required to separate each function argument from the next.
Can anyone spot where I'm going wrong ?
Thanks
If you're just interested in accessing the keys of the map then you can use the keys function to return a list of keys. You can then combine that with formatlist to interpolate each list item with a string.
I'd also recommend using a HCL map for the wider data structure and then encoding to JSON rather than trying to JSON encode a section of it and having to mangle things to get it in a suitable shape.
A fully worked example then looks something like this:
variable "gluedb_map" {
type = map(map(string))
default = {
"apple" = {
description = "my apple db"
catalog = ""
location_uri = "s3://mybucket/"
params = ""
}
"banana" = {
description = "my banana db"
catalog = ""
location_uri = "s3://anotherpath/"
params = ""
}
}
}
output "json" {
value = jsonencode({
pairs: [
{
principal = "arn:aws:iam::12345678901:role/myRole"
databases = formatlist("my_db_%s", keys(var.gluedb_map))
}
]
})
}
Applying this will output the following:
json = {"pairs":[{"databases":["my_db_apple","my_db_banana"],"principal":"arn:aws:iam::12345678901:role/myRole"}]}
You can try to use keys, formatlist and join to get:
${jsonencode("databases": [join("," , formatlist("my_db_%s", keys(var.gluedb_map)) )}

microsoft bots to teams using nodejs fails with missing activityid when updating the same activity

My code has a simple card carousel which has action button like below:
actions = [
{
"type": "Action.Submit",
"title": "Qualify",
"data": { "action" : "qualify_lead" }
},
{
"type": "Action.OpenUrl",
"title": "Retire",
"url": "{viewUrl}"
},
{
"type": "Action.ShowCard",
"title": "Add Note",
"card": this.noteCard(item.LeadId, "leads")
}
]
I am having a method to handle qualify_lead action like below
async qualifyLead(context:any){
console.log("in qualifyLead:" + JSON.stringify(context.activity))
await context.updateActivity(this.successCard('Lead is qualified'))
}
All I am doing on purpose is to replace entire carousel with a simple text message. But it fails with error:
Error: BotFrameworkAdapter.updateActivity(): missing activity.id
Where do i get this ?
I am using google firebase for this and the wrapper code is like below
const {
TurnContext,
TeamsActivityHandler,
CardFactory,
AttachmentLayoutTypes,
ActionTypes
} = require('botbuilder');
class TeamsConversationBot extends TeamsActivityHandler {
constructor() {
super();
this.leadState =
this.conversationState.createProperty('leadCarouselState');
this.onMessage(async (context:any, next:any) => {
TurnContext.removeRecipientMention(context.activity);
let msg = context.activity.text
const action = context.activity.value
let objNum = ''
let keyword = ''
if(msg === undefined && action === undefined)
msg = 'help'
else if(msg !== undefined){
msg = msg.trim().toLowerCase()
if(msg.indexOf("help") > -1)
msg = 'help'
else{
if(msg.startsWith('lead')){
msg = 'lead'
}
}
}
switch (msg) {
case 'lead':
await this.lead(context, userKey, platform)
break;
case 'qualify_lead':
await this.qualifyLead(context)
break;
}
await next();
});
}
I'm not sure exactly what this.successCard('Lead is qualified') does, but presumably it returns an Activity. To my knowledge, in order for this Activity to replace another one, you need to set it's Id property to match the previous message. That means that, when you send the previous message (i.e. the card), you need to capture the reference that's returned from the send method on the context (e.g. into bot state), and then use it for this new activity.
As I explained in my answer to your other question, you need to save the activity ID in bot state and then apply it to the update that you're sending. The Bot Framework can't update an activity unless you tell it which activity to update, and you do that using an activity ID.
This was the part that saves the ID:
const dict = await this.carouselState.get(turnContext, {});
dict[batchId] = {
[KEYACTIVITYID]: response.id,
[KEYLEADS]: leads
};
And this was the part that applies it to the updated activity:
const update = this.createCarousel(batchId, leads);
update.id = info[KEYACTIVITYID];

How to set output contexts while creating a intent in dialogflow PHP?

I am trying to set output context to a particular intent via v2 create intent API.
Please check my code.
use Google\Cloud\Dialogflow\V2\SessionsClient;
use Google\Cloud\Dialogflow\V2\TextInput;
use Google\Cloud\Dialogflow\V2\QueryInput;
use Google\Cloud\Dialogflow\V2\IntentsClient;
use Google\Cloud\Dialogflow\V2\Intent_TrainingPhrase_Part;
use Google\Cloud\Dialogflow\V2\Intent_TrainingPhrase;
use Google\Cloud\Dialogflow\V2\Intent_Message_Text;
use Google\Cloud\Dialogflow\V2\Intent_Message;
use Google\Cloud\Dialogflow\V2\Intent;
use Google\Cloud\Dialogflow\V2\Context;
use Google\Cloud\Dialogflow\V2\ContextsClient;
private function intent_create(){
putenv('GOOGLE_APPLICATION_CREDENTIALS='.getcwd() . '/strive_stage.json');
$intentsClient = new IntentsClient();
/** Create Intent **/
$disaplayName = "Where is Goa";
$utterances = ["Goa", "Where is Goa"];
// prepare training phrases for intent
$trainingPhrases = [];
foreach ($utterances as $trainingPhrasePart) {
$part = new Intent_TrainingPhrase_Part();
$part->setText($trainingPhrasePart);
// create new training phrase for each provided part
$trainingPhrase = new Intent_TrainingPhrase();
$trainingPhrase->setParts([$part]);
$trainingPhrases[] = $trainingPhrase;
}
$messageTexts = 'Goa is in India.';
// prepare messages for intent
$text = new Intent_Message_Text();
$text->setText([$messageTexts]);
$message = new Intent_Message();
$message->setText($text);
$createIntentObject = $intentsClient->projectAgentName(env("DIALOG_FLOW_PROJECT_ID"));
// prepare intent
$intent = new Intent();
$intent->setDisplayName($disaplayName);
$intent->setTrainingPhrases($trainingPhrases);
$intent->setMessages([$message]);
$contexts = ['test'];
foreach($contexts as $con){
$contextObj = new Context();
$contextObj->setName($con);
$contextData[] = $contextObj;
$intent->setOutputContexts($contextData);
}
// $intent->getOutputContexts('test');
//dd($intent);
$response = $intentsClient->createIntent($createIntentObject, $intent);
printf('Intent created: %s' . PHP_EOL, $response->getName());
}
I am getting error message
{
"message": "com.google.apps.framework.request.BadRequestException: Resource name does not match format 'projects/{project_id}/agent/sessions/{session_id}/contexts/{context_id}' or 'projects/{project_id}/locations/{location_id}/agent/sessions/{session_id}/contexts/{context_id}'.",
"code": 3,
"status": "INVALID_ARGUMENT",
"details": []
}
I believe the issue is with the format of storing the output context. Please help me on this.
I had the same issue. The answer is to not put in the bare name, but to have a string of a certain format made
see http://googleapis.github.io/google-cloud-php/#/docs/google-cloud/v0.131.0/dialogflow/v2/intent?method=setOutputContexts
// $projectId your project id
// $sessionId can be anything, I use $sessionId = uniqid();
$uri = "projects/$projectId/agent/sessions/$sessionId/contexts/$con";
$contextObj->setName($uri);
I can see that there are any response about this topic.
I leave here my solution for the next generations
To create a output context you need to create the correct format, for this objetive you can use Context class Google\Cloud\Dialogflow\V2\Context
private function parseoOutputContexts($contexts, $project_id, $lifespan = 5)
{
$newContexts = array();
foreach ($contexts as $context) {
$newContexts[] = new Context(
[
'name' => 'projects/' . $project_id . '/agent/sessions/-/contexts/' . $context,
'lifespan_count' => $lifespan
]
);
}
return $newContexts;
}
And you can use this function to finnaly add the output context to the object Intent.
$dialogflow_intent = new Intent();
$output_contexts = ['output_context_1'. 'output_context_2'];
$output_contexts = $this->parseOutputContexts($output_contexts, '[YOUR_PROJECT_ID]');
$dialogflow_intent->setOutputContexts($output_contexts);

Delete filled in details after restart

I'm trying to let a person fill in some details and return an overview of the details. There is an option to restart the conversation (look at code) but when the conversation is restarted and the person fill in some new details, it will show the old details of the first filled in details.
How can i fix this problem ?
bot.dialog('overview', function (session, options) {
if (session.message && session.message.value) {
if(session.message.value.actions == "Accept"){
}
return;
}
var overview_msg = require('./cards/overview.json');
var date = new Date();
overview_msg.attachments[0].content.body[0].items[1].columns[1].items[0].text = overview_msg.attachments[0].content.body[0].items[1].columns[1].items[0].text.replace(/{{name}}/,nameGuest)
overview_msg.attachments[0].content.body[0].items[1].columns[1].items[1].text = overview_msg.attachments[0].content.body[0].items[1].columns[1].items[1].text.replace(/{{date}}/,date.toDateString() +' ' + date.toLocaleTimeString());
overview_msg.attachments[0].content.body[1].items[1].facts[0].value = overview_msg.attachments[0].content.body[1].items[1].facts[0].value.replace(/{{email}}/, mailGuest);
overview_msg.attachments[0].content.body[1].items[1].facts[1].value = overview_msg.attachments[0].content.body[1].items[1].facts[1].value.replace(/{{phone}}/, phoneGuest);
overview_msg.attachments[0].content.body[1].items[1].facts[2].value = overview_msg.attachments[0].content.body[1].items[1].facts[2].value.replace(/{{extra}}/, numberPeople);
overview_msg.attachments[0].content.body[1].items[1].facts[3].value = overview_msg.attachments[0].content.body[1].items[1].facts[3].value.replace(/{{lunch}}/, lunchGuest);
overview_msg.attachments[0].content.body[1].items[1].facts[3].value = overview_msg.attachments[0].content.body[1].items[1].facts[3].value.replace(/{{allergy}}/, lunchAllergyGuest);
overview_msg.attachments[0].content.body[1].items[1].facts[3].value = overview_msg.attachments[0].content.body[1].items[1].facts[3].value.replace(/{{vegan}}/, lunchVegan);
session.send(overview_msg);
bot.dialog('restart', function (session) {
session.beginDialog('overview');
}).triggerAction({matches: /restart|quit/i});
I think it may relate to how you define variables nameGuest, mailGuest, phoneGuest, etc which are not shown in your code snippet.
For getting values from Input.Text of adaptive-card, you can try the following code snippet:
bot.dialog('form', [
(session, args, next) => {
let card = require('./card.json');
if (session.message && session.message.value) {
next(session.message.value)
} else {
var msg = new builder.Message(session)
.addAttachment(card);
session.send(msg);
}
},
(session, results) => {
// Get the User input data here
session.send(JSON.stringify(results));
}
]).triggerAction({
matches: ['form', 'Action.Submit']
})
Yes i managed to get it done.
Instead of replacing the value in the json i referred to the variable.
example:
overview_msg.attachments[0].content.body[1].items[1].facts[0‌​].value = VARIABLE

Resources