I want to automatically create an calendar event from gmail.
I order to test the same I am using the URL (https://script.google.com) to test the same but the code is not working.
The code is as follows:
File name - Code.js
function testSchemas() {
var htmlBody = HtmlService.createHtmlOutputFromFile('mail_template').getContent();
MailApp.sendEmail({
to: Session.getActiveUser().getEmail(),
subject: 'Test Email - ' + new Date(),
htmlBody: htmlBody,
});
}
File name - mail_template.html
<html>
<body>
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "EventReservation",
"reservationNumber": "IO12345",
"underName": {
"#type": "Person",
"name": "Rahul Kumar"
},
"reservationFor": {
"#type": "Event",
"name": "Google I/O 2013",
"startDate": "2017-01-05T08:30:00-08:00",
"location": {
"#type": "Place",
"name": "Moscone Center",
"address": {
"#type": "PostalAddress",
"streetAddress": "800 Howard St.",
"addressLocality": "San Francisco",
"addressRegion": "CA",
"postalCode": "94103",
"addressCountry": "US"
}
}
}
}
</script>
<p>
Dear Rahul, thanks for booking your Google I/O ticket with us.
</p>
<p>
BOOKING DETAILS<br/>
Reservation number: IO12345<br/>
Order for: Rahul Kumar<br/>
Event: Google I/O 2013<br/>
Start time: Jan 5th 2017 8:00am PST<br/>
Venue: Moscone Center, 800 Howard St., San Francisco, CA 94103<br/>
</p>
</body>
</html>
Related
I have a problem where I am unable to retrieve values from the message card text input in Microsoft Teams, but the same JSON template actually works on Message Card Playground.
A brief overview of my Microsoft Card implementation. I have to use MessageCard as I am using connectors (incoming webhook) to send a card to Microsoft Teams. Thus, the input value substitution syntax is referred from Message Card Reference - {{<id of input>.value}}. I am not getting any value using this syntax in my Message Card when I am in TEAMS. E.g. User filled in a textbox, and the value is not being captured or cannot be retrieved with this syntax.
The card that I used is as followed:
{
"#type": "MessageCard",
"#context": "http://schema.org/extensions",
"themeColor": "0076D7",
"summary": "{{ctx.monitor.name}}",
"sections": [
{
"activityTitle": "![TestImage](https://47a92947.ngrok.io/Content/Images/default.png){{ctx.monitor.name}}",
"activitySubtitle": "Alert",
"activityImage": "https://teamsnodesample.azurewebsites.net/static/img/image5.png",
"facts": [
{
"name": "Assigned to",
"value": "Sam"
}
],
"markdown": true
}
],
"potentialAction": [
{
"#type": "ActionCard",
"name": "Add a comment",
"inputs": [
{
"#type": "TextInput",
"id": "comment",
"title": "Enter your comment",
"isMultiline": true
}
],
"actions": [
{
"#type": "HttpPOST",
"name": "OK",
"target": "https://webhook.site/ab592c11-4590-438d-90c2-57bc4bb4aa8a?serviceToken=d2l0cy1zYW06MXFhekBXU1g%3D",
"body": "{{comment.value}}"
}
]
}
]
}
Note: You can see there is "summary": "{{ctx.monitor.name}}", it is a property from Kibana (a data visualization tool). This value works, but it is not our focus right here. My problem is I cannot get any value from {{comment.value}}, it is an empty string.
My questions are:
Is this the limitation coming from MSFT Teams itself?
#csamleong could you please replace the "body": "comment ={{comment.value}}" so you will receive the comment value:
card json:
{
"summary": "Card \"Test card\"",
"themeColor": "0078D7",
"#type": "MessageCard",
"#context": "http://schema.org/extensions",
"themeColor": "0076D7",
"summary": "{{ctx.monitor.name}}",
"sections": [
{
"activityTitle": "![TestImage](https://47a92947.ngrok.io/Content/Images/default.png){{ctx.monitor.name}}",
"activitySubtitle": "Alert",
"activityImage": "https://teamsnodesample.azurewebsites.net/static/img/image5.png",
"facts": [
{
"name": "Assigned to",
"value": "Sam"
}
],
"markdown": true
}
],
"potentialAction": [
{
"#type": "ActionCard",
"name": "Add a comment",
"inputs": [
{
"#type": "TextInput",
"id": "comment",
"title": "Enter your comment",
"isMultiline": true
}
],
"actions": [
{
"#type": "HttpPOST",
"name": "OK",
"target": "https://daf47bb241c6.ngrok.io//weatherforecast/Configure/Comment",
"body": "comment={{comment.value}}"
}
]
}
]
}
Post Method:
[HttpPost]
[Route("Configure/Comment")]
public async Task<ActionResult> Comment()
{
string bodyStr;
using (var reader = new StreamReader(this.Request.Body, Encoding.UTF8, true, 1024, true))
{
bodyStr = await reader.ReadToEndAsync();
}
string comment = string.IsNullOrWhiteSpace(bodyStr) ? string.Empty : bodyStr.Split('=')[1];
Response.Headers.Add("CARD-UPDATE-IN-BODY", "true");
return null;
}
You will receive value in the comment varable.
I recognized that the return of CalendarList has changed. the summary value was person's name but now it returns email address.
my question is how can I get calendar name using calendar API?
tested url: https://developers.google.com/calendar/v3/reference/calendarList/list
◆ Before
{
"kind": "calendar#calendarList",
"items": [
{
"kind": "calendar#calendarListEntry",
"etag": "\"1578551131788000\"",
"id": "test#test.com",
"summary": "Test Calendar", // <-- calendar's name
"timeZone": "Asia/Tokyo",
◆Now
{
"kind": "calendar#calendarList",
"items": [
{
"kind": "calendar#calendarListEntry",
"etag": "\"1578551131788000\"",
"id": "test#test.com",
"summary": "test#test.com", // <-- email address
"timeZone": "Asia/Tokyo",
There is currently a bug in Google calendar. its not returning the title in the summary as it is documented to do Bug report can be found here.
Calendar.get on my primary calendar returns
{
"kind": "calendar#calendar",
"etag": "\"KfTgGrEyu1otuO_8YfN8ka6X3tg\"",
"id": "xxx#gmail.com",
"summary": "xxxx#gmail.com",
"description": "test",
"timeZone": "Europe/Copenhagen",
"conferenceProperties": {
"allowedConferenceSolutionTypes": [
"eventHangout"
]
}
}
The documentation states that a calendar resource should return
summary = Title of the calendar.
I'm doing a HttpPost from a message card with some user input fields. The message card is sent to MS teams and contains a Http Post action to another target which receives the user's selected inputs. I'm sending User's data in body of the Http Post. Input value substitution works fine in MS teams desktop but not working in MS teams android. Any suggestions are highly appreciated.
Snippet with httpPost:
{
"#type": "ActionCard",
"actions": [
{
"#type": "HttpPOST",
"body": "{\"Comment\":\"{{Comment.value}}\",\"Choice1\" : \"{{1c.value}}\",\"Choice2\" : \"{{2c.value}}\"}",
"name": "Submit Edit",
"target": "https://.."
}
],
"inputs": [
{
"#type": "TextInput",
"id": "Comment",
"isMultiline": true,
"isRequired": true,
"title": "Comment"
},
{
"#type": "TextInput",
"id": "1c",
"title": "Choice 1"
},
{
"#type": "TextInput",
"id": "2c",
"title": "Choice 2"
}
],
"name": "Edit"
}
]
}
Body received from MS teams android:
"body": {
"Comment": "{{Comment.value}}",
"Choice1": "{{1c.value}}",
"Choice2": "{{2c.value}}"
}
Body received from MS teams desktop:
"body": {
"Comment": "Test",
"Choice1": "Myinput",
"Choice2": "Myinput"
}
I am following this sample to implement Microsoft Graph interaction. I have managed to follow and display a page with my verification code, but the Teams SDK doesn't seem to want to post the code to my bot automatically.
I have the following lines in my oauth success page, as per the sample
<script src="https://unpkg.com/#microsoft/teams-js#1.4.2/dist/MicrosoftTeams.min.js" integrity="sha384-DcoNUuQTjpW5Sw3msonn/2ojgtNvtC5fCGd5U9RUpL3g1hla1LzHz8I9YIYSXe6q" crossorigin="anonymous"></script>
<script type="text/javascript">
setTimeout(function () {
document.getElementById("instructionText").style.display = "initial";
}, 5000);
microsoftTeams.initialize();
microsoftTeams.authentication.notifySuccess("{{verificationCode}}");
</script>
According to the sample, the bot receives an invoke message with name = signin/verifyState, but I do not. The sign-in page does close though.
Any ideas on why the page will not notify my bot of the code automatically?
Sorry this took so long. Got it.
So, the issue is that you're looking for a message activity, but Teams is sending an invoke activity, which isn't caught in onMessage. Instead, in your BotController, use something like:
this.onUnrecognizedActivityType(async (turnContext, next) => {
console.log(`GOT : ${ JSON.stringify(turnContext.activity, null, 2)}`)
});
This produces:
GOT : {
"name": "signin/verifyState",
"type": "invoke",
"timestamp": "2019-06-07T22:19:53.810Z",
"localTimestamp": "2019-06-07T22:19:53.810Z",
"id": "f:490708197841asdfasdfasdf15",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer/",
"from": {
"id": "29:1AvIMwjQc1iBRcFYBe-0opf4YzVU130fNasdjkhfkldjshfjkahgsdfjklasdkjfasdfcS_7MO9DKFFNL6Ow",
"name": "asdfasdfasdfasdf",
"aadObjectId": "asdfasdfasdfasdf"
},
"conversation": {
"conversationType": "personal",
"tenantId": "asdfasdfasdfasdfasd",
"id": "asdfasdfasdfasdf"
},
"recipient": {
"id": "asdfasdfasdfasdf",
"name": "asdfasdfasdfasdf"
},
"entities": [
{
"locale": "en-US",
"country": "US",
"platform": "Windows",
"type": "clientInfo"
}
],
"channelData": {
"tenant": {
"id": "asdfasdfadsfasdf"
},
"source": {
"name": "message"
}
},
"value": {
"state": "asdfasdfasdfasdf"
},
"locale": "en-US"
}
I would like to know how can I insert a string into a javascript code like in the example below:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Restaurant",
"name": "Dave's Steak House",
"address": {
"#type": "PostalAddress",
"streetAddress": "148 W 51st St",
"addressLocality": "New York",
"addressRegion": "NY",
"postalCode": "10019",
"addressCountry": "US"
}
}
</script>
The problem is that when I try to insert the String between js it appears interpreted as HTML code with %, &20 etc. I have tried with ?html, escape, no escape, ?string, ?js_string, etc.
That's the String:
{
"#context": "http://schema.org",
"#type": "Restaurant",
"name": "Dave's Steak House",
"address": {
"#type": "PostalAddress",
"streetAddress": "148 W 51st St",
"addressLocality": "New York",
"addressRegion": "NY",
"postalCode": "10019",
"addressCountry": "US"
}
}
And the code:
${myString}