如何在Dialogflow中创建表单?招生门户机器人表单实现咨询
Hey there! Let's walk through exactly how to build that admissions portal bot with a form submission flow in Dialogflow—this is totally doable, and I'll break it down step by step so you can follow along easily.
First, make a new intent (name it something like Admissions_Form_Start or Submit_Admissions_Info). This will be the hook that starts your form flow. Add training phrases that users might say to trigger it, like:
- "I want to apply to the program"
- "Fill out the admissions form"
- "Can I submit my info for admission?"
This is where you map out all the basic info you need from users. Head to the Parameters section of your intent and add each field as a parameter:
- For standard data types (name, email, phone), use Dialogflow's built-in system entities:
fullName(entity:@sys.fullname)emailAddress(entity:@sys.email)phoneNumber(entity:@sys.phone-number)
- For custom fields like "program of interest", create a custom entity (e.g.,
@programs) with options like "Computer Science", "Business Administration", "Mechanical Engineering". - For every parameter, check the Required box—this tells Dialogflow to automatically prompt the user if they skip that field.
For each required parameter, add friendly prompts to ask users for the missing data. You can even add multiple prompts to keep the conversation natural:
- For
fullName:- "Could you share your full name, please?"
- "I just need your full name to proceed—what should I call you?"
- For
emailAddress:- "What's your email address so we can send you updates?"
- "Could you provide an email where we can reach you?"
Once all fields are filled, you need to process and store the data. Here's how to set that up:
- Enable Fulfillment for your intent (you can use Dialogflow's inline Node.js editor or connect your own webhook server).
- Write code to grab the collected parameters and act on them—like saving to your admissions database or sending a confirmation message.
Example inline editor code snippet:function processAdmissionsForm(agent) { // Pull the collected data from the agent's parameters const name = agent.parameters.fullName; const email = agent.parameters.emailAddress; const phone = agent.parameters.phoneNumber; const program = agent.parameters.programOfInterest; // Replace this with your actual logic: save to DB, send email, etc. console.log(`Received admissions form: ${name}, ${email}, ${phone}, ${program}`); // Send a confirmation message to the user agent.add(`Thanks so much, ${name}! We've got your request for the ${program} program. We'll reach out to you at ${email} within 2 business days.`); } // Map the intent to your fulfillment function intentMap.set('Admissions_Form_Start', processAdmissionsForm);
To make sure the bot stays focused on the form until it's complete:
- Create an input context like
admissions_form_in_progressand attach it to your form intent. This tells Dialogflow to only trigger this intent when the user is in the middle of filling out the form. - After submission, set an output context to clear the active form state—so the bot can handle other requests (like "What's the deadline?") once the form is done.
If you're using Dialogflow CX, it has built-in Form components that make this even easier:
- Create a page, add a Form, and define all your fields directly in the Form editor.
- Set validation rules (e.g., "email must be valid") and prompts without manually configuring parameters.
- CX automatically manages the flow of collecting missing fields, so you don't have to handle that logic yourself.
- Add validation in fulfillment: Check if the email is formatted correctly, or if the phone number is valid, and prompt the user to correct it if needed.
- Let users edit fields: Add training phrases like "I messed up my email" or "Change my program" and set up a follow-up intent to update parameters.
- Add a confirmation step: Before submitting, say "Let me confirm your details: Name: Jane Doe, Email: jane@example.com, Program: Business Admin. Is that right?" to avoid mistakes.
内容的提问来源于stack exchange,提问作者Pranav Vardia

