Functions (formerly ChatGPT Triggers)

Modified on Wed, 18 Sep at 11:31 AM

Functions provide a means to seamlessly integrate ChatGPT with your automation tools and external systems. These Functions enable you to effortlessly gather user information and initiate predefined flows. The triggered flow has the capability to execute various automations, retrieve data from external sources, and relay the information back to ChatGPT.


Chatbot Builder has included a pre-configured tigger that allows the user to stop bot automation and talk with a human agent. This Functions is already active on all accounts.



How to create a ChatGPT Function

Navigate to Settings > Integrations > Prompt Engineering (Formerly OpenAI ChatGPT )> Functions and click the Manage button.



On the Functions page, click the Add Button



Name 

The best practice is to Name your Function in a way that it allows you, and others, to know exactly what it does at first sight. For example, instead of using “weather” as a name, use “get_current_weather”. 

Tip: Always include a verb in the name (book, get, set) and avoid any special characters such as: ', &, á or ñ.


What Does This Trigger Do?

This field should clarify even more what the purpose of the Function is. Always start with “Allows the user to …”. For example, “Allows the user to book an appointment”. This section should help OpenAI to match "intention" with the "function." If a user "wants to book an appointment," it will use the Trigger Name and this description to find the best match.

Tip: If you are working in more than one language, please keep each function in a single language. If choosing a different language than English, keep in mind this works just as a prompt, and you might need to test and make modifications.


Tip: If you are having issues with Functions not saving special characters correctly, you can try telling it to handle all user data with UTF-8 encoding in the field "what does this trigger do?”, and that worked like a charm.


What Data to Collect?

Naming must be clear and specific. For example, if you want your function to collect user email, use “email”. 

Tip: Keep in mind, Bot will wait until user provides all requested data BEFORE it triggers.


What Flow is Triggered?

You can trigger any flow that you have already created. For the best user experience, if the response depends on the data collected, set the final response in a single custom field and use it in the "What is the output message?" below. Go to "Examples" below to see some use cases.


What is the Output Message?

The result of triggering this Function. For example, “Your booking was confirmed”. The output message will not be sent exactly as specified. OpenAI will rewrite and send it to the user. 

Tip: This step it's optional, leave it empty if you need/want to ONLY trigger the flow and skip the AI generated text from the Default Response.


Examples

Name: book_appointment

What does this trigger do?: Allows the user to book an appointment.

What data to collect?: date, email, reason

What is the output message?: You have successfully booked an appointment.


Name: connect_user_to_human

What does this trigger do?: Allows the user to speak, talk or contact a human agent or team. This function will connect the user to a human agent.

What flow is triggered?: [Choose your flow from drop down] 

What is the output message?: You are now connected to a human agent. We will get back to you soon.


Name: get_current_weather

What does this trigger do?: Allows the user to get the current weather in a given location

What data to collect?: city

What flow is triggered?: [Choose your flow from drop down] 

What is the output message?: {{data_from_api}}


Name: join_email_list

What does this trigger do?: Allows the user to join our email list.

What data to collect?: email

What is the output message?: Success


Name: request_shipping_quote

What does this trigger do?: Allows the user to request a quote for shipping a package.

What data to collect?: origin_address, destination_address, dimensions, weight

What flow is triggered? [Choose your flow from drop down]

What is the output message?: {{quote}}



Enable a Function

After creating your Function, you need to attach it to the OpenAI action or attach it to the OpenAI Settings.




Important notes


Your prompt can and most likely will affect the way your Function work.


If your function is not working as expected, please verify your main prompt and business description to make sure there is NO text that might be in conflict with your trigger.


How to use this in your favor? If, for example, you have a restaurant reservation function, you might find useful for Bot to remember and reuse user's name and phone number, but it won't make sense to reuse its last reservation's date or guest's number. In this case, you could include in your prompt something like: “It is very important to ask the user for the date and number of guests each time the user wants to make a reservation.” to make sure OpenAI do NOT complete the missing data and/or reuse it from past conversations.


Functions work similar to a "complementary prompt"


Just as any prompt, you might need some testing the wording in name and description before you get it working exacly as you need.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article