This workflow automates the process of analyzing a contract submitted via a web form. It extracts the text from an uploaded PDF, uses AI to identify potential red flags, and sends a summary report to a Telegram chat.
Prerequisites
Before you can use this workflow, you'll need a few things set up.
1. JotForm Form
You need to create a form in JotForm with at least two specific fields:
- Email Address: A standard field to collect the user's email.
- File Upload: This field will be used to upload the contract or NDA. Make sure to configure it to allow
.pdf
files.
2. API Keys and IDs
- JotForm API Key: You can generate this from your JotForm account settings under the "API" section.
- Gemini API Key: You'll need an API key from Google AI Studio to use the Gemini model.
- Telegram Bot Token: Create a new bot by talking to the
@BotFather
on Telegram. It will give you a unique token.
- Telegram Chat ID: This is the ID of the user, group, or channel you want the bot to send messages to. You can get this by using a bot like
@userinfobot
.
Node-by-Node Explanation
Here is a breakdown of what each node in the workflow does, in the order they execute.
1. JotForm Trigger
- What it does: This node kicks off the entire workflow. It actively listens for new submissions on the specific JotForm you select.
- How it works: When someone fills out your form and hits "Submit," JotForm sends the submission data (including the email and a link to the uploaded file) to this node.
2. Grab Attachment Details (HTTP Request)
- What it does: The initial data from JotForm doesn't contain a direct download link for the file. This node takes the
submissionID
from the trigger and makes a request to the JotForm API to get the full details of that submission.
- How it works: It constructs a URL using the
submissionID
and your JotForm API key to fetch the submission data, which includes the proper download URL for the uploaded contract.
3. Grab the Attached Contract (HTTP Request)
- What it does: Now that it has the direct download link, this node fetches the actual PDF file.
- How it works: It uses the file URL obtained from the previous node to download the contract. The node is set to expect a "file" as the response, so it saves the PDF data in binary format for the next step.
4. Extract Text from PDF File
- What it does: This node takes the binary PDF data from the previous step and extracts all the readable text from it.
- How it works: It processes the PDF and outputs plain text, stripping away any formatting or images. This raw text is now ready to be analyzed by the AI.
5. AI Agent (with Google Gemini Chat Model)
- What it does: This is the core analysis engine of the workflow. It takes the extracted text from the PDF and uses a powerful prompt to analyze it. The "Google Gemini Chat Model" node is connected as its "brain."
- How it works:
- It sends the contract text to the Gemini model.
- The prompt instructs Gemini to act as an expert contract analyst.
- It specifically asks the AI to identify major red flags and hidden/unfair clauses.
- It also tells the AI to format the output as a clean report using Telegram's MarkdownV2 style and to keep the response under 1500 characters.
6. Send a text message (Telegram)
- What it does: This is the final step. It takes the formatted analysis report generated by the AI Agent and sends it to your specified Telegram chat.
- How it works: It connects to your Telegram bot using your Bot Token and sends the AI's output (
$json.output
) to the Chat ID you've provided. Because the AI was instructed to format the text in MarkdownV2, the message will appear well-structured in Telegram with bolding and bullet points.