We will be creating an action-based assistant to take coffee orders.
How to create an IBM Cloud Account
Please complete the prereq session in this readme first, i.e.
-
You must register for the SkillsBuild program with your university email address https://github.com/academic-initiative/documentation/blob/main/academic-initiative/how-to/How-to-register-with-the-IBM-Academic-Initiative/readme.md
-
Request an IBM Cloud feature code https://github.com/academic-initiative/documentation/blob/main/academic-initiative/how-to/How-to-request-and-IBM-Cloud-Feature-Code/readme.md
- Go to this link and create an account: https://cloud.ibm.com/registration.
- If you already have an account, go to https://cloud.ibm.com and click Log in on the top right of the page to continue.
You have two options to create and work with watsonx Assistant:
- Once logged in, click on
Catalogin the top bar (next to the search area). - Search for
Assistant. - Under the
AI / Machine LearningCategory, click onwatsonx Assistant. - Scroll down and make sure the
LitePlan is selected for the free plan. - Click
Create. - Click on
Launch watsonx Assistant. - You will be taken directly to the assistant builder interface.
watsonx Orchestrate is an AI-powered platform that enables you to build, deploy, and manage intelligent agents that automate business tasks. It supports workflow automation and agentic workflows, allowing agents to execute multi-step processes, integrate with enterprise systems, and take actions based on user requests. Additionally, assistants such as watsonx Assistant can be integrated as collaborator agents within orchestrated solutions.
Learn more: https://www.ibm.com/products/watsonx-orchestrate
Creating a watsonx Orchestrate Trial Instance:
- Once logged in, click on
Catalogin the top bar (next to the search area). - Search for
Orchestrate. - Under the
AI / Machine LearningCategory, click onwatsonx Orchestrate. - Scroll down and select the
TrialPlan. - Click
Create. - Wait for your trial instance to be provisioned (this may take a few minutes).
- Once ready, click on
Launch watsonx Orchestrate.
Creating Your First Assistant in watsonx Orchestrate:
- From the watsonx Orchestrate home page, click the hamburger menu (☰) in the top left corner.
- Scroll down and click on Assistant builder at the bottom of the menu.
- The assistant creation wizard will open automatically.
- Name and Language:
- Give your assistant a name (e.g., "Coffee Shop Assistant")
- Add a description (e.g., "An assistant to help customers order coffee, tea and soft drinks")
- Important: Choose your language (e.g., US English). Watson uses this language to understand user utterances and map them to the action that best matches. The example phrases you provide (customer says sentences) should align with this language.
- Click Next
- Assistant Details:
- For "Where will this assistant be used?", select Web
- For "What is your role?", select N/A (I am a student)
- For "What is your level of experience?", select Developer
- For "What do you want to build?", select Not sure at this time
- Click Next
- Validate and create:
- Review your assistant name
- Click Next
- Click Create to create your assistant
Your assistant is now created and you're ready to start creating your first action!
Note: Whether you choose Option 1 or Option 2, the assistant builder interface and the steps to create actions are the same. watsonx Orchestrate simply provides additional features for automation, agentic capabilities, and workflow orchestration alongside your assistant.
watsonx Assistant uses an action-based approach to build conversational flows. Actions are goal-oriented tasks that your assistant can help users complete. Each action consists of:
- Customer starts with: Example phrases that trigger the action
- Steps: A sequence of questions and responses to gather information
- Variables: Information collected from the user
- Conditions: Logic to handle different scenarios
For more information, see: https://www.ibm.com/docs/en/watsonx/watson-orchestrate/base?topic=assistants-building-your-ai-assistant-actions#build-actions-from-scratch
-
In the watsonx Assistant interface, click the Build actions tile or click Actions in the left navigation menu.
-
Click Create action.
-
For your first action in watsonx Orchestrate, select Custom-built action (Note: In standalone watsonx Assistant, this option may be called "Start from scratch").
-
A pop-up window titled "New action" will appear with the subtitle "What does your customer say to start this interaction?"
-
Enter a sample sentence in the text field, for example:
I would like to order a coffee please -
Click Save to create the action.
Now you need to add more example phrases so Watson can better understand different ways customers might order a drink.
- Click in the "Customer starts with" box at the top left of the action editor.
- Add the following sample sentences one by one (press Enter after each):
- I need some caffeine
- order espresso
- a cappuccino would be lovely
- a latte please
These example phrases help Watson understand the various ways customers might express their intent to order a drink. The more examples you provide, the better Watson becomes at recognizing similar requests.
After having entered the sample sentences, you are ready to create the conversation flow.
-
Click on the 1st step in the Conversation steps section on the left side of the screen.
-
In the Assistant says field, enter:
What would you like to drink? -
Click Define customer response.
-
Select Options as the response type.
-
Add the following options with synonyms:
- coffee (synonyms: espresso, latte, cappuccino)
- tea (synonyms: chai)
- soft drink (synonyms: soda, cola)
-
Click Apply to save the options.
-
The response will be automatically saved to an action variable named to something like
1. [text].
-
Click New step to add another step.
-
In the Assistant says field, type:
How many cups of -
Place your cursor at the end of the text.
-
Click the fx button (insert variable) to add an action variable to the response.
-
Select the
1. [text]action variable from the previous step. -
Continue typing to complete the sentence (make sure to start with a space):
would you like?The final text should read: "How many cups of [drink_type variable] would you like?"
-
Click Define customer response.
-
Select Number as the response type.
-
This will be saved to an action variable named to something like
2. [text].
-
Click New step to add a confirmation step.
-
In the Assistant says field, type:
Okay, so you would like -
Click the fx button and select the action variable from Step 2 (e.g.,
2. [text]). -
Continue typing:
(space) -
Click the fx button again and select the action variable from Step 1 (e.g.,
1. [text]). -
Complete the sentence by typing:
. Is this correct?The final text should read: "Okay, so you would like [quantity variable] [drink_type variable]. Is this correct?"
-
Click Define customer response.
-
Select Options as the response type.
-
Add the following options with synonyms:
- Yes (synonyms: correct, right, yep, yeah, sure)
- No (synonyms: nope, incorrect, wrong)
-
Click Apply to save the options.
-
This will be saved to an action variable named to something like
3. [text].
-
Click New step to handle when the customer says "No".
-
Look for the Is taken dropdown at the top of the step.
-
Change the dropdown from Is taken to with conditions.
-
The correct action variable from Step 3 is already selected. Make sure the value is set to No.
-
In the Assistant says field, enter:
No problem. Let's try again then... -
Click And then at the bottom of the step.
-
Select Re-ask previous steps.
-
Choose to re-ask Step 1 (What would you like to drink?). Step 2 and 3 will automatically be selected as well.
-
Click Apply.
-
Click New step to handle when the customer says "Yes".
-
Look for the Is taken dropdown at the top of the step.
-
Change the dropdown from Is taken to with conditions.
-
The correct action variable from Step 3 is already be selected. Make sure the value is set to Yes.
-
In the Assistant says field, type:
Okay, -
Click the fx button and select the quantity action variable from Step 2.
-
Type a space, then click the fx button again and select the type of drink action variable from Step 1.
-
Complete the sentence by typing:
coming right up! ☕️☕️The final text should read: "Okay, [quantity variable] [drink_type variable] coming right up! ☕️☕️"
-
Click And then at the bottom of the step.
-
Select End the action.
-
Click the Preview button (chat bubble icon) in the bottom right corner.
-
Type one of your example phrases, such as "I would like to order a coffee please".
-
Follow the conversation flow:
- Select a drink type
- Enter a quantity
- Confirm your order
-
Test both "Yes" and "No" paths to ensure the logic works correctly.
CONGRATULATIONS!! 🎉 👍
You successfully created an action-based assistant! Your coffee ordering bot can now:
- Understand multiple ways customers ask for drinks
- Collect drink type and quantity
- Confirm orders before processing
- Handle corrections when customers change their mind
- Click on Integrations in the left navigation menu.
- Select Web chat.
- Click Open to configure the web chat.
- Customize the appearance:
- Change the accent color
- Add your coffee shop name
- Upload a logo
- Customize the greeting message
- Click Save and exit.
- Copy the embed code from the Embed tab.
- Paste the code into your website's HTML before the closing
</body>tag.
You can use the provided web-chat-example.html file:
- Open
web-chat-example.htmlin a text editor. - Replace the
<!-- INSERT EMBED SCRIPT HERE -->comment with your embed code. - Save the file.
- Open the file in your web browser.
- Start chatting with your assistant!