Gemini – Basic Chat Bot

You can set up a basic chat bot cycle:

Install a “Generic Webhook” Utility Connector

  1. Navigate to the install a Utility Connector page:
    • In the Cyclr Console:
      • Navigate to Templates > Template Connectors.
      • Select + Install New Utility.
    • In the Cycle builder:
      • Select + Add Utility.
  2. Find the Generic Webhook connector and select Install.
  3. Edit the Name field if you need to. This example sets the name to Gemini webhook.
  4. Select Next.

Setup the Generic Webhook connector

  1. Navigate to the Edit Connector page of the Generic Webhook Connector:
    • In the Cyclr Console:
      • Navigate to Templates > Template Connectors.
      • Under the Installed Utility Connectors heading, select Edit Connector next to the Gemini webhook Connector.
    • In the Cycle builder:
      • In the right hand menu, under the Utility Connectors heading, select the Gemini webhook Connector.
      • Select Settings.
  2. Under the Methods and Fields heading, select Webhooks > Webhook.
  3. Under the Request Fields heading, select the + (Add Field) icon to add request fields for:
    • A Chat Session ID field that will receive the chat session ID to use for the chat request.
    • A Message field that will receive the message to send to the API.
  4. Under the Methods and Fields heading, select HTTP Methods > POST.
  5. Under the Request Fields heading, select the + icon to add a request field for:
    • A Chat Session ID field that contains the chat session ID to identify which chat the response was from.
    • A Message field that contains the response message.

Create the Cycle

Create a new Cycle as follows:

Setup each Step as follows:

Webhook

Receive the chat session ID and message.

List Chat Session Messages

Check if the chat session already exists. If it does, the message from the Webhook step is sent to the chat. If it doesn’t, an initial system instruction message is sent to the chat using the Send Message step along with the webhook message.

Send Message (Existing Chat)

Sends a user message to an existing chat session.

FieldMapping
Chat Session IDWebhook > Chat Session ID
Trim Tokens?Use Select a Value to set if tokens should be trimmed.
ModelUse Select a Value to set the model.
MessageWebhook > Message

Send Message (New Chat)

Sends an initial system message to a new chat session.

FieldMapping
Chat Session IDWebhook > Chat Session ID
Trim Tokens?Use Select a Value to set if tokens should be trimmed.
ModelUse Select a Value to set the model.
MessageWebhook > Message
System Instruction Part TextUse Type a Value to set the instructions for the chat bot.

POST

Respond to an external source with the answer Gemini generated.

FieldSource
URLUse Type a Value to enter a URL to post Gemini’s response to.
Chat Session IDWebhook > Chat Session ID
MessageSend Message > Candidate Content Part Text

Use the Cycle

To start the cycle, select Run in the Cycle builder.

To use the chat bot cycle:

  1. Select the Step Setup of the Webhook step.
  2. Make note of the webhook URL.
  3. Post to this webhook URL from an external source, either another Cycle or an external client such as Postman, with a request body structure as follows:
{
    "chatSessionId": "test-chat-session-1",
    "message": "How do I convert miles to centimeters?"
}

Cyclr saves all messages (system, user, and assistant) with the Chat Session ID provided. In this example, the ID is test-chat-session-1, and you can therefore post follow up requests with the same Chat Session ID to continue the conversation.