Advertising sustains the DA. Ads are hidden for members. Join today

Views Intent

Last updated on
12 March 2021

Imagine the following conversation.

User: "Middle Earth, what cities have you got?"
Bot: "I've got Hobbiton, Bree, Moria, Lorien, Edoras and Minas Tirith."
User: "Tell me events in Bree happening today."
Bot: "Bilbo and Friends playing at The Prancing Pony today. Do you want to know more or skip to the next event?"
User: "Skip."
Bot: "Black Riders hanging around Bree from today to tomorrow. Do you want to know more or skip to the next event?"
User: "I want to know more."
Bot: "[...]"

What Bot's answers are if not content listing? If we had to provide this content through the web we could easily achieve the task using a couple of Views, for example:

Bot: "I've got Hobbiton, Bree, Moria, Lorien, Edoras, Minas Tirith." - Cities taxonomy vocabulary terms listing, displaying all items. An header area is added with text "I've got " and entity titles are rewritten to append a ",".
[...]
Bot: "Bilbo and Friends playing at The Prancing Pony today. Do you want to know more or skip to the next event?" - Events content listing, filtered by city field Bree, with pager displaying 1 result per page. A footer area is added with the text "Do you want to know more or skip to the next event?".

Chatbot API provides a Chatbot Intent Views display which allow you to nest the output of Views inside a response message. You have the power of Views system and all the features (field rewriting, filters, sorting, paging, header/footer areas, templating, etc.) ready to be used with your bot.
And without writing a line of code. Everything can be done from the Views admin UI.

Slots/Entities will be mapped to Views exposed filters (as long as the slot/entity name exactly maps to a exposed filter field name) and an internal iterator will track the pagination, if required.

Always remember your output will be a speech or a visual message and users get easily annoyed so be wise on the amount of text you return from the view.

The views integration is still experimental, and additional works will be done to provide better results and better experience. For example fields referencing entities (i.e. a City field referencing Cities taxonomy vocabulary) expect the exposed filter value to be the entity id, while the request Slots/Entities will probably be the city name. But this is a common issue with views which can be easily solved by altering the view and its options during the building process.

Help improve this page

Page status: No known problems

You can: