-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an ifttt webhook tool #114
Open
aitoehigie
wants to merge
1
commit into
Forethought-Technologies:main
Choose a base branch
from
aitoehigie:IFTTTWebhook
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
"""From https://github.com/SidU/teams-langchain-js/wiki/Connecting-IFTTT-Services. | ||
|
||
# Creating a webhook | ||
- Go to https://ifttt.com/create | ||
|
||
# Configuring the "If This" | ||
- Click on the "If This" button in the IFTTT interface. | ||
- Search for "Webhooks" in the search bar. | ||
- Choose the first option for "Receive a web request with a JSON payload." | ||
- 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. | ||
- Click the "Create Trigger" button to save your settings and create your webhook. | ||
|
||
# Configuring the "Then That" | ||
- Tap on the "Then That" button in the IFTTT interface. | ||
- Search for the service you want to connect, such as Spotify. | ||
- Choose an action from the service, such as "Add track to a playlist". | ||
- Configure the action by specifying the necessary details, such as the playlist name, | ||
e.g., "Songs from AI". | ||
- Reference the JSON Payload received by the Webhook in your action. For the Spotify | ||
scenario, choose "{{JsonPayload}}" as your search query. | ||
- Tap the "Create Action" button to save your action settings. | ||
- 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 | ||
- To get your webhook URL go to https://ifttt.com/maker_webhooks/settings | ||
- 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. | ||
""" | ||
|
||
|
||
from typing import Any | ||
|
||
from autochain.tools.base import Tool | ||
|
||
import requests | ||
|
||
|
||
class IFTTTWebhook(Tool): | ||
"""IFTTT Webhook. | ||
|
||
Args: | ||
name: name of the tool | ||
description: description of the tool | ||
url: url to hit with the json event. | ||
""" | ||
|
||
name = "IFTTT Webhook" | ||
description = "Tool for connecting IFTTT services" | ||
url: str | ||
|
||
def _run(self, input_data:str) -> str: | ||
body = {"this": input_data} | ||
response = requests.post(self.url, data=body) | ||
return response.text |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is different from sending any web request? ideally each tool should have a specific purpose and served as example for how to add new tools easily, while not trying to be comprehensive