langchain/docs/modules/agents/tools/examples/ifttt.ipynb
Harrison Chase 705431aecc
big docs refactor (#1978)
Co-authored-by: Ankush Gola <ankush.gola@gmail.com>
2023-03-26 19:49:46 -07:00

122 lines
3.6 KiB
Plaintext

{
"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",
"## Creating a webhook\n",
"- Go to https://ifttt.com/create\n",
"\n",
"## Configuring the \"If This\"\n",
"- 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",
"## Configuring the \"Then That\"\n",
"- 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",
"## Finishing up\n",
"- 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
}