How to Integrate an AI Chatbot with Web Search Access into Trello Using Pipedream?

This topic was automatically generated from Slack. You can find the original thread here.

Hey:wave: I’m in search of an AI chatbot with web search engine access similar to BingChat and Perplexity. Specifically, I need one that can integrate with tools like Pipedream. My goal is to have web search abilities right in Trello. :desktop_computer:

I’d like to be able to use ChatGPT in the comments/descriptions of Trello cards! If you know how to achieve a workflow from Trello to Pipedream to a language model accessing web search engines like Bing or Google, then back to Trello, I’d really appreciate the info.

Workflow: Trello> Pipedream> Language Model Web search access (Bing, Google Search) Processing > Trello.
Thanks in advance! :pray:

Hey:wave: I’m in search of an AI chatbot with web search engine access similar to BingChat and Perplexity. Specifically, I need one that can integrate with tools like Pipedream. My goal is to have web search abilities right in Trello. :desktop_computer:

I’d like to be able to use ChatGPT in the comments/descriptions of Trello cards! If you know how to achieve a workflow from Trello to Pipedream to a language model accessing web search engines like Bing or Google, then back to Trello, I’d really appreciate the info.

Workflow: Trello> Pipedream> Language Model Web search access (Bing, Google Search) Processing > Trello.
Thanks in advance! :pray:

To achieve the workflow you described, you can follow these steps: 1. Set up a Trello trigger in Pipedream, such as “New Comment” or “New Card”, depending on your use case. 2. Use a code step in Pipedream to call the ChatGPT API with web search engine access (e.g., Bing or Google). You’ll need to use the axios package to make the API request. 3. Process the response from the ChatGPT API and extract the relevant information. 4. Use a Trello action in Pipedream, such as “Add Comment to Card” or “Update Card Description”, to send the processed information back to Trello. Here’s an example of a Pipedream code step that calls the ChatGPT API (replace YOUR_API_KEY with your actual API key and adjust the API request as needed): ```
import { axios } from “@pipedream/platform”; export default defineComponent({ async run({ steps, $ }) { const apiKey = “YOUR_API_KEY”; const query = steps.trigger.event.comment.text; // Adjust this based on the Trello trigger you use const response = await axios($, { method: “POST”, url: “https://api.openai.com/v1/engines/davinci-codex/completions”, // Replace with the ChatGPT API URL headers: { “Content-Type”: “application/json”, “Authorization”: Bearer ${apiKey}, }, data: { prompt: query, // Add other parameters as needed }, }); return response; }, });

Does this all look correct below?

Trigger on a new comment or card in Trello (depending on your setup).
Execute a search using the Google Search API.
Pass the search results to ChatGPT for further processing.
Return the ChatGPT response, which can then be sent to Trello in a subsequent step

Code:
import { axios } from “@pipedream/platform”;

export default defineComponent({
async run({ steps, $ }) {
// Replace with your actual API keys
const googleApiKey = “YOUR_GOOGLE_API_KEY”;
const chatGptApiKey = “YOUR_CHATGPT_API_KEY”;

// Adjust this based on the Trello trigger you use
const query = steps.trigger.event.comment.text;

// Google Search API call
const searchResponse = await axios($, {
  method: "GET",
  url: "[https://www.googleapis.com/customsearch/v1](https://www.googleapis.com/customsearch/v1)",
  params: {
    key: googleApiKey,
    q: query,
    // Add other parameters as needed
  },
});

// Extracting search results
const searchResults = searchResponse.data.items.map(item => [item.link](http://item.link)).join('\n');

// ChatGPT API call with search results
const chatGptResponse = await axios($, {
  method: "POST",
  url: "[https://api.openai.com/v1/engines/davinci-codex/completions](https://api.openai.com/v1/engines/davinci-codex/completions)",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${chatGptApiKey}`,
  },
  data: {
    prompt: `Search results for ${query}:\n${searchResults}\n`,
    // Add other parameters as needed
  },
});

return chatGptResponse;

},
});

Yes, your code looks mostly correct. It triggers on a new comment or card in Trello, executes a search using the Google Search API, passes the search results to ChatGPT for further processing, and returns the ChatGPT response, which can then be sent to Trello in a subsequent step. However, there’s a small issue with the search results extraction line. You should replace the > with >: ```
const searchResults = searchResponse.data.items.map(item => item.link).join(‘\n’);

Please provide the full complete revision with your modifications.

Here’s the revised code with the modification: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ async run({ steps, $ }) { // Replace with your actual API keys const googleApiKey = “YOUR_GOOGLE_API_KEY”; const chatGptApiKey = “YOUR_CHATGPT_API_KEY”; // Adjust this based on the Trello trigger you use const query = steps.trigger.event.comment.text; // Google Search API call const searchResponse = await axios($, { method: “GET”, url: “https://www.googleapis.com/customsearch/v1”, params: { key: googleApiKey, q: query, // Add other parameters as needed }, }); // Extracting search results const searchResults = searchResponse.data.items.map(item => item.link).join(‘\n’); // ChatGPT API call with search results const chatGptResponse = await axios($, { method: “POST”, url: “https://api.openai.com/v1/engines/davinci-codex/completions”, headers: { “Content-Type”: “application/json”, “Authorization”: Bearer ${chatGptApiKey}, }, data: { prompt: Search results for ${query}:\n${searchResults}\n, // Add other parameters as needed }, }); return chatGptResponse; }, });

Can I replace Unito with Pipedream for a deep two integration sync using code?

Yes, you can use Pipedream to create deep integrations between two apps by writing custom code in Pipedream workflows. To achieve this, you’ll need to: 1. Set up a trigger for the workflow (e.g., an event from App A, an HTTP trigger, or a scheduled trigger). 2. Use actions or custom code steps to interact with the APIs of both App A and App B. 3. Process and transform the data as needed. 4. Send the processed data to the destination app (App B). To get started, you’ll need to understand the APIs of both apps you want to integrate and use Pipedream’s built-in actions or write custom code to interact with those APIs. If you need help with specific app integrations, please provide more details about the apps and the desired sync functionality.

what else should I add to this code to achieve my goal in pipedream?

Goal:
Hey:wave: I’m in search of an AI chatbot with web search engine access similar to BingChat and Perplexity. Specifically, I need one that can integrate with tools like Pipedream. My goal is to have web search abilities right in Trello. :desktop_computer:

I’d like to be able to use ChatGPT in the comments/descriptions of Trello cards! If you know how to achieve a workflow from Trello to Pipedream to a language model accessing web search engines like Bing or Google, then back to Trello, I’d really appreciate the info.

Workflow: Trello> Pipedream> Language Model Web search access (Bing, Google Search) Processing > Trello.
Thanks in advance! :pray:

Code:
import { axios } from “@pipedream/platform”;

export default defineComponent({
async run({ steps, $ }) {
// Replace with your actual API keys
const googleApiKey = “YOUR_GOOGLE_API_KEY”;
const chatGptApiKey = “YOUR_CHATGPT_API_KEY”;

// Adjust this based on the Trello trigger you use
const query = steps.trigger.event.comment.text;

// Google Search API call
const searchResponse = await axios($, {
  method: "GET",
  url: "[https://www.googleapis.com/customsearch/v1](https://www.googleapis.com/customsearch/v1)",
  params: {
    key: googleApiKey,
    q: query,
    // Add other parameters as needed
  },
});

// Extracting search results
const searchResults = searchResponse.data.items.map(item => [item.link](http://item.link)).join('\n');

// ChatGPT API call with search results
const chatGptResponse = await axios($, {
  method: "POST",
  url: "[https://api.openai.com/v1/engines/davinci-codex/completions](https://api.openai.com/v1/engines/davinci-codex/completions)",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${chatGptApiKey}`,
  },
  data: {
    prompt: `Search results for ${query}:\n${searchResults}\n`,
    // Add other parameters as needed
  },
});

return chatGptResponse;

},
});

To achieve your goal of integrating Trello, Pipedream, a language model with web search access, and then back to Trello, you’ll need to modify the code to include a Trello trigger and update the Trello card with the ChatGPT response. Here’s an updated version of your code: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ async run({ steps, $ }) { // Replace with your actual API keys const googleApiKey = “YOUR_GOOGLE_API_KEY”; const chatGptApiKey = “YOUR_CHATGPT_API_KEY”; const trelloApiKey = “YOUR_TRELLO_API_KEY”; const trelloApiToken = “YOUR_TRELLO_API_TOKEN”; // Adjust this based on the Trello trigger you use const query = steps.trigger.event.comment.text; const cardId = steps.trigger.event.comment.card.id; // Google Search API call const searchResponse = await axios($, { method: “GET”, url: “https://www.googleapis.com/customsearch/v1”, params: { key: googleApiKey, q: query, // Add other parameters as needed }, }); // Extracting search results const searchResults = searchResponse.data.items.map(item => item.link).join(‘\n’); // ChatGPT API call with search results const chatGptResponse = await axios($, { method: “POST”, url: “https://api.openai.com/v1/engines/davinci-codex/completions”, headers: { “Content-Type”: “application/json”, “Authorization”: Bearer ${chatGptApiKey}, }, data: { prompt: Search results for ${query}:\n${searchResults}\n, // Add other parameters as needed }, }); // Update Trello card with ChatGPT response const chatGptResult = chatGptResponse.data.choices[0].text; await axios($, { method: “PUT”, url: https://api.trello.com/1/cards/${cardId}, params: { key: trelloApiKey, token: trelloApiToken, desc: chatGptResult, }, }); return chatGptResult; }, });