Showing posts with label Professional Development. Show all posts
Showing posts with label Professional Development. Show all posts

Send an Email with a Function: Part 2

There are times that automated email can be very helpful. The concept I'm going with here is aligning to a form response. When we ask folks to sign up for something we sometimes need them to have materials or may want to customize the response. Yes, in Forms you can customize a response to the form but what if you want to get fancy? Say people are filling out a form for an audition (I was in the entertainment industry so I'm using an example personal to me) they are going to need to audition materials and information for the particular role they are auditioning for. Here's where a script can help you to select who receives what.

Let's go back to our form we were collecting emails on. We'll keep this simple to begin then I'll give you a case where it can be expanded.

Open the Scripts Tools>Script editor. You should have:
function formResponse(e){
   Logger.log(e.values[0]);
}

Try changing it to:

function formResponse(e){
   Logger.log(e.values);
}

Submit a form response again. 

The 0 index of the form response is the timestamp. If we modify our log to get the value of e, Logger.log(e); we will get all the information returned. Logger.log(e.values); will return all the values of the form response. 
We want to identity the index of the email address. If you are collecting emails automatically if will likely be index 1 or e.values[1]. If you are collecting emails in your form it will be listed in the form at an index relative to all other information you may be collecting. If you have turned on the automatic collecting of email and turned it back off you may have also created an index with no information or null. 
Your incoming data may look like this [9/16/2018 11:03:52, clay@claycodes.org, Clay Smith, Danny] or [9/16/2018 11:05:21, , Clay, Danny, clay@claycodes.org] or something else. 

Each index is separated by a comma. If we want to get the values of a particular index we can use the index number. There are other methods but this is a good concept to start with. 

function formResponse(e){
   Logger.log(e.values);
}

Our function returns all the values to the log. It's now time to start doing something with the values. We want to send an email when some one submits the form. Let's set a variable to be the email address. We can do this with: 

var email = e.values[4]; 

The 4 index is from the image sample above. Your index may be different.

Next let's identify a file URL we want to include in our email. To make it easy here's a link to Bloom's Taxonomy verbs. https://drive.google.com/file/d/0BxUJf-bQ7_PzNnFKMXdOUjJGZGM/view?usp=sharing
We can assign this link to a variable by typing: var fileurl = 'https://drive.google.com/file/d/0BxUJf-bQ7_PzNnFKMXdOUjJGZGM/view?usp=sharing';
I've made up the variable name fileurl just like I did email. I'm using the apostrophe, ', mark to indicate the data is a string or typed letters and not something to be calculated. The apostrophe encloses the information on each end. 

We'll make a variable for the body and include some characters which will be escaped. Meaning they are normally reserved for programming but we will tell the program not to read them as part of the programing. 

var body = 'Thanks for filling out the form here\'s a document to read before we begin. \n ' + fileurl;
The \ is used to escape characters. The apostrophe typically represents the end of a string of characters, in this case we're using it grammatically. So we escape it with \'. Looking at the other escape character we see \n representing a new line. The + symbol is used to put things together. just like we would add 2 and 2 to get 4 a string gets added to make a longer string. The fileurl is a variable so it doesn't go in apostrophes or the system will think it's the word fileurl. 

Now let's put these elements together as an email. 

var mail = GmailApp.sendEmail(email, 'Subject goes here' , body);

The GmailApp loads a library of possible functions. We are using the pre-made sendMail which takes in three inputs, an email address, the subject of the email, and the body of the email. We could have used a variable for the subject but here I've entered it as a string to build on the idea that we don't have to always create variables. we could also replace the variable email with e.values[4] and it will still function.

Putting it all together looks like:

function formResponse(e){
  Logger.log(e.values);
  var email = e.values[4];
  var fileurl = 'https://drive.google.com/file/d/0BxUJf-bQ7_PzNnFKMXdOUjJGZGM/view?usp=sharing';
  var body = 'Thanks for filling out the form here\'s a document to read before we begin. \n ' + fileurl;
  var mail = GmailApp.sendEmail(email, 'Subject goes here' , body);
}

Google handles a lot of security for you. To be sure all the security is engaged for our function let's try running it. It will give us an error but before it does it will go through the permission checks and allow the mail feature to work. Click Run>Run function>formResponse
Accept the permissions and we'll be ready to submit through the Form. 




Go ahead and submit a new form with your email address. Check your email. You should get the response from the script you wrote. Congratulations!!!

So here's a use case which may help. Let's use the audition example. We'll add a dropdown of role with two selections. Danny or Sandy. We'll create an if statement to change the fileurl based on the role. We could also change the text of the body and subject by using the conditional statement but we'll keep it simple. 

function formResponse(e){
  Logger.log(e.values);
  var email = e.values[4];
  var role = e.values[3];
if(role == 'Danny'){
   var fileurl = 'https://drive.google.com/file/d/1-hGi-F7EAi4pBXoDoZHzLQ2qasJ4ie2F/view?usp=sharing';
}else if(role=='Sandy'){
   var fileurl = 'https://drive.google.com/file/d/1t7bVocmj9QaHApIIlc91l3RARg4gXoKa/view?usp=sharing
}
  var body = 'Thanks for filling out the form here\'s a document to read before we begin. \n ' + fileurl;
  var mail = GmailApp.sendEmail(email, 'Subject goes here' , body);
}

onFormSubmit Do Something: Part 1


Did you know Google Scripts can be triggered when a form submits to do something? Assigning a function to the onFormSubmit trigger and it will call that function. Let’s build one now to email a response to a submitted form.

We all have sign-ups we use with our school community. Sometimes when some one signs up we need to provide them with a document and other information. With Google Apps Scripts we can automatically send an email to the person that signed up with attachments.  

Let’s explore. 
Start by creating a form. Be sure to turn on the Email capture or make a field for people to type their email and validate it as an email. Add any other questions to your form that you like. Keep the Allow only 1 response off so we can test with our own email multiple times.

Our script will be built in Google Sheets. IN the form responses link the responses to a new sheet. Open the sheet and select Tools>Script editor. The editor will open in a new tab. Give a name to your script. Remove the pre-populated function, myFunction, so we are working with a blank area. Let’s begin our function:

function formResponse(e){
}

I’m calling it formResponse because it makes sense to me. I made up this name for the function. It’s also case sensitive. So if I use it later I have to be sure it’s typed exactly the same way. 
This function is going to take an input of e.  e represents the form response. Let’s first take a look at what e looks like when it’s received. We’ll use the Logger for this. In the function type Logger.log(e);

function formResponse(e){
   Logger.log(e);
}

Now let’s hook up the trigger before testing. Click on the button that looks like a clock. 

This will open the Trigger settings. Click "No triggers set up. Click here to add one now." to add a trigger.






It will likely automatically populate the function we create. The Run column identifies the function to activate. The Events column gives the selection to happen either when something in the spreadsheet happens or time based. The last column is the specific event triggering the function. We can add more than one function to activate when triggered and multiple triggers.


Click Save to save the trigger to our form. You will be asked to approve some permissions. Click Review Permissions. Select your account, then click Allow on the next screen.


Now let's see what data looks like when it comes into the form. Open the form in submission mode. Fill it out and click submit. Our function will have captured the submission in the Logger. To get to the logger click View>Logs. This will open a window floating over our script with the data from the form submission.

When we look at the Logger we are seeing the form submission in the form of a program object. Let’s look closely at the label values. Notice it equals an open square bracket, "[",  then some comma separated information followed by a closed square bracket, "]". This is the information submitted through the Form as a list. A list is separated data with an unseen reference called an index. The index starts counting from 0. The first piece of data in the list is the timestamp. Let’s grab the timestamp and show it in our log. To return that value only we would use the input object e and the array values in e with the index 0. Logger.log(e.values[0]);

function formResponse(e){
   Logger.log(e.values[0]);
}

When we look at the Logger now we see only the timestamp. With this method we can identify the Email or other response data. We'll look further into how to use the response to do something in the next post. 

Professional Learning Networks



#nycSchoolsTech
Recently I had the opportunity to educate teachers on the Common Sense Education curriculum at the NYC STEM Institute. While facilitating some really great conversation I was struck by the excitement of the group. Tech always excites me. Especially when it gets used for positive unintended purposes. When I see an educator excited I know it will bring more to their communities. It also indicates they may have been missing out on belonging the right professional learning networks. 

I sometimes assume everyone knows and has see the basic educational technology available; GSuite, Office 365, Apple iWork. And I’m often wrong. Just seeing these things doesn’t mean an educator is taking advantage of them or knows how they work. It also doesn't mean they know how to infuse them in their practice. Giving EdTech to educators doesn’t change practice without proper training. This is where a good PLN, Professional Learning Network can help. 

PLNs take all forms, in-person meetups, conference video chats, online groups, etc. They can be asynchronous happening by email correspondence to bulletin board posting or synchronous through chat, conference calls or the old school face to face meeting. These can be invaluable resources of places to go when you have a question. They allow members to share materials and best practices. They engage people in improving their practice. But I’ve also seen the other side. Some great groups lay quiet and unused. Members join but then don't take the opportunity to engage each other as a resource. PLNs are good when they make an ongoing effort to engage with members. 

How do you know a good PLN:
  1. Engagement- Members and Leadership make an effort to regularly engage others in a group. The once a picnic isn’t enough. The group should pose thought provoking questions. Provide cutting edge resources. And provide a platform for discussion. It’s also helpful if the group doesn’t take itself too seriously. 
  2. Multiple ways to Connect- Not everyone can make it out on a Thursday night once a month. Providing multiple environments for members to meet is key in supporting engagement. Offer multiple digital environments and find a member to upkeep each. Take advantage of live-streams at meetings so members can virtually attend. Make a calendar of events physical and virtual so members can best plan to participate. 
  3. Positivity - It’s an exciting thing to be a part of a community you have been hoping to find. No one wants to be bashed for their opinion. Groups should be very conscious of what their rules are and clearly communicate them. Promote positivity in the group. Celebrate what others are doing. Provide a space for members to show off and talk about what they are doing. Engagement is much richer when it’s positive. Consider at times using a protocol when responding to others. Just saying everything is great defeats the purpose of growing as an educator. A framework of how to give feedback to promote growth supports everyone.
  4. Willingness to Collaborate- If we hoard all the cool things we are doing and how we do them we don’t participate in building capacity. We are past the time that things get created by one person. The best products are a collaboration of many ideas all supporting one another from different sources. 
  5. Wide range of resources- While a Google PLN will focus around Google topics the resources should not eliminate or exclude other tools which can be very valuable. Good resources are often that way because they can be used so universally. Your PLN should be curating resources for easy access by old and new members. 
  6. Partnerships- Networking inside the group is a great way to share practices. But what happens when the sharing gets stale? Developing connections with other networks, communities, and professional businesses can help to infuse new ideas into the group. Support when members really struggle is then just a connection away. 

I’m lucky to have stumbled on the #NYCSchoolsTech PLN in NYC. The group engages teachers through regular posts online by members and group leaders. In person meetings are organized Monthly as part of the PLNs Google Educator subgroup. Opportunities for training events and conferences are regularly posted. Most importantly there is a wide range of positive posts discussing practice, tech issues, job opportunities, and celebrations of work. While I may not always be at an event I gain from it through my colleagues. 

Find yourself a great PLN or make one. Your professional practice has everything to gain. 
#NYCSchoolsTech GEG Meetup NYC

Update: Added Partnership thanks to members of my PLN Andrew Liebowitz and Lisa Nielsen pointing it out. See how wonderful a PLN can be?

Social Emotional Well-Being During Online Teaching and Learning

The world is a bit nutty right now because of the COVID-19 pandemic. Schools are switching to online learning and parents are working from...