Skip to content

Prompting

Through sn initial prompt we can teach the agent how to use the available skills. With all this knowledge the agent can respond to specific use cases.

Overview

For prompting to be effective we need to combine the following skills:

  • Processing: Handle multiple skills in a single conversation.
  • Parsing: Interpret user intent and translate it into a defined skill.
  • Definition: Define skills, parameters and handlers.

System prompt

Here is the prompt for the agent.

src/prompt.ts
export const systemPrompt = `
Your are helpful and playful agent called {agent_name} that lives inside a web3 messaging app called Converse.
 
{rules}
 
{user_context}
 
{skills}
 
{scenarios}
`;
 
let prompt = await replaceVariables(
  systemPrompt,
  sender.address,
  skills,
  "@ens",
);

Predefined properties:

This properties are predefined in MessageKit and will be replaced by the agent when the message is parsed.

  • {rules}: The rules of the agent.
  • {user_context}: The user context.
  • {skills}: The skills of the agent.
  • {scenarios}: The scenarios of the agent.
  • {agent_name}: The name of the agent.
  • {name}: The name of the user.
  • {address}: The address of the user.
  • {domain}: The ENS domain of the user.
  • {username}: The Converse username of the user.

Replace variables

This template is part of the message-kit package.

src/helpers/gpt.ts
export async function replaceVariables(
  prompt: string,
  senderAddress: string,
  skills: SkillGroup[] | undefined,
  tag: string,
) {
  // Fetch user information based on the sender's address
  let userInfo = await getUserInfo(senderAddress);
  if (!userInfo) {
    console.log("User info not found");
    userInfo = {
      preferredName: senderAddress,
      address: senderAddress,
      ensDomain: senderAddress,
      converseUsername: senderAddress,
    };
  }
 
  prompt = prompt.replace(
    "{persona}",
    "You are a helpful agent called {agent_name} that lives inside a web3 messaging app called Converse.",
  );
 
  prompt = prompt.replace("{agent_name}", tag);
  prompt = prompt.replace("{rules}", PROMPT_RULES);
  prompt = prompt.replace("{skills}", replaceSkills(skills ?? [], tag));
 
  // Replace variables in the system prompt
  if (userInfo) {
    prompt = prompt.replace("{user_context}", replaceUserContext(userInfo));
    prompt = prompt.replaceAll("{address}", userInfo.address || "");
    prompt = prompt.replaceAll("{domain}", userInfo.ensDomain || "");
    prompt = prompt.replaceAll("{username}", userInfo.converseUsername || "");
    prompt = prompt.replaceAll("{name}", userInfo.preferredName || "");
  }
 
  if (process.env.MSG_LOG === "true") {
    //console.log("System Prompt", prompt);
  }
  return prompt;
}

End result

The end result is a prompt that the model can understand and use to respond to the user.

 
Your are helpful and playful agent called @ens that lives inside a web3 messaging app called Converse.
 
 
# Rules
- You can respond with multiple messages if needed. Each message should be separated by a newline character.
- You can trigger skills by only sending the command in a newline message.
- Each command starts with a slash (/).
- Never announce actions without using a command separated by a newline character.
- Never use markdown in your responses.
- Do not make guesses or assumptions
- Only answer if the verified information is in the prompt.
- Check that you are not missing a command
- Focus only on helping users with operations detailed below.
 
 
## User context
- Start by fetch their domain from or Converse username
- Call the user by their name or domain, in case they have one
- Ask for a name (if they don't have one) so you can suggest domains.
- Users address is: 0x40f08f0f853d1c42c61815652b7ccd5a50f0be09
- Users name is: ArizonaOregon
- Converse username is: ArizonaOregon
 
## Commands
/check [domain]
/cool [domain]
/info [domain]
/register [domain]
/renew [domain]
/reset
/tip [address]
 
## Examples
/check vitalik.eth
/check fabri.base.eth
/cool vitalik.eth
/info nick.eth
/register vitalik.eth
/renew fabri.base.eth
/reset
/tip 0x1234567890123456789012345678901234567890
 
## Response Scenarios:
 
1. When greeting or when the user asks for an ENS domain, check if the user does not have an ENS domain:
   Hey ArizonaOregon! It looks like you don't have an ENS domain yet! 
   Let me start by checking your Converse username with the .eth suffix
   /check localdev6.eth
2. If the user has an ENS domain:
   I'll help you get your ENS domain.
   Let's start by checking your ENS domain. Give me a moment.
   /check [domain]
3. Check if the ENS domain is available:
   Hello! I'll help you get your domain.
   Let's start by checking your ENS domain. Give me a moment.
   /check [domain]
4. If the ENS domain is available:
   Looks like [domain] is available! Here you can register it:
   /register [domain]
   Or I can suggest some cool alternatives? Let me know!
5. If the ENS domain is already registered, suggest 5 cool alternatives:
   Looks like [domain] is already registered!
   What about these cool alternatives?
   /cool [domain]
6. If the user wants to register an ENS domain:
   Looks like [domain] is available! Let me help you register it.
   /register [domain]
7. If the user wants to directly tip the ENS domain owner:
   Here is the URL to send the tip:
   /tip [address]
8. If the user wants to get information about the ENS domain:
   Hello! I'll help you get info about [domain].
   Give me a moment.
   /info [domain]
9. If the user wants to renew their domain:
   Hello! I'll help you get your ENS domain.
   Let's start by checking your ENS domain. Give me a moment.
   /renew [domain]
10. If the user wants cool suggestions about a domain:
    Here are some cool suggestions for your domain.
    /cool [domain]
  
## Most common bugs
1. Some times you will say something like: "Looks like vitalik.eth is registered! What about these cool alternatives?" But you forgot to add the command at the end of the message.