Why one entity extratcted different values in different forms in one intent - entity

I have my Dialogflow es agent working weid now.
Previously, I was training one intent understanding how many bedrooms the enduser mentioned, so I have an entity relating to that called $sc_bed It should be a list as a checked the "is list" in action and parameters
action and parametes I have for this Intent
Also I have 3 output contexts with this intent and store the key parameters mentioned
contexts
For my understanding, the sc_bed entity should be stored in all 3 contexts I mentioned above, with same value and format(which should be list rather than string)
However, the log shows that the entity in different contexts are different in both format and value, I will shoe the log here.
"name": "projects/xxxx/locations/global/agent/sessions/f4xxxxxxxx/contexts/search_criteria",
"lifespanCount": 49,
"parameters": {
"is_visitor": "yes",
"lead_first_name": "Test Lead",
"sc_location": [],
"clarify_renter.original": "",
"lead_email.original": "",
"buyer_reply_message2": "I’d like to get a little more information from you if that's ok.",
"sc_timeframe.original": [],
"buyer_interested_listing.original": "",
"conversation.original": "",
"lead_type": "renter",
"buyer_reply_message": "I've got your preferences down here and I'll set up a search for places you might like.",
"seller_market_snapshot.original": "",
"lead_first_name.original": "",
"assigned_agent_name.original": "",
**"sc_bed": {
"amount": 3
},**
"assigned_agent_name": "Test Assigned Agent",
"reply_message_timeframe": "We would love to assist you with the renting process!",
"sc_maxPrice.original": [],
"reminder_price_reduced_link": "chime.me/pricereduced",
"sc_timeframe_range": [],
"search_listing_result.original": "",
"sc_propertyType": [],
"sc_priceRange": [],
"sc_maxPrice": [],
}
},
{
"name": "projects/newagent-mxiwbg/locations/global/agent/sessions/f47970c6-49b2-c8a9-7aff-60316c185007/contexts/general_info",
"lifespanCount": 49,
"parameters": {
"chime_action_add_tag": "AI: Interested",
"buyer_reply_message2.original": "",
"follow_up_event.original": "",
"conversation": "renter_home_search",
"conversation.original": "",
"sc_feature.original": [],
"sc_location": [],
"lead_type": "renter",
"reply_message_timeframe.original": "",
"sc_priceRange": [],
"buyer_reply_message.original": "",
"sc_approxPrice": "",
"sc_propertyType": [],
"sc_propertyType.original": [],
"clarify_renter.original": "",
"sc_timeframe_range": [],
"clarify_renter": "Yes",
"sc_maxPrice.original": [],
**"sc_bed": [
{
"amount.original": [
"2",
"3"
],
"amount": [
2,
3
]
}
],
"sc_bed.original": [
"2 or 3 bedroom"
],**
}
},
What I am expecting are 2 points:
The entity in different contexts should be the same one at least for the entity extracted in this exactly same one intent
The entity info should keep the format I checked which is a list not a string.

Related

Remove user selected item from the list in SAP conversational AI Chatbot

I am working on a chatbot project where I have to create a dynamic list option. There is a list of 15 Items (first step). When user selects one, selected item should be removed from the list. After that It will return to first step (list) and will display only 14 items. Where is the issue in step 3?
Step 1: I have created a "item_list" in the memory field of one skill.
[{"item": "product_1", "value": 5},{"item": "product_2", "value": 6},{"item": "product_3", "value": 4}]
Step 2: Choose custom list and enter the following script in the same skill.
{
"type": "list",
"delay": "",
"content": {
"elements": [
{{#eachJoin memory.item_list}}
{
"title": "{{this.item_list.item}}",
"subtitle": "{{this.item_list.value}}",
"imageUrl": "",
"status": "",
"statusState": "<''/none/information/error/success/warning>",
"description": "",
"buttons": [
{
"title": "{{this.item_list.item}}",
"value": "{{this.item_list.item}}",
"type": "postback"
}
]
}{{/eachJoin}}
]
}
}
Step 3: In another skill, set memory field where the user input is stored and set another memory "item_list" to match the user input within the array value to remove it from the item_list. For this, I have entered the following script. But there is some problem with that script. How can I remove the item from the array?
{{#inArray memory.item_list.title memory.user_input.raw}} "{{remove memory.item_list memory.user_input.raw}}" {{else}} "{{memory.lists}}"{{/inArray}}

MongoDB: self-referencing correctly?

I'm coming from SQL and very new to Mongo. I'm trying to put everybody in my members collection.
This is daddy:
{
"_id":{"$oid":"629f50805d9928ddfeeda108"}, /* auto generated */
"email": "parent1234567#yahoo.com",
"password":"hA$h3dP#zZw0rdstring",
"memberType":"parent",
"fullName": "Senior Rodriguez",
"birthday": "1980-12-31",
"phone": "514-555-9988",
"address": [
{"billing":"100 rue barré, montreal qc h3a1p2"},
{"shipping":"3-1107 rue amherst, montreal qc h2e1g8"}
],
"enrolledIn": [],
"notes": [],
"parentId":[] }
This is the kid:
{
"_id":{"$oid":"729f50805d9928ddfeeda109"}, /* auto generated */
"email": "",
"password":"",
"memberType":"child",
"fullName": "Junior Rodriguez",
"birthday": "2012-01-01",
"phone": "",
"address": [],
"enrolledIn": [
{"courseName":"summer camp sc220601a",
"startDate":"2022-06-07",
"endDate":"2022-08-01",
"notes":"Monday to Friday, 9am-4pm"},
{"courseName":"piano tue 1730-1800 pia220603a",
"startDate":"2022-05-07",
"endDate":"2022-08-01",
"notes":"Every Tuesdays, 5:30pm-6:00pm"}
],
"notes": ["allergic to peanuts", "lactose intolerant"],
"parentId":{"_id":{"$oid":"629f50805d9928ddfeeda108"}} /* manually created */ }
Is this the proper way to self-reference another _id in the same collection?
Sorry I still kinda think like SQL, and I can't help but also think about other questions like, what do I do to enrolledIn when I change the details of the courses? For example summer camp sc220601a got cancelled? And should I put the password on this collection so I can use this same collection for authentication?

pymongo: Document must be an instance of dict

Afternoon,
I'm facing a problem with pymongo, I'm not able to set up correctly the parameter to insert into MongoDB via insert_many(). I came across with de following error:
TypeError: document must be an instance of dict, bson.son.SON,
bson.raw_bson.RawBSONDocument, or a type that inherits from
collections.MutableMapping [while running 'Insere no MongoDB']
What am I doing wrong ?
class InsertMongoDB(beam.DoFn):
def process(self, element):
arqJson=json.loads(element)
client = MongoClient("mongodb://user:password#mkp-cr-marketplace-core.lcr88.gcp.mongodb.net/db-poc-base360?retryWrites=true&w=majority%20")
db = client['db-poc-base360']
db.tbPropostaSucesso.insert_many(arqJson)
# tbPropostaErro = db['tbPropostaErro']
# tbPropostaErro
resultado = 0
yield resultado
I receive a messagem from Google PubSub and forward it to a method called InsertMongoDB().
I don't know how to suit my massage, whose value is in a json format, to use it correctly in the insert_many().
When I debug my variable "arqJson" has :
The json that I'm using is :
{
"Status": "Sucesso ",
"Documento": {
"Apolice": [{
"ItemAuto": [{
"nmTipo": "FOX",
"nrItem": "000001",
"nmMarca": "VOLKSWAGEN",
"aaModelo": "2017",
"cdModelo": "0017664",
"nmModelo": "TRENDLINE 1.0 FLEX 12V 5P",
"aaFabricacao": "2016",
"nmTipoVeiculo": "Hatch"
}, {
"nmTipo": "FOX",
"nrItem": "000001",
"nmMarca": "VOLKSWAGEN",
"aaModelo": "2017",
"cdModelo": "0017664",
"nmModelo": "TRENDLINE 1.0 FLEX 12V 5P",
"aaFabricacao": "2016",
"nmTipoVeiculo": "Hatch"
}],
"ItemProp": [{
"dsUF": "MG",
"idLocal": "000001",
"dsCidade": "BELO HORIZONTE",
"dsEndereco": "RUA RUA RUA",
"dsComplemento": "CASA"
}],
"cdEmpresa": "1",
"idApolice": "501741",
"idEndosso": "000000",
"cdCarteira": "431",
"cdSucursal": "010",
"cdPatrimonio": "1",
"nrItemContrato": "2",
"dsTipoDocumento": "A",
"cdVeiculoSegurado": "1"
}],
"Cliente": [{
"cdCliente": "1",
"nmCliente": "Lucas",
"nrCpfCnpj": "4355582833",
"icRegistroAtivo": "1",
"cdAcaoInformacao": "A",
"dtAcaoInformacao": "2020-02-02",
"cdServicoAcaoInformacao": "cdServicoAcao",
"cdUsuarioAcaoInformacao": "cdUsuarioAcao"
}, {
"cdCliente": "2",
"nmCliente": "Lucas",
"nrCpfCnpj": "43331971",
"icRegistroAtivo": "1",
"cdAcaoInformacao": "A",
"dtAcaoInformacao": "2020-02-01",
"cdServicoAcaoInformacao": "cdServicoAcao2",
"cdUsuarioAcaoInformacao": "cdUsuarioAcao2"
}],
"Mensagem": [{
"cdMensagem": "1",
"dsMensagem": "Teste de mensagem"
}],
"EnderecoCobranca": [{
"dsUF": "RS",
"dsBairro": "INTEGRAÇÃO",
"dsCidade": "PAROBE",
"cdEndereco": 1,
"dsEndereco": "RUA RUA RUA",
"nrEndereco": "280",
"dsComplemento": "",
"icRegistroAtivo": "1",
"cdAcaoInformacao": "A",
"dtAcaoInformacao": "2020-02-02",
"cdServicoAcaoInformacao": "cdServicoAcao",
"cdUsuarioAcaoInformacao": "cdUsuarioAcao"
}, {
"dsUF": "SP",
"dsBairro": "INTEGRAÇÃO2",
"dsCidade": "POC2",
"cdEndereco": 2,
"dsEndereco": "RUA B",
"nrEndereco": "222",
"dsComplemento": "CASA 2",
"icRegistroAtivo": "1",
"cdAcaoInformacao": "A",
"dtAcaoInformacao": "2020-02-01",
"cdServicoAcaoInformacao": "cdServicoAcao2",
"cdUsuarioAcaoInformacao": "cdUsuarioAcao2"
}]
}
}
2020/11/20:
At the moment I'm struggling with the format of arqJson that I need to use in the insert_one(arqJson).
I forgot to mention that my method InsertMongoDB receives the arqJson from another method called InsertPostgreSQL.
InsertPostgreSQL does:
Receive the message from Pubsub;
-Transform the element : json.dumps(json.loads(element))
Save it into arqJson. After that, InsertMongoDB is called.
At this moment, I don't know how to format "element" (whose type is list) and save it into arqJson, because I have this error:
raise TypeError("%s must be an instance of dict, bson.son.SON, "
TypeError: document must be an instance of dict, bson.son.SON,
bson.raw_bson.RawBSONDocument, or a type that inherits from
collections.MutableMapping [while running 'Insere no MongoDB']
Thank you,
Juliano
The solution is :
The first error is because your JSON contains a single document not
multiple docs for an insert many. If you use brackets like this
db.tbPropostaSucesso.insert_many([arqJson]) and convert it to a list
with a single element it will work. Or you can try
insert_one(arqJson). – DaveStSomeWhere 5 hours ago
Thank you DaveStSomeWhere
I had the same problem, and what worked for me was adding retryWrites=false to the connection URL:
mongodb+srv://user:pass#server/etc...etc?retryWrites=false

Yodlee searchSite returning component with multiple values

The Yodlee docs for siteSearch shows a componentList array with each entry looking like this:
{
"valueIdentifier": "LOGIN",
"valueMask": "LOGIN_FIELD",
"fieldType": {
"typeName": "TEXT"
},
"size": 20,
"maxlength": 22,
"name": "LOGIN",
"displayName": "User ID",
"isEditable": true,
"isOptional": false,
"isEscaped": false,
"helpText": "101920",
"isOptionalMFA": false,
"isMFA": false
},
however, when the siteSearch is matches "baa", we get a response with a componentList array entry that seems to have multiple possible values, like this:
{
\"defaultValues\": [
\"6331\",
\"5700\",
null,
null
],
\"values\": [
null,
null,
null,
null
],
\"validValues\": [
null,
null,
null,
null
], ...
I can't find any documentation on this "multiple-value field", and it seems to be a rare case. Can anyone point me to any information on this type?
Thanks.
I would suggest you to check this.
Here look for Social Security Number example. It is a single field which has been divided into 3 section(i.e. input text box). Similarly you need to consume the Login form you are receiving and show it to the consumer of your application.
Whenever you'll find valueIdentifier is having an array i.e. more than 1 value then it is multiple fixed field type else it's a single field.
Here is the image how does it look like once you render the same.

Freebase search_api and excluding results by specified type

is anyone know, how to exclude some topics with specified type(s) using search api and mql?
For example i'm try to find all topics "Voodoo People", and exclude only those, that have composition and release types, and sort result by score desc: http://tinyurl.com/3tjkb7y.
Sorting work perfect, but i can't find functionality for excluding :(
I'm try to use mql_filter: http://tinyurl.com/644xkow, but releases still there.
And one more question: i see in type_strict param possible values: "all", "any", "should". But there is no value "not" or "not in". Is needed result can be obtained in any other way?
The syntax that you're looking for is "optional" : "forbidden". In your query that would look like this:
[{
"search": {
"query": "Voodoo People",
"score": null,
"mql_filter": [{
"type": {
"id": "/music/release",
"optional": "forbidden"
}
}]
},
"name": null,
"id": null,
"type": [],
"/common/topic/notable_for": {
},
"limit": 15,
"sort": "-search.score"
}]​