Cognitive search (using the chatbot to search content of already available documents)

hello
I need to create a chatbot where if any use provide a keyword, let’s say, tax form then the chatbot will take the tax form keyword then it will search the contents of the documents that are alreay provided to the chatbot , then if the keyword matches with any on the content of the document then the chatbot will send that document to the user as a response

Is that possible?

Hi @rezwanahmed, for now it’s not supported but you can try to do something by yourself in a module for example.

Have a look at algorithms like the BM25 or solutions like elastic-search or many others… (for which you can add hooks in botpress).

Hope it helps,
Have a great day

1 Like

actually I am trying with the call api function

https://policyfinder.search.windows.net/indexes/azureblob-index/docs?search={{event.payload.text}}&$count=true&api-version=2020-06-30

this is my query link


it is a get request and the value is saved on temp.responses

But the problem is that I am not being able to use the data in the next node

image

this is the variable that i am using

and this is my whole flow

and this the the flow from the emulator , ( i have marked the point where i should get the data that i have queried through the api but I am not getting any

image

I think i am incorrectly using the temp.response variable , it would be really great if you could provide some insight

From What I’m seeing, the temp variable is correctly use. If you want to learn more about memory you can go here

Response with TEMP

In the node say something, could you try to modified the event.

{{temp.response}}

Normally you should receive something like this

image

If it doesn’t work, could I see your action or your hook :sweat_smile:

Do you know the body of your response ?

1 Like

yes i was receiving this object object, why wasn’t i receving the data from the api call?

I did not use hooks or custom action , i used the direct api calls
this is my current api call and it’s response

POST https://policyfinder.search.windows.net/indexes/azureblob-index/docs/search?api-version=2020-06-30

and this is my body response

{
    "@odata.context": "https://policyfinder.search.windows.net/indexes('azureblob-index')/$metadata#docs(*)",
    "@odata.count": 2,
    "value": [
        {
            "@search.score": 1.4610517,
            "content": "\nSample company sick leave policy\nThis Company Sick Leave Policy template is ready to be tailored to your company’s needs and should be considered a starting point for setting up your employment policies. A company sick leave policy may also be called a sick time policy, sick pay policy, or sick days policy.\nPolicy brief & purpose\nOur company sick leave policy outlines our company’s provisions for employees who become sick and need to be absent from work. The following sample policy specifies how sick leave will be accrued and how it may be used.\nScope\nThis company sick leave policy applies to all our employees who have been with our company for at least [six months.]\nPolicy elements\nOur employees may be unable to perform their duties if they get sick. Our company follows legal guidelines that may apply to sick pay. We’ll also offer [25 days] of [paid/ partially paid] sick leave. This leave is separate from other types of leave like maternity leave and Paid Time Off (PTO).\nHow do sick days work?\nOur employees can take sick leave when they want to:\n· Recover from sudden illness\n· Recover from accidents/injuries\n· Receive mental/psychological care or counseling when necessary\nEmployees who want to attend to routine healthcare (e.g. doctor’s/dentist’s appointments) should use their PTO.\nUnused sick leave policy\nEmployees will receive [1] additional day/s every [1 year] of working for our company. Depending on the law, employees can accumulate unused sick leave until it reaches a certain number of days. Unused sick time may be calculated for an employee’s annuity when they retire.\nKeep in mind that, employees who become sick should either use their sick days or work from home to avoid spreading illnesses.\nProcedure\nWhen employees want to use their sick time, they should notify their supervisor as soon as possible either through email or an automated Human Resources Information System (HRIS.) They should also inform the supervisor for how long they’ll be absent (if possible) or report daily for every day of sick leave.\nUnder certain circumstances, employees might need to submit a physician’s note or other medical certification and/or complete a sick leave form. Those circumstances include but are not limited to:\n· Being absent for more than [three days] on sick leave.\n· Cases when a pattern arises (e.g. employees plead sick at a specific time each week.)\nWe will handle all sick time requests with discretion.\n \n\tDisclaimer: This policy template is meant to provide general guidelines and should be used as a reference. It may not take into account all relevant local, state or federal laws and is not a legal document. Neither the author nor Workable will assume any legal liability that may arise from the use of this policy.\n\n\n\nImprove your hiring with Workable - get started with a product tour or a 15-day free trial.\n\n"
        },
        {
            "@search.score": 0.2868743,
            "content": "\nParental leave company policy\nThis parental leave policy sample will help you set up and flesh out your own parental leave company policy with important information for mothers and fathers you employ.\nPolicy brief & purpose\nOur parental leave company policy outlines our provisions for our employees who have children. We want everyone in our company to be able to balance their job and family duties; work shouldn’t unduly hinder a parent’s responsibilities toward their child or consistently prevent them from spending time together.\nRegarding pay during family leave, we will always follow legal guidelines where they exist. In counties or states where paid family leave isn’t mandatory, we will provide paid leave according to this company policy.\nScope\nThis paid parental leave policy applies to all employees who are parents or will become parents in the near future.\nIn this policy, we define a ‘child’ as someone who is under 18 years old. For the purposes of providing parental leave, we don’t differentiate among biological children, adoptive children and step-children, as long as they’re under the custody or care of an employee.\nPolicy elements\nOur parental leave company policy addresses every need associated with the expectancy or care of a child. It includes paternity leave, maternity leave, adoption leave and any other leave that parents might need:\nMaternity leave\nWhat is maternity leave? It’s a temporary absence from an employee’s position and will be granted to support expectant mothers who require time off for pregnancy, childbirth recovery and child care. We have a dedicated maternity leave policy you can look at for more information.\nSee our maternity leave policy template to craft an effective policy for your own company.\nLength and compensation will depend on the laws of the country / state you reside in or our company policy, whichever is greater. Our company offers [four months of paid maternity leave] plus [two months of unpaid leave if you need more time to recover from labor – in this case, you may need to bring doctor’s notes to HR]. If there are legal provisions specifically for maternity leave that exceed our company policy, the law will apply.\nWhile you’re on paid maternity leave, your position, benefits and pay remain the same. If a larger scale change needs to happen for organizational purposes, and your job is affected, we’ll keep you informed and discuss solutions according to the law. In any case, you will never be victimized or disadvantaged because you’re a mother or because you’re on maternity leave.\nPaternity leave\nWhat is paternity leave? It’s a temporary absence from an employee’s position and applies to employees who identify as male who require time to care for an infant. We will grant paternity leave to allow fathers to care for and bond with their newborn child. We have a dedicated paid paternity leave policy where you can find more information.\nLength and compensation will depend on the laws of the country / state you reside in or our company policy, whichever is greater. Our company offers [four months of paid paternity leave]. If there are legal provisions specifically for paternity leave that exceed our company policy, the law will apply.\nJust like with maternity leave, your position, benefits and pay remain the same and we will find solutions when any necessary changes need to be done.\nAdoption Leave\nWhat is adoption leave? It’s a temporary absence from any employee’s position that applies to those who have recently become legal guardians of a child. Our paid adoption leave allows bonding time with that child. You can also use part of your adoption leave to go to appointments or meetings related to the adoption procedure. Ask HR about what documents you need to bring to use leave for this reason.\nOur company offers [four months of paid adoption leave]. If there are legal provisions specifically for adoption leave that exceed our company policy, the law will apply.\nOther parental leave\nParents who require time off to see to various affairs regarding their children may qualify for a certain amount of paid parental leave. For example, you can get parental leave if you want to:\n· Take your child to the hospital or a doctor’s appointment\n· Care for a sick child\n· Visit current or new schools\n· Attend child counseling sessions\nWe will comply with legal guidelines that may exist. If there aren’t any legal provisions in the country or state you reside in, our company will offer [six days] of paid parental leave per year on top of any maternity and paternity leave or paid time off.\nNote that in some countries, parents may be allowed to share their leave with their partners (e.g. mothers can pass on the remainder of their leave to their partners) or take it consecutively instead of together. Wherever these arrangements are possible or mandatory, we will follow the law and try to assist our employees in the best way possible.\nWe may consider flexible work arrangements if you need them for another [year] after the end of your maternity or paternity leave.\nProcedure\nIf you need to request maternity or paternity leave, you must always give notice to your supervisor and HR, [at least four months before your expected start of leave]. We can make exceptions when there are unforeseen circumstances that force you to take leave earlier.\nWhen parental leave for other reasons is needed, please inform your supervisor [at least two days in advance]. [Send your request via our HRIS.]\nYou can contact HR for information if you have any questions to ask.\n \n\tDisclaimer: This policy template is meant to provide general guidelines and should be used as a reference. It may not take into account all relevant local, state or federal laws and is not a legal document. Neither the author nor Workable will assume any legal liability that may arise from the use of this policy.\n\n\n\nFurther reading:\n· The Family and Medical Leave Act (US Department of Labor)\n· The Pregnancy Discrimination Act (US Equal Employment Opportunity Commission)\n\nImprove your hiring with Workable - get started with a product tour or a 15-day free trial.\n\n"
        }
    ]
}

I checked the weatherbot example for understanding custom action to use api but I wasn’t able to configure it properly in accordance to the azure cognitive search REST api. But I noticed one thing that in the response node {{event.state.temp.response.weather}} was used shouldn’t we use only {{temp.response}} ?

I don;t have knowledge on axios or javascript , it would be really great if you could provide some documentation or solution to the api call data not showing problem

If you reveived this object then your call was complete and you can access data inside it.

Maybe check Object.keys(my_object) to see whats inside.
You can then access it with my_object.my_key

You data is surely in my_object.data

Hope it helps,
Have a great day

1 Like