├── README.md └── langchainXzapier.ipynb /README.md: -------------------------------------------------------------------------------- 1 | # Zapier-Langchain-AI-agent 2 | Using OpenAI or other LLMs via Langchain to connect that intelligence to Zapier which can access virtually every app, you might want to automate 3 | 4 | Open the .ipynb file with colab to play with it 5 | 6 | ![Screenshot 2023-06-08 005444](https://github.com/K-Jadeja/Zapier-Langchain-AI-agent/assets/113630783/f7e2378e-6088-4d52-b245-bbe8046d5603) 7 | 8 | You need two keys 9 | 10 | • OpenAI Key (GPT 3.5 turbo works) 11 | 12 | • Zapier NLA Key 13 | 14 | Use this to get the Zapier key and set up tools for your agent to access https://zapier.com/l/natural-language-actions 15 | 16 | Ask me anything https://twitter.com/krsnalyst 17 | -------------------------------------------------------------------------------- /langchainXzapier.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "authorship_tag": "ABX9TyMXVNKw8zpGGsaP6sJX51S5", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "metadata": { 22 | "id": "view-in-github", 23 | "colab_type": "text" 24 | }, 25 | "source": [ 26 | "\"Open" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "source": [ 32 | "!pip install langchain\n", 33 | "!pip install openai" 34 | ], 35 | "metadata": { 36 | "id": "DrTQCQ-K5sdM" 37 | }, 38 | "execution_count": null, 39 | "outputs": [] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": 3, 44 | "metadata": { 45 | "id": "Avu4A-Tw4WDM" 46 | }, 47 | "outputs": [], 48 | "source": [ 49 | "import os\n", 50 | "from langchain.llms import OpenAI\n", 51 | "from langchain.agents import initialize_agent\n", 52 | "from langchain.agents.agent_toolkits import ZapierToolkit\n", 53 | "from langchain.utilities.zapier import ZapierNLAWrapper" 54 | ] 55 | }, 56 | { 57 | "cell_type": "markdown", 58 | "source": [ 59 | "Get your Zapier key form https://zapier.com/l/natural-language-actions" 60 | ], 61 | "metadata": { 62 | "id": "_Ka2cH67Qjmb" 63 | } 64 | }, 65 | { 66 | "cell_type": "code", 67 | "source": [ 68 | "os.environ[\"OPENAI_API_KEY\"] = \"YOUR_OPEN_API_KEY\"\n", 69 | "os.environ[\"ZAPIER_NLA_API_KEY\"] = \"YOUR_ZAPIER_API_KEY\"" 70 | ], 71 | "metadata": { 72 | "id": "6JhSPbTF4Zi1" 73 | }, 74 | "execution_count": 4, 75 | "outputs": [] 76 | }, 77 | { 78 | "cell_type": "markdown", 79 | "source": [ 80 | "You can also import ConversationalBufferMemory from langchain so it remembers what you said before\n", 81 | "\n", 82 | "• Keep the temperature low\n", 83 | "\n", 84 | "• ZERO_SHOT_REACT_DESCRIPTION - An agent type that uses ReAct framework to determine which tool to use based solely on the tool’s description. Any number of tools can be provided.\n", 85 | "\n", 86 | "• Verbose=True gives us a peak into the agent's thought process" 87 | ], 88 | "metadata": { 89 | "id": "ztm1_dUXIbUg" 90 | } 91 | }, 92 | { 93 | "cell_type": "code", 94 | "source": [ 95 | "llm = OpenAI(temperature=0)\n", 96 | "zapier = ZapierNLAWrapper()\n", 97 | "toolkit = ZapierToolkit.from_zapier_nla_wrapper(zapier)\n", 98 | "agent = initialize_agent(toolkit.get_tools(), llm, agent=\"zero-shot-react-description\", verbose=True)" 99 | ], 100 | "metadata": { 101 | "id": "hi-EqHRF4uQy" 102 | }, 103 | "execution_count": 5, 104 | "outputs": [] 105 | }, 106 | { 107 | "cell_type": "markdown", 108 | "source": [ 109 | "The code below let's us see all the tools we added from zapier and their descriptions" 110 | ], 111 | "metadata": { 112 | "id": "FN8H7E0hKD0e" 113 | } 114 | }, 115 | { 116 | "cell_type": "code", 117 | "source": [ 118 | "for tool in toolkit.get_tools():\n", 119 | " print (tool.name)\n", 120 | " print (tool.description)\n", 121 | " print (\"\\n\\n\")" 122 | ], 123 | "metadata": { 124 | "id": "5AwrYj-i4tn0" 125 | }, 126 | "execution_count": null, 127 | "outputs": [] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "source": [ 132 | "agent.run(\"Get the last email I received from Adrian. Create a draft email in gmail back to him giving some key insights\")" 133 | ], 134 | "metadata": { 135 | "id": "79zm-uj_4uXF" 136 | }, 137 | "execution_count": null, 138 | "outputs": [] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "source": [ 143 | "agent.run(\"Send an Email to Adrian@conyx.ai via gmail that is a pitch for why he should visit https://conyx.ai to help his small business integrate autonomous agent services today. Provide a hyperlink to the website and make the email likely to convert to website visitors.\")" 144 | ], 145 | "metadata": { 146 | "id": "N_zVUAXK5CR5" 147 | }, 148 | "execution_count": null, 149 | "outputs": [] 150 | } 151 | ] 152 | } --------------------------------------------------------------------------------