Skip to content

#621 Added streamId and formMessageId to FormReplyActivity#622

Merged
thibauult merged 3 commits intofinos:mainfrom
thibauult:#621/FormReplyContext
Jan 11, 2022
Merged

#621 Added streamId and formMessageId to FormReplyActivity#622
thibauult merged 3 commits intofinos:mainfrom
thibauult:#621/FormReplyContext

Conversation

@thibauult
Copy link
Copy Markdown
Member

Closes #621

2 new fields added to the FormReplyActivity class:

  • streamId
  • formMessageId

@thibauult thibauult merged commit 4155cc4 into finos:main Jan 11, 2022
@thibauult thibauult deleted the #621/FormReplyContext branch January 11, 2022 13:41
@ystxn
Copy link
Copy Markdown
Member

ystxn commented Jan 11, 2022

@symphony-thibault Sorry there seems to be some confusion here: formMessageId isn't the same as messageId. To suppress or update the message containing the form that triggered the SYMPHONYELEMENTSACTION event, we will need the top-level messageId rather than symphonyElementsAction.formMessageId.

https://docs.developers.symphony.com/building-bots-on-symphony/datafeed/real-time-events#symphony-elements-action

@thibauult
Copy link
Copy Markdown
Member Author

Hi @ystan-,

To me what has been done in this PR is correct and resolve the problem:

Using FormReplyActivity to capture Elements form submissions currently does not provide the Message ID from the originating form. This blocks workflows attempting to either suppress or update the message containing the form that was just submitted.

The top-level messageId from the symphony-elements-action payload corresponds to the formReply messageId (that is hidden in the chat).

The following example shows that what is needed to update the original form is the formMesssageId field and not the formReply messageId:

@Slf4j
public class Example {

  private static final String FORM = "<messageML>\n"
      + "  <form id=\"the-form\">\n"
      + "    <text-field name=\"name\" placeholder=\"Input your name...\" required=\"true\"/>\n"
      + "    <button name=\"send-answers\" type=\"action\">Send Answers</button>\n"
      + "  </form>\n"
      + "</messageML>";

  public static void main(String[] args) throws Exception {

    final SymphonyBdk bdk = new SymphonyBdk(loadFromSymphonyDir("config.yaml"));

    bdk.activities().register(slash("/form", false, c -> {
      V4Message msg = bdk.messages().send(c.getStreamId(), FORM);
      log.info("Message sent: {}", msg.getMessageId());
    }));

    bdk.datafeed().subscribe(new RealTimeEventListener() {

      @Override
      public void onSymphonyElementsAction(V4Initiator initiator, V4SymphonyElementsAction event) throws EventException {
        log.info("Form reply received: {}", event.getFormMessageId());
      }
    });

    bdk.datafeed().start();
  }
}

with output:

16:00:21.015 [main] Vxs9UV INFO  c.s.bdk.examples.Example - Message sent: Tud9Lauq2CeBSLDzqXVWRn___oG2WIGcbQ
16:00:55.691 [main] Lwd6zZ INFO  c.s.bdk.examples.Example - Form reply received: Tud9Lauq2CeBSLDzqXVWRn___oG2WIGcbQ

We indeed decided to call this field formMessageId to avoid any confusion with the formReply messageId.

Please let me know if it helps 👍

@ystxn
Copy link
Copy Markdown
Member

ystxn commented Jan 11, 2022

Apologies - you're right. This works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Message ID and Stream ID to FormReplyActivity's FormReplyContext

5 participants