Generate new topics, posts and PM via IFTTT


(Vinoth Kannan) #1

Want to use IFTTT to create new topics, posts and private messages? Let’s get started!

Using Maker Webhooks of IFTTT service we can make Discourse API calls. For that we must generate API keys first. It can be generated using the API admin tab.

Also we can generate user specific API keys through user admin pages.

Now create new applet on IFTTT and then choose your favorite trigger service. Now I am using Google Calendar service for example.

Then I am choosing Any new event added trigger.

To connect your trigger with Discourse choose Maker Webhooks as action service and Make a web request action.

Now fill the action fields as below.

  • URL (required): https://discourse.example.com/posts/?api_key=[YOUR_API_KEY]&api_username=[API_USERNAME]

  • Method (required): POST

  • Content Type: application/json

  • Body:

{
 "title": "{{Title}}",
 "raw": "{{Description}}\n\nPlace: {{Where}}\nAt: {{Starts}} - {{Ends}}",
 "category": 4,
 "created_at": "{{CreatedAt}}"
}

In body text you can see many fields with double brackets {{ }}. Those fields (content sources) will vary with every service triggers. Choose it from Ingredient button below.

You can edit title and raw fields in JSON body however you need with surrounded texts. Find category id from your site’s /site.json URL and put it on category field. Now click Create action button to create the applet. After the applet creation it may take some time to be live.

It’s done :sunglasses:. Now a new topic will be created whenever a new event created on your Google Calendar :calendar_spiral:.


To create a post reply to an existing topic instead of new topic creation the body text should be changed as below (topic_id instead of category)

{
 "title": "{{Title}}",
 "raw": "{{Description}}\n\nPlace: {{Where}}\nAt: {{Starts}} - {{Ends}}",
 "topic_id": 4,
 "created_at": "{{CreatedAt}}"
}

To create new private message

{
 "title": "{{Title}}",
 "raw": "{{Description}}\n\nPlace: {{Where}}\nAt: {{Starts}} - {{Ends}}",
 "target_usernames": "discourse1,discourse2",
 "archetype": "private_message",
 "created_at": "{{CreatedAt}}"
}

In this same method you can make Discourse API requests by any other IFTTT action services.


Create automate Topics from Youtube Video?