ποΈ Best practices for prompting AI to build integrations
Learn 4 best practices for prompting AI to build integrations
Hey friends,
Today, I'll discuss best practices for crafting prompts to build integrations, drawing heavily on OpenAI's guidelines. Incorporating AI into my development workflow has cut my development workflow down by two-thirds and for the most part I use regular old ChatGPT and the below guidelines.
So with that said, letβs go over some best practices so you too can speed up your time to develop all sorts of integrations π
1. Be specific
I've found that detailed prompts lead to better results. To improve my prompts, I often consult the documentation. It's important because even familiar models might not be up-to-date with the latest API changes, which happen frequently.
Less effective β
Generate code for sending emails
Better β
Create a Node.js request to send an email via SendGrid's API,
adhering to the example request format. Only use the specified parameters below.
Parameters###
##
Example request format ###
###
2. Cut the fluff
The second best practice is to cut the fluff. Iβve learned that AI models perform best when instructed without unnecessary words or context.
Less effective β
Can you please create a Node.js script to add new contacts to my HubSpot CRM.Here's some more information. Thanks so much for your help!
Better β
Create a Node.js request to send an email via SendGrid's API,
adhering to the example request format. Only use the specified parameters below.
Parameters###
##
Example request format ###
###
3. Separate context and instruction with delimiters
Keeping instructions and context separate in your prompt helps keep things clear and organized.
Especially for multi-step tasks, I often use one set of instructions and then switch the context for different prompts. This way, I can easily generate different parts of code while having the same rules.
Less effective β:
Create a Node.js request to charge a payment using Stripe's API. It should be for $1000
and have a description "payment for services".
Also here's a format that you can model the request after from Stripe's documentation
const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
const paymentIntent = await stripe.paymentIntents.create({
amount: 2000,
currency: 'usd',
automatic_payment_methods: {
enabled: true,
},
});
Better β :
Create a Node.js request to charge a payment using Stripe's API. Adhere to the example request format. Only use the specified parameters below.
Parameters ###:
- amount: 1000
- currency: usd
- description: payment for services
###
Example request format ###:
const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
const paymentIntent = await stripe.paymentIntents.create({
amount: 2000,
currency: 'usd',
automatic_payment_methods: {
enabled: true,
},
});
###
4. Request explanations
My favorite practice is to ask for explanations of the code generated and how it meets my instructions. This helps me understand the output in plain English and often leads to better results, as it gives the model a chance to 'think.
Less effective β:
Create a Node.js script to create a new video room. Adhere to the example request format. Only use the specified parameters below.
Better β
:
Create a Node.js script to create a new video room. Adhere to the example request format. Only use the specified parameters below. Explain the generated code, and how it fulfills the provided instruction
That's all! Writing good prompts is much like good communication.
I'd love to know if you use AI for integrations or other software, and what your practices are.
Feel free to share!
Lola