title: Dynamically Add Widget on user click in Gmail Add-on using CardService Appscript (GAS)
body: <p>I am working on creating Gmail Add-on on one of my project. I got stuck on one scenario. I want to show user a dropdown and when user selects any value from this dropdown, I want to dynamically add a new label/texfield below dropdown which will show you the selected value. 
  I am using newSelectionInput method of CardService to create a dropdown.
  Here's the code for it: </p>
  
  <pre><code>var dueDateDropDown = CardService.newSelectionInput()
  .setType(CardService.SelectionInputType.DROPDOWN)
  .setTitle("Due Date")
  .setFieldName("due_date")
  .addItem("No due date", "one_value", true)
  .addItem("Today", "two_value", false)
  .addItem("Tomorrow", "three_value", false)
  .addItem("This Friday", "four_value", false)
  .addItem("Next Monday", "five_value", false)
  .setOnChangeAction(CardService.newAction().setFunctionName('addLabel'))
  </code></pre>
  
  <p>So can someone help me writing the <code>addLabel</code> function which will add label widget. 
  This is a function which I am trying to write:</p>
  
  <pre><code> function addLabel(e){
    var selected = e.formInputs.due_date;
  
    // Activate temporary Gmail add-on scopes.
    var accessToken = e.messageMetadata.accessToken;
    GmailApp.setCurrentMessageAccessToken(accessToken);
  
    var messageId = e.messageMetadata.messageId;
    var message = GmailApp.getMessageById(messageId);
    var thread = message.getThread();
  
    Logger.log(message.getSubject());
    Logger.log(selected);
    // What should be the code for adding a label or textbox to the widget here.
  }
  </code></pre>
  
  <p>Thanks in advance.</p>