Using the Discourse API with Front App

Hey there folks! I’m currently working on an integration with the Front App and Discourse. As of now, I’m using Pipedream to connect them together.

I managed to set up two workflows:

  1. Discourse → Front App. When a new message is received on Discourse, it posts that message into Front.
  2. Front → Discourse. When I reply to that imported Discourse message on Front, a webhook by Pipedream that listens for new replies on Front, then using the Discourse API to post the reply on Discourse. This works great, however, when I go on Front, it shows my response (as it triggers workflow 1 i.e. when a new message is received on Discourse) I now have two messages in the inbox thread, the one I sent via Front and the same one but imported from workflow 1.

Does anyone have an idea how to “exclude” these messages sent from Front that is pulled in from that first workflow? Is this possible with the Discourse API?

Thanks in advance!

5 Likes

Hey there :wave: , sounds like a neat integration you have going on.

I think to better help there are a couple questions I am thinking of.

  1. Are you you routing based on the creation of a Discourse PM (personal messages) or a New topic / Topic reply?

If routing on a new topic / topic reply…

  1. On your Discourse instance, are you routing any topic, or reply to a topic, to Front as a new message?

  2. When you reply to a message from front, are you using the API to send a reply to the original topic?

3 Likes

Hey Jordan!

Thanks for getting back to me. :blush:

To answer your questions:

  1. Yes, it is ANY topic or reply to a topic to Front.
  2. Once I reply from Front, it is sent from a URL (generated from Pipedream) that triggers the Discourse POST API to the original topic (it finds it via topic ID.)

Essentially, it’s…
I send a message reply to a person in Front.
Then the Discourse API (from Workflow 1) sees that there’s a new message in the forum so sends it as a new message on Front.

I don’t want the duplication.

I know this can get confusing, so let me know if I didn’t explain that very well. :sweat_smile: Any pointers would be super helpful!

2 Likes

So, is it safe to say you will only want a Discourse topic pushed as a message to Front on initial creation, and after that, never again?

Am I understanding this correctly?

  1. Topic created on discourse
    1a) Topic converted to Front as a message
  2. User replies to Front message
    2a) Front message is pushed to discourse as a reply to the created topic.

Will a Discourse user reply to 2a here? Or does the conversation stop after this point?

The reason I am asking is because you may look into checking for the post ID upon creation when coming from front. If Front triggered post id#345 to be created on Discourse

…then in your pipedream code that watches for and converts a Discourse post into a Front post, you can make sure that the Post Id is not be equal to the one you just created, if it is then do not convert into a Front message…

Is this possible in Pipedream? I am not familiar with that product.

4 Likes

Yes, Discourse users can still reply to 2a. We have this working! So when new Discourse messages are sent from community members, it automatically is added to the Front thread.

This screenshot may help illustrate better:

As you can see, I replied via Front “Just a test message from Front” and because that is posted to the Discourse, the Discourse API picks up the fact that it’s a new message and therefore sends a fresh message onto the thread.

Your reply has got me thinking :thinking: Maybe creating some sort of function that looks for an id from Front to then exclude it in the Discourse SEND MESSAGE API… I’ll give that a go. Appreciate the help! Thank you :blush:

4 Likes

Hey @jordan-vidrine, I just wanted to say thank you for the help! Talking it through with you through this thread gave me an idea and now it works. :sparkles: Specifically this part:

The reason I am asking is because you may look into checking for the post ID upon creation when coming from front. If Front triggered post id#345 to be created on Discourse

Cheers!

3 Likes

That’s awesome! Glad to know it is working out for you :+1:

1 Like