How can I add new sections to an existing card on Gmail Addon?











up vote
0
down vote

favorite












I'm actually trying to create a Chat interface in Gmail using Add-ons with App Script. All the interactions are working. But it keeps navigating to different cards rather than have it all in one card. Like in Google Tasks.



Is there a way in which I can just keep adding sections to the same card dynamically to create a chat like interface.



I assume if it is possible on Google Tasks Add-on it should be possible in this case too. Please help me out as it is a necessary requirement.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I'm actually trying to create a Chat interface in Gmail using Add-ons with App Script. All the interactions are working. But it keeps navigating to different cards rather than have it all in one card. Like in Google Tasks.



    Is there a way in which I can just keep adding sections to the same card dynamically to create a chat like interface.



    I assume if it is possible on Google Tasks Add-on it should be possible in this case too. Please help me out as it is a necessary requirement.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm actually trying to create a Chat interface in Gmail using Add-ons with App Script. All the interactions are working. But it keeps navigating to different cards rather than have it all in one card. Like in Google Tasks.



      Is there a way in which I can just keep adding sections to the same card dynamically to create a chat like interface.



      I assume if it is possible on Google Tasks Add-on it should be possible in this case too. Please help me out as it is a necessary requirement.










      share|improve this question















      I'm actually trying to create a Chat interface in Gmail using Add-ons with App Script. All the interactions are working. But it keeps navigating to different cards rather than have it all in one card. Like in Google Tasks.



      Is there a way in which I can just keep adding sections to the same card dynamically to create a chat like interface.



      I assume if it is possible on Google Tasks Add-on it should be possible in this case too. Please help me out as it is a necessary requirement.







      google-apps-script gmail-addons






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 11 at 23:06









      Kara

      3,929104152




      3,929104152










      asked Nov 12 at 7:52









      Akhil

      32




      32
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Update :
          Try this



              function renderRootCard(){
          var card = CardService.newCardBuilder();
          var section = CardService.newCardSection();
          var btnSet = CardService.newButtonSet();
          section.addWidget(CardService.newTextParagraph().setText("old widget"));
          section.addWidget(btnSet.addButton(addTaskBtn));
          card.addSection(section);

          var addTask = CardService.newAction().setFunctionName("addTask");
          var addTaskBtn = CardService.newTextButton()
          .setText("Add Task")
          .setOnClickAction(addTask);


          return card.build();
          }

          function addTask(e) {
          var card = CardService.newCardBuilder();
          var section = CardService.newCardSection();
          var btnSet = CardService.newButtonSet();
          section.addWidget(CardService.newTextParagraph().setText("old widget"));
          section.addWidget(btnSet.addButton(addTaskBtn));
          section.addWidget(CardService.newTextParagraph().setText("new widget"));
          var addTask = CardService.newAction().setFunctionName("addTask");
          var addTaskBtn = CardService.newTextButton()
          .setText("Add Task")
          .setOnClickAction(addTask);
          return CardService.newNavigation().updateCard(card.build());
          }


          Original answer:



          In short: Possible



          I understand what you are trying to do. This involves replacing the current card by updating it with a new card that has the same widgets as that of current card and additional widgets that are required.



          Let's say, you are building a to-do app. When you click add task(say), you just create the same card, add some widgets and replace the current card with a new one.






          share|improve this answer























          • Yes! Exactly what I'm trying to achieve. But I haven't come across a code sample or a skeleton. Is it possible for you to share a sample?
            – Akhil
            Nov 13 at 6:44










          • I've added based on your request.
            – Hari Balaji
            Nov 13 at 13:40










          • Doesn't this code work also without the updateCard method? Also the main bit for me is how do I store or pass content of an existing card.
            – Akhil
            Nov 14 at 7:13










          • Akhil, the code has updateCard method . Moreover, I could not find any straight forward way to do this, rather than redrawing the old card again, while doing an update. In order to persist the state of the old card , pass the state of the card to the new card through setParameters method. If CardService allows us the pass the Card as a parameter, we would not have to do this.
            – Hari Balaji
            Nov 14 at 7:16












          • If I have to redraw the whole conversation then first I need to store them separately and recreate the card each time. setParameters doesn't work as well. Have tried that too.
            – Akhil
            Nov 14 at 7:32











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257853%2fhow-can-i-add-new-sections-to-an-existing-card-on-gmail-addon%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Update :
          Try this



              function renderRootCard(){
          var card = CardService.newCardBuilder();
          var section = CardService.newCardSection();
          var btnSet = CardService.newButtonSet();
          section.addWidget(CardService.newTextParagraph().setText("old widget"));
          section.addWidget(btnSet.addButton(addTaskBtn));
          card.addSection(section);

          var addTask = CardService.newAction().setFunctionName("addTask");
          var addTaskBtn = CardService.newTextButton()
          .setText("Add Task")
          .setOnClickAction(addTask);


          return card.build();
          }

          function addTask(e) {
          var card = CardService.newCardBuilder();
          var section = CardService.newCardSection();
          var btnSet = CardService.newButtonSet();
          section.addWidget(CardService.newTextParagraph().setText("old widget"));
          section.addWidget(btnSet.addButton(addTaskBtn));
          section.addWidget(CardService.newTextParagraph().setText("new widget"));
          var addTask = CardService.newAction().setFunctionName("addTask");
          var addTaskBtn = CardService.newTextButton()
          .setText("Add Task")
          .setOnClickAction(addTask);
          return CardService.newNavigation().updateCard(card.build());
          }


          Original answer:



          In short: Possible



          I understand what you are trying to do. This involves replacing the current card by updating it with a new card that has the same widgets as that of current card and additional widgets that are required.



          Let's say, you are building a to-do app. When you click add task(say), you just create the same card, add some widgets and replace the current card with a new one.






          share|improve this answer























          • Yes! Exactly what I'm trying to achieve. But I haven't come across a code sample or a skeleton. Is it possible for you to share a sample?
            – Akhil
            Nov 13 at 6:44










          • I've added based on your request.
            – Hari Balaji
            Nov 13 at 13:40










          • Doesn't this code work also without the updateCard method? Also the main bit for me is how do I store or pass content of an existing card.
            – Akhil
            Nov 14 at 7:13










          • Akhil, the code has updateCard method . Moreover, I could not find any straight forward way to do this, rather than redrawing the old card again, while doing an update. In order to persist the state of the old card , pass the state of the card to the new card through setParameters method. If CardService allows us the pass the Card as a parameter, we would not have to do this.
            – Hari Balaji
            Nov 14 at 7:16












          • If I have to redraw the whole conversation then first I need to store them separately and recreate the card each time. setParameters doesn't work as well. Have tried that too.
            – Akhil
            Nov 14 at 7:32















          up vote
          0
          down vote













          Update :
          Try this



              function renderRootCard(){
          var card = CardService.newCardBuilder();
          var section = CardService.newCardSection();
          var btnSet = CardService.newButtonSet();
          section.addWidget(CardService.newTextParagraph().setText("old widget"));
          section.addWidget(btnSet.addButton(addTaskBtn));
          card.addSection(section);

          var addTask = CardService.newAction().setFunctionName("addTask");
          var addTaskBtn = CardService.newTextButton()
          .setText("Add Task")
          .setOnClickAction(addTask);


          return card.build();
          }

          function addTask(e) {
          var card = CardService.newCardBuilder();
          var section = CardService.newCardSection();
          var btnSet = CardService.newButtonSet();
          section.addWidget(CardService.newTextParagraph().setText("old widget"));
          section.addWidget(btnSet.addButton(addTaskBtn));
          section.addWidget(CardService.newTextParagraph().setText("new widget"));
          var addTask = CardService.newAction().setFunctionName("addTask");
          var addTaskBtn = CardService.newTextButton()
          .setText("Add Task")
          .setOnClickAction(addTask);
          return CardService.newNavigation().updateCard(card.build());
          }


          Original answer:



          In short: Possible



          I understand what you are trying to do. This involves replacing the current card by updating it with a new card that has the same widgets as that of current card and additional widgets that are required.



          Let's say, you are building a to-do app. When you click add task(say), you just create the same card, add some widgets and replace the current card with a new one.






          share|improve this answer























          • Yes! Exactly what I'm trying to achieve. But I haven't come across a code sample or a skeleton. Is it possible for you to share a sample?
            – Akhil
            Nov 13 at 6:44










          • I've added based on your request.
            – Hari Balaji
            Nov 13 at 13:40










          • Doesn't this code work also without the updateCard method? Also the main bit for me is how do I store or pass content of an existing card.
            – Akhil
            Nov 14 at 7:13










          • Akhil, the code has updateCard method . Moreover, I could not find any straight forward way to do this, rather than redrawing the old card again, while doing an update. In order to persist the state of the old card , pass the state of the card to the new card through setParameters method. If CardService allows us the pass the Card as a parameter, we would not have to do this.
            – Hari Balaji
            Nov 14 at 7:16












          • If I have to redraw the whole conversation then first I need to store them separately and recreate the card each time. setParameters doesn't work as well. Have tried that too.
            – Akhil
            Nov 14 at 7:32













          up vote
          0
          down vote










          up vote
          0
          down vote









          Update :
          Try this



              function renderRootCard(){
          var card = CardService.newCardBuilder();
          var section = CardService.newCardSection();
          var btnSet = CardService.newButtonSet();
          section.addWidget(CardService.newTextParagraph().setText("old widget"));
          section.addWidget(btnSet.addButton(addTaskBtn));
          card.addSection(section);

          var addTask = CardService.newAction().setFunctionName("addTask");
          var addTaskBtn = CardService.newTextButton()
          .setText("Add Task")
          .setOnClickAction(addTask);


          return card.build();
          }

          function addTask(e) {
          var card = CardService.newCardBuilder();
          var section = CardService.newCardSection();
          var btnSet = CardService.newButtonSet();
          section.addWidget(CardService.newTextParagraph().setText("old widget"));
          section.addWidget(btnSet.addButton(addTaskBtn));
          section.addWidget(CardService.newTextParagraph().setText("new widget"));
          var addTask = CardService.newAction().setFunctionName("addTask");
          var addTaskBtn = CardService.newTextButton()
          .setText("Add Task")
          .setOnClickAction(addTask);
          return CardService.newNavigation().updateCard(card.build());
          }


          Original answer:



          In short: Possible



          I understand what you are trying to do. This involves replacing the current card by updating it with a new card that has the same widgets as that of current card and additional widgets that are required.



          Let's say, you are building a to-do app. When you click add task(say), you just create the same card, add some widgets and replace the current card with a new one.






          share|improve this answer














          Update :
          Try this



              function renderRootCard(){
          var card = CardService.newCardBuilder();
          var section = CardService.newCardSection();
          var btnSet = CardService.newButtonSet();
          section.addWidget(CardService.newTextParagraph().setText("old widget"));
          section.addWidget(btnSet.addButton(addTaskBtn));
          card.addSection(section);

          var addTask = CardService.newAction().setFunctionName("addTask");
          var addTaskBtn = CardService.newTextButton()
          .setText("Add Task")
          .setOnClickAction(addTask);


          return card.build();
          }

          function addTask(e) {
          var card = CardService.newCardBuilder();
          var section = CardService.newCardSection();
          var btnSet = CardService.newButtonSet();
          section.addWidget(CardService.newTextParagraph().setText("old widget"));
          section.addWidget(btnSet.addButton(addTaskBtn));
          section.addWidget(CardService.newTextParagraph().setText("new widget"));
          var addTask = CardService.newAction().setFunctionName("addTask");
          var addTaskBtn = CardService.newTextButton()
          .setText("Add Task")
          .setOnClickAction(addTask);
          return CardService.newNavigation().updateCard(card.build());
          }


          Original answer:



          In short: Possible



          I understand what you are trying to do. This involves replacing the current card by updating it with a new card that has the same widgets as that of current card and additional widgets that are required.



          Let's say, you are building a to-do app. When you click add task(say), you just create the same card, add some widgets and replace the current card with a new one.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 at 13:37

























          answered Nov 12 at 12:22









          Hari Balaji

          28115




          28115












          • Yes! Exactly what I'm trying to achieve. But I haven't come across a code sample or a skeleton. Is it possible for you to share a sample?
            – Akhil
            Nov 13 at 6:44










          • I've added based on your request.
            – Hari Balaji
            Nov 13 at 13:40










          • Doesn't this code work also without the updateCard method? Also the main bit for me is how do I store or pass content of an existing card.
            – Akhil
            Nov 14 at 7:13










          • Akhil, the code has updateCard method . Moreover, I could not find any straight forward way to do this, rather than redrawing the old card again, while doing an update. In order to persist the state of the old card , pass the state of the card to the new card through setParameters method. If CardService allows us the pass the Card as a parameter, we would not have to do this.
            – Hari Balaji
            Nov 14 at 7:16












          • If I have to redraw the whole conversation then first I need to store them separately and recreate the card each time. setParameters doesn't work as well. Have tried that too.
            – Akhil
            Nov 14 at 7:32


















          • Yes! Exactly what I'm trying to achieve. But I haven't come across a code sample or a skeleton. Is it possible for you to share a sample?
            – Akhil
            Nov 13 at 6:44










          • I've added based on your request.
            – Hari Balaji
            Nov 13 at 13:40










          • Doesn't this code work also without the updateCard method? Also the main bit for me is how do I store or pass content of an existing card.
            – Akhil
            Nov 14 at 7:13










          • Akhil, the code has updateCard method . Moreover, I could not find any straight forward way to do this, rather than redrawing the old card again, while doing an update. In order to persist the state of the old card , pass the state of the card to the new card through setParameters method. If CardService allows us the pass the Card as a parameter, we would not have to do this.
            – Hari Balaji
            Nov 14 at 7:16












          • If I have to redraw the whole conversation then first I need to store them separately and recreate the card each time. setParameters doesn't work as well. Have tried that too.
            – Akhil
            Nov 14 at 7:32
















          Yes! Exactly what I'm trying to achieve. But I haven't come across a code sample or a skeleton. Is it possible for you to share a sample?
          – Akhil
          Nov 13 at 6:44




          Yes! Exactly what I'm trying to achieve. But I haven't come across a code sample or a skeleton. Is it possible for you to share a sample?
          – Akhil
          Nov 13 at 6:44












          I've added based on your request.
          – Hari Balaji
          Nov 13 at 13:40




          I've added based on your request.
          – Hari Balaji
          Nov 13 at 13:40












          Doesn't this code work also without the updateCard method? Also the main bit for me is how do I store or pass content of an existing card.
          – Akhil
          Nov 14 at 7:13




          Doesn't this code work also without the updateCard method? Also the main bit for me is how do I store or pass content of an existing card.
          – Akhil
          Nov 14 at 7:13












          Akhil, the code has updateCard method . Moreover, I could not find any straight forward way to do this, rather than redrawing the old card again, while doing an update. In order to persist the state of the old card , pass the state of the card to the new card through setParameters method. If CardService allows us the pass the Card as a parameter, we would not have to do this.
          – Hari Balaji
          Nov 14 at 7:16






          Akhil, the code has updateCard method . Moreover, I could not find any straight forward way to do this, rather than redrawing the old card again, while doing an update. In order to persist the state of the old card , pass the state of the card to the new card through setParameters method. If CardService allows us the pass the Card as a parameter, we would not have to do this.
          – Hari Balaji
          Nov 14 at 7:16














          If I have to redraw the whole conversation then first I need to store them separately and recreate the card each time. setParameters doesn't work as well. Have tried that too.
          – Akhil
          Nov 14 at 7:32




          If I have to redraw the whole conversation then first I need to store them separately and recreate the card each time. setParameters doesn't work as well. Have tried that too.
          – Akhil
          Nov 14 at 7:32


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257853%2fhow-can-i-add-new-sections-to-an-existing-card-on-gmail-addon%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python