> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wordware.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Chatbot

> Make a chatbot in under 5 minutes

<div
  style={{
position: "relative",
paddingBottom: "74.17582417582418%",
height: 0,
}}
>
  <iframe
    src="https://www.loom.com/embed/5c6f931d90744c6d844237e38371af9c?sid=2c9ee01d-b2c1-47fb-87e6-31954e3f04f4"
    frameborder="0"
    webkitallowfullscreen
    mozallowfullscreen
    allowfullscreen
    style={{
  position: "absolute",
  top: 0,
  left: 0,
  width: "100%",
  height: "100%",
}}
  />
</div>

<img src="https://mintcdn.com/wordware/FWDTtuq-kcxfP2RJ/images/recipes/chatbot/chatbot-demo.png?fit=max&auto=format&n=FWDTtuq-kcxfP2RJ&q=85&s=62f8f9e23c6e3781f047e3b2fd29944a" alt="Chatbot Demo" width="2018" height="1466" data-path="images/recipes/chatbot/chatbot-demo.png" />

With Wordware, tasks that would take software engineers hours or days can be done in minutes. In this recipe, we'll
show you how to make a chatbot in under 5 minutes, with only 5 steps, no coding required.

## Steps

<Steps>
  <Step title="Create a New Prompt">
    Start by creating a new Prompt. You can do this by clicking the "New Prompt" button on the editor.

    <img width="40%" src="https://mintcdn.com/wordware/ra7xKdT2WQAz-aM2/images/recipes/chatbot/new-prompt.png?fit=max&auto=format&n=ra7xKdT2WQAz-aM2&q=85&s=065802a7d3fa8ec66ca097da024f24ad" alt="New prompt" data-path="images/recipes/chatbot/new-prompt.png" />
  </Step>

  <Step title="Start the Conversation">
    Give the chatbot an initial message to get the ball rolling. Just type whatever you want the AI to see!

    <img width="60%" src="https://mintcdn.com/wordware/FWDTtuq-kcxfP2RJ/images/recipes/chatbot/initial-message.png?fit=max&auto=format&n=FWDTtuq-kcxfP2RJ&q=85&s=231a6dbe0f494c1042c0d6e879c873d5" alt="Initial message" data-path="images/recipes/chatbot/initial-message.png" />
  </Step>

  <Step title="Add a Loop">
    To keep the conversation going, add a [loop](/nodes/loop) node. This will allow the conversation steps we'll add
    next to repeat.

    <img width="60%" src="https://mintcdn.com/wordware/FWDTtuq-kcxfP2RJ/images/recipes/chatbot/add-loop.png?fit=max&auto=format&n=FWDTtuq-kcxfP2RJ&q=85&s=f2b0f5116ed4114e047134d955a187fc" alt="Loop" data-path="images/recipes/chatbot/add-loop.png" />
  </Step>

  <Step title="Now for some AI">
    Add a [generation](/nodes/generation) node *inside the loop* to generate the AI's response. You can use the default
    settings or customize them to your liking.

    <img width="60%" src="https://mintcdn.com/wordware/FWDTtuq-kcxfP2RJ/images/recipes/chatbot/generation.png?fit=max&auto=format&n=FWDTtuq-kcxfP2RJ&q=85&s=5551f0bebcb7e8b345f218e5c0a5c6a2" alt="Generation node" data-path="images/recipes/chatbot/generation.png" />
  </Step>

  <Step title="It Takes Two to Tango">
    Finally, to let the user respond to the AI in real time, add a [human ask](/nodes/human) node after the generation
    to get the user's response (this is probably you!). This will allow the AI to respond to the user's input.

    <img width="60%" src="https://mintcdn.com/wordware/FWDTtuq-kcxfP2RJ/images/recipes/chatbot/human-input.png?fit=max&auto=format&n=FWDTtuq-kcxfP2RJ&q=85&s=219a67a41c4a0a1f7b7b8c9588f20213" alt="Human ask node" data-path="images/recipes/chatbot/human-input.png" />
  </Step>
</Steps>

At this point, you've got a working chatbot! Hit the "Run" button to see it in action.

<img src="https://mintcdn.com/wordware/FWDTtuq-kcxfP2RJ/images/recipes/chatbot/first-test.png?fit=max&auto=format&n=FWDTtuq-kcxfP2RJ&q=85&s=f73d336a38f0fec754488ef39b54a747" alt="First Test" width="2028" height="1352" data-path="images/recipes/chatbot/first-test.png" />

## Taking it to the Next Level

You might notice the chatbot only responds 3 times! To make it more conversational, we'll have to tweak the default
loop settings. Click the loop node to open the sidebar, and notice the `Count` setting, currently set to 3 by default.

We could increase this count to get a larger number of repetitions, but real conversations tend to be a bit more
dynamic. Let's add a stop message instead, like a safeword for the chatbot to end the conversation.

<Steps>
  <Step title="Change the Loop Type to Match" stepNumber={6}>
    We'll use the last message from the human to trigger the stop, ending the loop when that last message matches a
    predetermined safeword. You could use "blueberry" or "keep going" but for tradition's sake we'll go with "stop".

    Enter your choice of stop message in the `First value` field.

    <img width="30%" src="https://mintcdn.com/wordware/ra7xKdT2WQAz-aM2/images/recipes/chatbot/modified-loop-sidebar.png?fit=max&auto=format&n=ra7xKdT2WQAz-aM2&q=85&s=f6f368d8ea290b24efcc20b0436519b6" alt="Stop message" data-path="images/recipes/chatbot/modified-loop-sidebar.png" />
  </Step>

  <Step title="Use a Mention to Reference the Human Output" stepNumber={7}>
    To check if the human's last message matches the stop message, we'll use a [mention](/nodes/mention) node to
    reference the human's output. Inside the `Second value` field, type `@` to bring up the mention options, and select
    the one matching the name of the human ask node.

    <img width="30%" src="https://mintcdn.com/wordware/FWDTtuq-kcxfP2RJ/images/recipes/chatbot/mention-human-output.png?fit=max&auto=format&n=FWDTtuq-kcxfP2RJ&q=85&s=74f8092f755cf8747c3e11ae2259d2b5" alt="Mention node" data-path="images/recipes/chatbot/mention-human-output.png" />
  </Step>
</Steps>

Now let's test it out!

<img src="https://mintcdn.com/wordware/ra7xKdT2WQAz-aM2/images/recipes/chatbot/second-test.png?fit=max&auto=format&n=ra7xKdT2WQAz-aM2&q=85&s=837888143057ee4fe611b7b0084ac835" alt="Second Test" width="2054" height="2026" data-path="images/recipes/chatbot/second-test.png" />

Finally, it's always a good idea to add some polish to your chatbot. I'll add a "your turn" indicator to the human ask
here, so it's clear when the user should respond.

<img width="60%" src="https://mintcdn.com/wordware/FWDTtuq-kcxfP2RJ/images/recipes/chatbot/final-tweaks.png?fit=max&auto=format&n=FWDTtuq-kcxfP2RJ&q=85&s=b7993d9d65e6ac38d740e21a697e371e" alt="Final tweaks" data-path="images/recipes/chatbot/final-tweaks.png" />

I'll also add a quick "Chatbot: " indicator before the generation that produces the AI's response, for that classic
early 2000s chatroom feel. This is as easy as typing in the text just before the generation node.

<img width="60%" src="https://mintcdn.com/wordware/FWDTtuq-kcxfP2RJ/images/recipes/chatbot/chatbot-indicator.png?fit=max&auto=format&n=FWDTtuq-kcxfP2RJ&q=85&s=aca891a020e77f92c0e598115e0cc6c2" alt="Chatbot indicator" data-path="images/recipes/chatbot/chatbot-indicator.png" />

At this point, we'll get a conversation that looks exactly like what we had in the demo at the start.

Next, we could add more features to make the chatbot more engaging. For example, when the chatbot stops, it just stops.
To make it more natural, we could add a goodbye message to the AI. We could also update the names of the nodes to make
the flow easier to follow, or perhaps add an input for the user's name so the AI can personalize the conversation.
The possibilities are endless.

And that's it! You've made a chatbot in under 5 minutes. If you have any questions or need help, feel free to reach
out. We're excited to see what you come up with.
