Skip to content

Connecting IFTTT Services

Sid Uppal edited this page Feb 22, 2023 · 4 revisions

Creating a webhook

  1. Go to https://ifttt.com/create

Configuring the "If This"

  1. Click on the "If This" button in the IFTTT interface.
  2. Search for "Webhooks" in the search bar.
  3. Choose the first option for "Receive a web request with a JSON payload."
  4. Choose an Event Name that is specific to the service you plan to connect to. This will make it easier for you to manage the webhook URL. For example, if you're connecting to Spotify, you could use "Spotify" as your Event Name.
  5. Click the "Create Trigger" button to save your settings and create your webhook.

Configuring the "Then That"

  1. Tap on the "Then That" button in the IFTTT interface.
  2. Search for the service you want to connect, such as Spotify.
  3. Choose an action from the service, such as "Add track to a playlist".
  4. Configure the action by specifying the necessary details, such as the playlist name, e.g., "Songs from AI".
  5. Reference the JSON Payload received by the Webhook in your action. For the Spotify scenario, choose "{{JsonPayload}}" as your search query.
  6. Tap the "Create Action" button to save your action settings.
  7. Once you have finished configuring your action, click the "Finish" button to complete the setup.

Congratulations! You have successfully connected the Webhook to the desired service, and you're ready to start receiving data and triggering actions 🎉

Finishing up

  1. To get your webhook URL go to https://ifttt.com/maker_webhooks/settings
  2. Copy the IFTTT key value from there. The URL is of the form https://maker.ifttt.com/use/YOUR_IFTTT_KEY. Grab the YOUR_IFTTT_KEY value.

Connecting the IFTTT Webhook to LangChain

In your code where you initialize the agent, instantiate the IFTTTWebhook tool as follows:

new IFTTTWebhook(`https://maker.ifttt.com/trigger/spotify/json/with/key/${process.env.IFTTTKey}`, 'Spotify', 'Play a song on Spotity.')

Here, "spotify" in the URL matches the name you chose in step 5 above, and the description matches how you want LangChain to use this tool. In the example here, we want LangChain to use this IFTTTWebhook instance when it needs to play a song on Spotify so that's what we use for the description.

Make sure to save the IFTTT key in your .env file.

IFTTTKey=<YOUR_IFTTT_KEY>

What next?

You can use this approach to connect LangChain to your smart-lights, your Roomba, garage door, Twitter, Trello, OneDrive, email, whatever.