Trigger
ChatBotKit Trigger Integration is a powerful feature that allows users to seamlessly send events and other types of information to their bots using a dedicated API endpoint. Once activated, the bot processes incoming information, decides on the required action, executes it - potentially using one of many available ChatBotKit Skillsets - and records the result. This integration is particularly valuable in the context of agent workflows.
You can dispatch any number of events to the trigger, and the bot will respond with appropriate actions accordingly. All activities from the interaction are logged in the Conversations tab as usual.
How to Invoke the Trigger
Invoking a trigger can be done through either CURL or standard HTTP requests, and revolves around using the endpoint URL provided on the ChatBotKit Trigger configuration dashboard. Below is a CURL request example:
# with authentication curl 'https://api.chatbotkit.com/v1/integration/trigger/{triggerId}/event?session={session}' \ -H 'Authorization: Bearer {SECRET}' \ --data '{PAYLOAD}' # without authentication curl 'https://api.chatbotkit.com/v1/integration/trigger/{triggerId}/event?session={session}' \ --data '{PAYLOAD}'
In the sample above, remember to replace both {triggerId}
and {SECRET}
with your actual ID and associated secret from your integration. You will find this information on your trigger configuration page.
There are a number of optional parameters that can be passed in the query: session
, contact.name
****, contact.email
****, and contact.phone
****:
session
: If asession
value is provided, the bot will attempt to continue a previous conversation that matches the provided session id. This is kept up to the session duration limit specified in the advanced options. If no session is provided, or the previous one has expired, a new session is created for each interaction.contact.*
: If acontact
object is provided, the bot will associate the session with the given contact. The contact object can containname
,email
andphone
fields. If no session is used then one of the unique contact identifiers will be used for the session.
Please remember that all interactions, including trigger event histories, can be viewed in the Conversation tab of the dashboard for convenient tracking and reference.
Triggers vs API Calls
ChatBotKit Trigger integration and Direct API Calls both serve unique needs and environments. They share many similarities but differ in key areas such as how they process events and interactions. Understanding these differences can help you utilize the right one for your specific needs.
ChatBotKit Trigger Integration
The main strength of ChatBotKit Trigger integration lies in its ability to process events in the background. Once the trigger receives an event, it schedules it for processing and immediately sends back a response, freeing up your application to continue other tasks without waiting for the bot response. This makes the trigger integration particularly suitable for scenarios where an immediate response from the bot is not required, or when you want to offload certain tasks to the background to enhance the performance of your application or simply to perform some type of job in the case of agent workflows.
In other words, it's particularly efficient for sending events and performing background tasks without the need for additional infrastructure.
Direct API Calls
Invoking direct API endpoints, on the other hand, is a synchronous process. When you send a request to a specific bot conversation endpoint via an API call, you have to wait for the bot to process the request and return a response before your application can continue. While this might potentially introduce a delay into your workflows, it also ensures that you receive an immediate response from the bot, making it suitable for scenarios where immediate feedback is required.
Summary
Using the ChatBotKit Trigger integration forms an essential part of the enhanced ChatBotKit experience. By facilitating communication to and from bots, it powerfully extends the potential applications and workflows that chatbots can be incorporated into. As such, mastering this integration will certainly open up new frontiers in your ChatBotKit usage.