I am trying to get the action event after a button is pressed on a thumbnail card generated in OnTeamsMessagingExtensionSelectItemAsync method. All the samples around this have used only Action.OpenUrl. Anyone have tried this ?
protected override Task<MessagingExtensionResponse> OnTeamsMessagingExtensionSelectItemAsync(ITurnContext<IInvokeActivity> turnContext, JObject query, CancellationToken cancellationToken)
{
var packages1 = JsonConvert.DeserializeObject<TicketClass>(query.ToString());
var card = new ThumbnailCard
{
Title = $"{packages1.Title}, {packages1.ShortDescription}",
Subtitle = packages1.LongDescription,
Buttons = new List<CardAction>
{
new CardAction { Type = ActionTypes.ImBack, Title = "Action 1 ", Value = "Show me more" },
new CardAction { Type = ActionTypes.OpenUrl, Title = "Action 2", Value = "" },
},
};
var attachment = new MessagingExtensionAttachment
{
ContentType = ThumbnailCard.ContentType,
Content = card,
};
return Task.FromResult(new MessagingExtensionResponse
{
ComposeExtension = new MessagingExtensionResult
{
Type = "result",
AttachmentLayout = "list",
Attachments = new List<MessagingExtensionAttachment> { attachment }
}
});
}
Related
I already have the radio button in DocuSign template, I want to select one of correct option from True and False programmatically. With the help of radioGroup.Radios.Add(, I am getting overwrite button on template button. Can you please suggest the solution how i can select radio button through c# code.
RadioGroup radioGroup = new RadioGroup { GroupName =
templateField.DocuSignFieldName, DocumentId = "1",
Radios = new List<Radio>() };
radioGroup.Radios.Add(
new Radio { PageNumber = "3", Value = "Radio 1",
XPosition = "52", YPosition = "344", Selected = "true",
TabId = templateField.DocuSignFieldName });
radioGroup.Radios.Add(
new Radio { PageNumber = "3", Value = "Radio 2",
XPosition = "85", YPosition = "344", Selected = "false",
TabId = templateField.DocuSignFieldName });
radioTabs.Add(radioGroup);
Your template has a radio group
When you use the API to send the envelope, you want to choose the initial value of the radio group. (If you want the radio buttons to be read-only, then use the locked attribute.)
You will need the tabId and value for the radio button you want to set.
Here is the request object that uses a template on the server, and then sets the name/email of the signer, and sets which radio button is selected.
{
"envelopeDefinition": {
"status": "sent",
"compositeTemplates": [
{
"compositeTemplateId": "1",
"serverTemplates": [
{
"sequence": "1",
"templateId": "12345-678-91023"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "larry#example.com",
"name": "Larry K",
"roleName": "Signer1",
"recipientId": "1",
"tabs": {
"radioGroupTabs": [
{
"groupName": "Radio Group 1",
"radios": [
{
"selected": "true",
"tabId": "615d0f54-8754-459e-9f79-e72ad427557c",
"value": "Radio3"
}
]
}
]
}
}
]
}
}
]
}
]
}
}
Here is the same JSON when it is created with the C# SDK
ServerTemplate serverTemplate1 = new ServerTemplate
{
Sequence = "1",
TemplateId = "12345-678-91023"
};
List<ServerTemplate> serverTemplates1 = new List<ServerTemplate> {serverTemplate1};
Radio radio1 = new Radio
{
Selected = "true",
TabId = "615d0f54-8754-459e-9f79-e72ad427557c",
Value = "Radio3"
};
List<Radio> radios1 = new List<Radio> {radio1};
RadioGroup radioGroupTab1 = new RadioGroup
{
GroupName = "Radio Group 1",
Radios = radios1
};
List<RadioGroup> radioGroupTabs1 = new List<RadioGroup> {radioGroupTab1};
Tabs tabs1 = new Tabs
{
RadioGroupTabs = radioGroupTabs1
};
Signer signer1 = new Signer
{
Email = "larry#example.com",
Name = "Larry K",
RecipientId = "1",
RoleName = "Signer1",
Tabs = tabs1
};
List<Signer> signers1 = new List<Signer> {signer1};
Recipients recipients1 = new Recipients
{
Signers = signers1
};
InlineTemplate inlineTemplate1 = new InlineTemplate
{
Recipients = recipients1,
Sequence = "1"
};
List<InlineTemplate> inlineTemplates1 = new List<InlineTemplate> {inlineTemplate1};
CompositeTemplate compositeTemplate1 = new CompositeTemplate
{
CompositeTemplateId = "1",
InlineTemplates = inlineTemplates1,
ServerTemplates = serverTemplates1
};
List<CompositeTemplate> compositeTemplates1 = new List<CompositeTemplate> {compositeTemplate1};
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition
{
CompositeTemplates = compositeTemplates1,
Status = "sent"
};
ApiClient apiClient = new ApiClient(basePath);
apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + accessToken);
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
try
{
EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);
Console.WriteLine($"Envelope status: {results.Status}. Envelope ID: {results.EnvelopeId}");
return results.EnvelopeId;
}
catch (ApiException e)
{
Console.WriteLine("Exception while creating envelope!");
Console.WriteLine($"Code: {e.ErrorCode}\nContent: {e.ErrorContent}");
//Console.WriteLine(e.Message);
return "";
}
}
Please find the correct answer .
RadioGroup radioGroup = new RadioGroup
{
GroupName = templateField.DocuSignFieldName,
Radios = new List<Radio>()
};
if (_applicationAnswerMapService.GetRadioboxFieldValue(templateField, application) == "true")
{
radioGroup.Radios.Add(new Radio { Value = "Radio1", Selected = "true" });
}
else
{
radioGroup.Radios.Add(new Radio { Value = "Radio2", Selected = "false" });
}
I know nopCommerce gives this example when you want to add a menu item into the admin dashboard from a plugin:
nopCommerce documentation Admin menu
However, my problem is my controller is not called
This is my code in plugin.cs:
var subMenuItemTwo = new SiteMapNode
{
SystemName = "AttestationEditor",
Title = "Edit Attestations (Name and Cancellation Reason only)",
ControllerName = "CarbonOffsetPlatformAdminController",
ActionName = "AttestationEditing",
IconClass = "fa fa-dot-circle-o",
Visible = true,
RouteValues = new RouteValueDictionary
{
{ "area", "AttestationEditorPage"}
},
};
//Ich füge mein menuItem hinzu
rootNode.ChildNodes.Add(menuItem);
menuItem.ChildNodes.Add(subMenuItem);
menuItem.ChildNodes.Add(subMenuItemTwo);
This is my Action method in CarbonOffsetPlatformAdminController.cs:
[HttpGet]
public IActionResult AttestationEditing()
{
var attestationEditing = new AttestationEditorModel();
return View("~/Views/AttestationEditing/AttestationEditorStart.cshtml", attestationEditing);
}
what am I doing wrong? Thanks in advance
You have problem with ControllerName and RouteValues.
Replace
var subMenuItemTwo = new SiteMapNode
{
SystemName = "AttestationEditor",
Title = "Edit Attestations (Name and Cancellation Reason only)",
ControllerName = "CarbonOffsetPlatformAdminController",
ActionName = "AttestationEditing",
IconClass = "fa fa-dot-circle-o",
Visible = true,
RouteValues = new RouteValueDictionary
{
{ "area", "AttestationEditorPage"}
},
};
By
var subMenuItemTwo = new SiteMapNode
{
SystemName = "AttestationEditor",
Title = "Edit Attestations (Name and Cancellation Reason only)",
ControllerName = "CarbonOffsetPlatformAdmin", //Change here
ActionName = "AttestationEditing",
IconClass = "fa fa-dot-circle-o",
Visible = true,
RouteValues = new RouteValueDictionary
{
{ "area", "Admin"} //Change here
},
};
I am using Autodesk Forge DesignAutomatin V3 in C# and am getting an error when creating an Activity.
this is the error i receive: System.IO.InvalidDataException: 'CommandLine is a required property for Activity and cannot be null'
Here is how i am setting up the activity.
var activity = new Activity()
{
CommandLine = new List<string>() { $"$(engine.path)\\accoreconsole.exe /i $(args[InputModel].path) /al $(appbundles[{_bundleId}].path) /s $(settings[script].path)" },
Parameters = new Dictionary<string, ModelParameter>()
{
{ "HostDwg", new ModelParameter() { Verb = ModelParameter.VerbEnum.Get, LocalName = "$(HostDwg)", Required = true } },
{ "InputModel", new ModelParameter() { Verb = ModelParameter.VerbEnum.Get, LocalName = "3DBuild.dxf", Required = true, } },
{ "Result", new ModelParameter() { Verb = ModelParameter.VerbEnum.Put, Zip = true, LocalName = _outPutFileName, Required = true } }
},
Engine = _engineVersion,
Appbundles = new List<string>() { myApp },
Settings = new Dictionary<string, dynamic>()
{
{ "script", new StringSetting() { Value = string.Format("DXFIN\n\"3DBuild.dxf\"\nExplodeModel\n-view sw\nDXFOUT\n{0}\n16\n", _outPutFileName) } }
},
Description = "DXF processor",
Version = 1,
Id = _activityName
};
Please use exclusive Design Automation .NET core SDK for v3, it appears that you are referring Design Automation namespace from autodesk.forge.
When you add new SDK, make sure you remove this - using Autodesk.Forge.Model.DesignAutomation.v3; from your code.
var activity = new Activity() {
CommandLine = new List < string > () {
$ "$(engine.path)\\accoreconsole.exe /i $(args[InputModel].path) /al $(appbundles[{PackageName}].path) /s $(settings[script].path)"
}, Parameters = new Dictionary < string, Parameter > () {
{
"HostDwg",
new Parameter() {
Verb = Verb.Get, LocalName = "$(HostDwg)", Required = true
}
}, {
"InputModel",
new Parameter() {
Verb = Verb.Get, LocalName = "3DBuild.dxf", Required = true,
}
}, {
"Result",
new Parameter() {
Verb = Verb.Put, Zip = true, LocalName = outputFile, Required = true
}
}
}, Engine = TargetEngine, Appbundles = new List < string > () {
myApp
}, Settings = new Dictionary < string, ISetting > () {
{
"script",
new StringSetting() {
Value = string.Format("DXFIN\n\"3DBuild.dxf\"\nExplodeModel\n-view sw\nDXFOUT\n{0}\n16\n", outputFile)
}
}
}, Description = "DXF processor", Version = 1, Id = ActivityName
};
Hello i am trying to do this template on my C# code for Bot Framework V4.
This is the code from facebook.
"payload": {
"template_type":"button",
"text":"<MESSAGE_TEXT>",
"buttons":[
<BUTTON_OBJECT>,
<BUTTON_OBJECT>,
...
]
}
And this is my attempt of doing it. I can't debug the error cause it only works on messenger. Any help would be appreciated thank you.
Activity reply = stepContext.Context.Activity.CreateReply();
reply.ChannelData = JObject.FromObject(
new
{
attachment = new
{
type = "template",
payload = new
{
template_type = "button",
text = "xx",
buttons = new[]
{
new
{
type = "web_url",
title = "take test",
url = "xx",
messenger_extensions="true",
webview_height_ratio = "tall",
},
},
},
},
});
await stepContext.Context.SendActivityAsync(reply);
Your code looks fine. Make sure to Whitelist any URLs you use with Facebook. Note, they must be https URLs. Additionally, unless the website is configured to be a webview, you do not need the messenger_extensions and webview_height_ratio properties in the button.
var reply = turnContext.Activity.CreateReply();
var attachment = new
{
type = "template",
payload = new
{
template_type = "button",
text = "Sign up for our mailing list!",
buttons = new[]
{
new
{
type = "web_url",
url = "https://mybot.azurewebsites.net/",
title = "Sign Up!"
},
},
},
};
reply.ChannelData = JObject.FromObject(new { attachment });
await turnContext.SendActivityAsync(reply, cancellationToken);
Take a look at Messengers Documentation on Button Templates for more details.
Hope this helps!
I have the following drop down list. How can I check the selected value BEFORE saving the data into the module? I want to use the selected value in setting the values of Neighborhood's drop down list.
#Html.DropDownListFor(model => model.City, new SelectList(
new List<Object>{
new { value = "Abha", text = "Abha" },
new { value = "Al Qunfudhah", text = "Al Qunfudhah" },
new { value = "Al-Kharj", text = "Al-Kharj" },
new { value = "Al-Ahsa", text = "Al-Ahsa" },
new { value = "Buraidah", text = "Buraidah" },
new { value = "Dammam", text = "Dammam" },
new { value = "Ha'il", text = "Ha'il"},
new { value = "Hafar Al-Batin", text = "Hafar Al-Batin" },
new { value = "Jazan", text = "Jazan" },
new { value = "Jeddah", text = "Jeddah" },
new { value = "Jubail", text = "Jubail" },
new { value = "khobar", text = "khobar" },
new { value = "Khamis Mushait", text = "Khamis Mushait" },
new { value = "Mecca", text = "Mecca" },
new { value = "Medina", text = "Medina" },
new { value = "Najran", text = "Najran" },
new { value = "Qatif", text = "Qatif" },
new { value = "Riyadh", text = "Riyadh" },
new { value = "Tabuk", text = "Tabuk" },
new { value = "Ta'if", text = "Ta'if" },
new { value = "Yanbu", text = "Yanbu" }
},"value", "text", "Jeddah"))
#Html.ValidationMessageFor(model => model.City)
</div>
</div>
With jQuery, you can try
$('#City').val();
If you are not using jQuery, the vanilla javascript way would be
var element = document.getElementById("City");
var strVal = element.options[element.selectedIndex].value;