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












0














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





























    0














    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



























      0












      0








      0







      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 '18 at 23:06









      Kara

      3,935104152




      3,935104152










      asked Nov 12 '18 at 7:52









      Akhil

      32




      32
























          1 Answer
          1






          active

          oldest

          votes


















          0














          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 '18 at 6:44










          • I've added based on your request.
            – Hari Balaji
            Nov 13 '18 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 '18 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 '18 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 '18 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',
          autoActivateHeartbeat: false,
          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









          0














          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 '18 at 6:44










          • I've added based on your request.
            – Hari Balaji
            Nov 13 '18 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 '18 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 '18 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 '18 at 7:32
















          0














          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 '18 at 6:44










          • I've added based on your request.
            – Hari Balaji
            Nov 13 '18 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 '18 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 '18 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 '18 at 7:32














          0












          0








          0






          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 '18 at 13:37

























          answered Nov 12 '18 at 12:22









          Hari Balaji

          29815




          29815












          • 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 '18 at 6:44










          • I've added based on your request.
            – Hari Balaji
            Nov 13 '18 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 '18 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 '18 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 '18 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 '18 at 6:44










          • I've added based on your request.
            – Hari Balaji
            Nov 13 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 6:44












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




          I've added based on your request.
          – Hari Balaji
          Nov 13 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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

          Full-time equivalent

          さくらももこ

          13 indicted, 8 arrested in Calif. drug cartel investigation