2023-02-23 06:29:43 +00:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"id": "16763ed3",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"# IFTTT WebHooks\n",
|
|
|
|
"\n",
|
|
|
|
"This notebook shows how to use IFTTT Webhooks.\n",
|
|
|
|
"\n",
|
|
|
|
"From https://github.com/SidU/teams-langchain-js/wiki/Connecting-IFTTT-Services.\n",
|
|
|
|
"\n",
|
2023-03-27 02:49:46 +00:00
|
|
|
"## Creating a webhook\n",
|
2023-02-23 06:29:43 +00:00
|
|
|
"- Go to https://ifttt.com/create\n",
|
|
|
|
"\n",
|
2023-03-27 02:49:46 +00:00
|
|
|
"## Configuring the \"If This\"\n",
|
2023-02-23 06:29:43 +00:00
|
|
|
"- Click on the \"If This\" button in the IFTTT interface.\n",
|
|
|
|
"- Search for \"Webhooks\" in the search bar.\n",
|
|
|
|
"- Choose the first option for \"Receive a web request with a JSON payload.\"\n",
|
|
|
|
"- Choose an Event Name that is specific to the service you plan to connect to.\n",
|
|
|
|
"This will make it easier for you to manage the webhook URL.\n",
|
|
|
|
"For example, if you're connecting to Spotify, you could use \"Spotify\" as your\n",
|
|
|
|
"Event Name.\n",
|
|
|
|
"- Click the \"Create Trigger\" button to save your settings and create your webhook.\n",
|
|
|
|
"\n",
|
2023-03-27 02:49:46 +00:00
|
|
|
"## Configuring the \"Then That\"\n",
|
2023-02-23 06:29:43 +00:00
|
|
|
"- Tap on the \"Then That\" button in the IFTTT interface.\n",
|
|
|
|
"- Search for the service you want to connect, such as Spotify.\n",
|
|
|
|
"- Choose an action from the service, such as \"Add track to a playlist\".\n",
|
|
|
|
"- Configure the action by specifying the necessary details, such as the playlist name,\n",
|
|
|
|
"e.g., \"Songs from AI\".\n",
|
|
|
|
"- Reference the JSON Payload received by the Webhook in your action. For the Spotify\n",
|
|
|
|
"scenario, choose \"{{JsonPayload}}\" as your search query.\n",
|
|
|
|
"- Tap the \"Create Action\" button to save your action settings.\n",
|
|
|
|
"- Once you have finished configuring your action, click the \"Finish\" button to\n",
|
|
|
|
"complete the setup.\n",
|
|
|
|
"- Congratulations! You have successfully connected the Webhook to the desired\n",
|
|
|
|
"service, and you're ready to start receiving data and triggering actions 🎉\n",
|
|
|
|
"\n",
|
2023-03-27 02:49:46 +00:00
|
|
|
"## Finishing up\n",
|
2023-02-23 06:29:43 +00:00
|
|
|
"- To get your webhook URL go to https://ifttt.com/maker_webhooks/settings\n",
|
|
|
|
"- Copy the IFTTT key value from there. The URL is of the form\n",
|
|
|
|
"https://maker.ifttt.com/use/YOUR_IFTTT_KEY. Grab the YOUR_IFTTT_KEY value.\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 1,
|
|
|
|
"id": "10a46e7e",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"from langchain.tools.ifttt import IFTTTWebhook"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 2,
|
|
|
|
"id": "12003d72",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"import os\n",
|
|
|
|
"key = os.environ[\"IFTTTKey\"]\n",
|
|
|
|
"url = f\"https://maker.ifttt.com/trigger/spotify/json/with/key/{key}\"\n",
|
|
|
|
"tool = IFTTTWebhook(name=\"Spotify\", description=\"Add a song to spotify playlist\", url=url)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 3,
|
|
|
|
"id": "6e68f846",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"\"Congratulations! You've fired the spotify JSON event\""
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 3,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"tool.run(\"taylor swift\")"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"id": "a7e599c9",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
|
|
|
"display_name": "Python 3 (ipykernel)",
|
|
|
|
"language": "python",
|
|
|
|
"name": "python3"
|
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"codemirror_mode": {
|
|
|
|
"name": "ipython",
|
|
|
|
"version": 3
|
|
|
|
},
|
|
|
|
"file_extension": ".py",
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
"name": "python",
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
"pygments_lexer": "ipython3",
|
|
|
|
"version": "3.9.1"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 5
|
|
|
|
}
|