I want a chatbot with buttons in Slack integrated RASA Bot for example, How are you feeling? Sad or Happy. I want two-buttons(one for happy and one for sad) here and get input from the user and followed by other questions. What will be the stories.md, nlu.md, domain.yml, and frontend python code?
You can implement the buttons in your domain.yml file. It could look like the following:
responses:
utter_greet:
- text: "Hey! How are you?"
buttons:
- title: "great"
payload: "great"
- title: "super sad"
payload: "super sad"
The payload will then be sent to the nlu model to make the prediction on the intent. That's why your nlu.md should have examples for like mood_sad, mood_great in there.
Your stories.md should look regular - it should have examples of how the conversations could go. For example:
* greet
- utter_greet
* mood_sad
- action_cheer_up
You can also restrict the nlu part on buttons by sending actual intents (and potential entities) to the RegexInterpreter. In that case, you can define buttons in your domain as follows:
utter_greet:
- text: "Hey! How are you?"
buttons:
- title: "great"
payload: '/mood_great'
- title: "super sad"
payload: '/mood_sad'
Related
am using rasa 1.9.5.
I have a form that gets activated and it will ask for the slots to fill. When it is asking for a slot to fill it's calling utter_slots_name. But my requirement is, I need to call custom action instead like action_slots_name.
I need to call custom action for all slot filling questions.
NLU:
## intent:greet
- Hi
- Hello
- I need a help
- just need help
- can you server me
## intent: greeting_with_name
- Hi I am [sharath](name), I need some services
- Hi myself [sharath](name), Need some services
- Hi this is [sharath](name), need some services
## intent: are_u_bot
- are you a bot?
- are you a human?
- am I talking to a bot?
- am I talking to a human?
## intent: my_name_is
- my name is [sharath](name)
- [sharath](name)
- I am [sharath](name)
- Myself [sharath](name)
Stories:
## bot challenge
* bot_challenge
- utter_iamabot
## happy path
* greet
- action_greeting
- user_details
- form{"name":"user_details"}
- form{"name":null}
- action_askfor_services
Domain:
actions:
- action_askfor_services
- action_slots_name
- user_details
- action_greeting
intents:
- greet
- bot_challenge
- my_name_is
- greeting_with_name
form:
- user_details
entities:
- name
- phoneNo
- tenentId
- language
slots:
language:
type: text
name:
type: text
phoneNo:
type: text
tenentId:
type: text
requested_slot:
type: text
responses:
utter_iamabot:
- text: I am a bot, powered by Rasa.
utter_bye:
- text: bye
session_config:
carry_over_slots_to_new_session: true
session_expiration_time: 60
I'm trying to integrate a form in my rasa chatbot.
In domain.yml, I have included the following:
I declared the slots:
slots:
question1:
type: text
question2:
type: text
question3:
type: text
the questions that the form is supposed to send to the user:
utter_ask_question1:
- text:" first question goes here"
utter_ask_question2:
- text:" second question goes here"
utter_ask_question3:
- text:" third question goes here"
defined the form as:
forms:
user_quiz_form:
question1:
- type: from_text
# entity: date
question2:
- type: from_text
question3:
- type: from_text
the actions section also contains :
actions:
- action_submit
- user_quiz_form
The file rules.yml contains:
- rule: Activate quiz form
steps:
- intent: quiz
- action: utter_quiz
- action: user_quiz_form
- active_loop: user_quiz_form
- rule: Submit quiz form
condition:
- active_loop: user_quiz_form
steps:
- action: user_quiz_form
- active_loop: null
- slot_was_set:
- requested_slot: null
- action: action_submit
and actions.py is:
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.events import SlotSet, EventType
from rasa_sdk.executor import CollectingDispatcher
import webbrowser
class ValidateForm(Action):
def name(self) -> Text:
return "user_quiz_form"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
required_slots = ["question1","question2", "question3"]
for slot_name in required_slots:
if tracker.slots.get(slot_name) is None:
# The slot is not filled yet. Request the user to fill this slot next.
return [SlotSet("requested_slot", slot_name)]
return [SlotSet("requested_slot", None)]
class ActionSubmit(Action):
def name(self) -> Text:
return "action_submit"
def run(
self,
dispatcher,
tracker: Tracker,
domain: "DomainDict",
) -> List[Dict[Text, Any]]:
print("****************SUBMIT*****************")
dispatcher.utter_message(template="utter_quiz_thanks", date=tracker.slots.get("question1"))
return []
When the form is triggered, it doesn't' ask the questions to the user and returns utter_quiz_thanks with None as question1 value.
Is this the same indentation you're using in your domain.yml? If so, you're missing some indents; the slots underneath the form need to be indented (see below for an example). My guess is that you're launching the form correctly, but due to the indent issues your assistant is treating it as a form with 0 questions.
forms:
restaurant_form:
cuisine:
- type: from_entity
entity: cuisine
num_people:
- type: from_entity
entity: number
jekyll blog(minimal-mistakes thema) has a space to introduce myself.
I want to write on two lines in this space.
For example
hello
world
I know that to edit this page, i need to touch the _config.yml file.
# Site Author
author:
name : "Choi Young-jin"
avatar : "/assets/images/images/avatar.png"
bio : "**^^**" <-----------Parts to change
42 intra ID: yochoi
location : "Seoul"
email : "amateur.toss#gmail.com"
links:
- label: "Email"
icon: "fas fa-fw fa-envelope-square"
# url: "amateur.toss#gmail.com"
- label: "GitHub"
icon: "fab fa-fw fa-github"
url: "https://github.com/amateurtoss"
The escape character does not work.
bio: "hello\nworld"
What if I want to show the string in two lines?
Well it's markdown, so you should do
bio: |-
hello
world
(That's a YAML block scalar, which is interpreted literally and ends with the next item on the same or lesser indentation level as bio)
You can of course also do
bio: "hello\n\nworld"
But it's less obvious what happens here.
You can use HTML in the bio string, so you can simply use a HTML linebreak:
bio: "hello<br>world"
The above is the only way in which I managed to have a single line break. All other options lead to either no line break or an empty line between the two lines.
I do not understand how the slot mapping does to know which "utterance" to answer the user to get the "entity" requested.
example of my form class:
class RestaurantForm(FormAction):
"""Example of a custom form action"""
def name(self):
# type: () -> Text
"""Unique identifier of the form"""
return "formaejemplo"
#staticmethod
def required_slots(tracker):
# type: () -> List[Text]
"""A list of required slots that the form has to fill"""
return ["valor1","valor2","valor3"]
def slot_mappings(self):
return {"valor1": self.from_entity(entity="valor1",intent="getvalor1"),
"valor2": self.from_entity(entity="valor2",intent="getvalor2"),
"valor3": self.from_entity(entity="valor3",intent="getvalor3")}
def submit(self, dispatcher, tracker, domain):
dispatcher.utter_template('utter_listo', tracker)
return []
domain.yml:
intents:
- peticion_habitacion:
use_entities: false
- getvalor1
- getvalor2
- getvalor3
entities:
- valor1
- valor2
- valor3
slots:
valor1:
type: unfeaturized
auto_fill: false
valor2:
type: unfeaturized
auto_fill: false
valor3:
type: unfeaturized
auto_fill: false
actions:
- utter_prueba
- utter_completo
templates:
utter_completo:
- text: "listo:\nvalor 1 {valor1} \nvalor 2 {valor2} \nvalor 3 {valor3}"
utter_prueba:
- text: "iniciando prueba:\n"
utter_valor1:
- text: "dame el valor 1 no enteros"
utter_valor2:
- text: "dame el valor 2 no enteros"
utter_valor3:
- text: "dame el valor 3 no enteros"
utter_listo:
- text: "prueba completa"
forms:
- formaejemplo
in the section where you get the value1, value2 etc ... it is according to the Rasa documentation: "valor1": self.from_entity (entity = "valor1", intent = "getvalor1" "the "valor 1" will be obtained from the intent getvalor1."
my question is, at what time or in what part or what file, the action form is told that it will have to send the "utterance" "utter_valor1" or "utter_valor2", because to several Internet examples plus the same examples of bots of rasa, I see that these send the utterance and then recover the value, but I can not get to understand how they send the utterance and then get the value
I assume you mean how the action sdk determines which template it should use to ask for a requested slot, right?
This logic is actually hardcoded here: https://github.com/RasaHQ/rasa_core_sdk/blob/cfffaac0013606f7614ab0f213bc39623ee8b53c/rasa_core_sdk/forms.py#L374
What it does is simply dispatches an utterance which is utter_ask_{the name of slot which should be requested}.
If the user then sends back his answer, the form action is triggered again and the slot value can be extracted.
I am pulling recent commits from github and trying to parse it using ruby. I know that I can parse it manually but I wanted to see if there was some package that could turn this into a hash or another data structure.
commits:
- parents:
- id: 202fb79e8686ee127fe49497c979cfc9c9d985d5
author:
name: This guy
login: tguy
email: tguy#tguy.com
url: a url
id: e466354edb31f243899051e2119f4ce72bafd5f3
committed_date: "2010-07-19T13:44:43-07:00"
authored_date: "2010-07-19T13:33:26-07:00"
message: |-
message
- parents:
- id: c3c349ec3e9a3990cac4d256c308b18fd35d9606
author:
name: Other Guy
login: oguy
email: oguy#gmail.com
url: another url
id: 202fb79e8686ee127fe49497c979cfc9c9d985d5
committed_date: "2010-07-19T13:44:11-07:00"
authored_date: "2010-07-19T13:44:11-07:00"
message: this is another message
This is YAML http://ruby-doc.org/core/classes/YAML.html. You can do something like obj = YAML::load yaml_string (and a require 'yaml' at the top of your file, its in the standard libs), and then access it like a nested hash.
YAML is basically used in the ruby world the way people use XML in the java/c# worlds.
Looks like YAML to me. There are parsers for a lot of languages. For example, with the YAML library included with Ruby:
data = <<HERE
commits:
- parents:
- id: 202fb79e8686ee127fe49497c979cfc9c9d985d5
author:
name: This guy
login: tguy
email: tguy#tguy.com
url: a url
id: e466354edb31f243899051e2119f4ce72bafd5f3
committed_date: "2010-07-19T13:44:43-07:00"
authored_date: "2010-07-19T13:33:26-07:00"
message: |-
message
- parents:
- id: c3c349ec3e9a3990cac4d256c308b18fd35d9606
author:
name: Other Guy
login: oguy
email: oguy#gmail.com
url: another url
id: 202fb79e8686ee127fe49497c979cfc9c9d985d5
committed_date: "2010-07-19T13:44:11-07:00"
authored_date: "2010-07-19T13:44:11-07:00"
message: this is another message
HERE
pp YAML.load data
It prints:
{"commits"=>
[{"author"=>{"name"=>"This guy", "login"=>"tguy", "email"=>"tguy#tguy.com"},
"parents"=>[{"id"=>"202fb79e8686ee127fe49497c979cfc9c9d985d5"}],
"url"=>"a url",
"id"=>"e466354edb31f243899051e2119f4ce72bafd5f3",
"committed_date"=>"2010-07-19T13:44:43-07:00",
"authored_date"=>"2010-07-19T13:33:26-07:00",
"message"=>"message"},
{"author"=>
{"name"=>"Other Guy", "login"=>"oguy", "email"=>"oguy#gmail.com"},
"parents"=>[{"id"=>"c3c349ec3e9a3990cac4d256c308b18fd35d9606"}],
"url"=>"another url",
"id"=>"202fb79e8686ee127fe49497c979cfc9c9d985d5",
"committed_date"=>"2010-07-19T13:44:11-07:00",
"authored_date"=>"2010-07-19T13:44:11-07:00",
"message"=>"this is another message"}]}
This format is YAML, but you can get the same information in XML or JSON, see General API Information. I'm sure there are libraries to parse those formats in Ruby.
Although this isn't exactly what you're looking for, here's some more info on pulling commits. http://develop.github.com/p/commits.html. Otherwise, I think you may just need to manually parse it.