- Simple Interaction
- Conversation with an action that requires confirmation
- Conversation with authentication
- Conversation with transfer to an agent
Simple interaction
The example below shows a simple interaction with the GenerativeAgent. We first use the Conversation API to create a conversation, and then call the GenerativeAgent API to analyze a message from the customer. RequestPOST /conversation/v1/conversations
POST /generativeagent/v1/analyze
Conversation with an action that requires confirmation
In this use case, we go through a scenario that requires confirmation before the GenerativeAgent can execute a task on the user’s behalf. Besides showing the payload of the GenerativeAgent Events that are sent from the GenerativeAgent, we also check the conversation state. We assume there is an existing conversation with ID 01HMSHT9KKHHBRMRKJTFZYRCKZ. RequestPOST /generativeagent/v1/analyze
GET /generativeagent/v1/state?conversationId=01HMSHT9KKHHBRMRKJTFZYRCKZ
Response
Status 200. We see the GenerativeAgent is waiting for confirmation for this conversation.
POST /generativeagent/v1/analyze
GET /generativeagent/v1/state?conversationId=01HMSHT9KKHHBRMRKJTFZYRCKZ
Response
Conversation with authentication
In this scenario, the user tries to take an action that requires authentication first. GenerativeAgent will then ask for authentication via the GenerativeAgent event, which we can also confirm via the State API call. We’ll authenticate and see the GenerativeAgent resuming the task. We assume there is an existing conversation with ID 01HMW15N6V27Y4V2HRCE0CBZJQ. Please see the first use case to understand how to create a new conversation. RequestPOST /generativeagent/v1/analyze
GET /generativeagent/v1/state?conversationId=01HMW15N6V27Y4V2HRCE0CBZJQ
Response
Status 200. We see the GenerativeAgent is waiting for confirmation for this conversation.
POST /conversation/v1/conversations/01HMW15N6V27Y4V2HRCE0CBZJQ/authenticate
Conversation with transfer to an agent
This example showcases the bot transferring the conversation to an agent (a.k.a. agent escalation). We assume there is an existing conversation with ID 01HMY50MM3D5JP23NPWXKPQVD4. Please see the first use case to understand how to create a new conversation. RequestPOST /generativeagent/v1/analyze
GET /generativeagent/v1/state?conversationId=01HMY50MM3D5JP23NPWXKPQVD4
Response
Status 200. We see the GenerativeAgent is waiting for confirmation for this conversation.