Best-practice for flows

(Andrew Lee) #1

Hey all,

New to Flow, and have a few flows setup to connect to a single FB bot. They’re mostly working great, and it’s amazing being able to quickly prototype interactions.

My question is about flow best practice.

I’m structuring my bot around a few flows:

  • suggestions based on ingredients
  • suggestions based on flavour preferences
  • where to buy based on location

Should I stick with seperate flows? Combine them all in one huge, unwieldy flow? What is considered best-practice?

I’m having odd issues that seem to stem from keywords in flows, if I use the same one in multiple flows it seems to only trigger one bot (I can test this by turning off one, the other then works).

Thanks for any tips.

(Kellsey Shaw) #2

Hi Andrew,

Good to hear that things are mostly working great. Sounds like you are really getting to grips with things.

You are right that only one flow will be triggered if they use the same keyword because ideally, the keyword should be unique to the flow.

Bots aren’t very good at sharing a channel. When you ask the user a question, you are inside the question and whatever you type next (except command keywords such as quit) will be taken as the answer to the question. Basically, the bot hogs the channel when it asks a question and won’t let you speak with another bot.

But you can easily run multiple flows. We’ve got a handy service called Flow that you can use to start other flows.You just need to use the Flow trigger in the flows that you want to be able to start from another flow and use the Flow task in the flow to start another flow.

Hopefully, this all makes sense but if not just let me know.

How to structure your flows is very much personal preference. Personally, I like to break my flows out into blocks that handle different sections of the complete process. Doing it this way allows you to repeat sections.

If you’ve got Telegram you can take a look at @XO_PizzaBot to see this approach in action. Each section (pizza, base and toppings) is it’s own flow so you can restart the sections if you want to change the selection.

(Andrew Lee) #3

Hi Kellsey,

Thanks for the reply, and the rundown on flows.

So I’m clear…

  • you recommend 1 bot, but multiple flows is ok
  • each flow should have a unique set of triggering keywords

I have a few quick questions, if you don’t mind:

Using the pizza example, how would you break it up?

  • 1 flow per pizza? - but they might share keywords like “pizza”
  • seperate flows for ordering and store locations? - again, how do you break up common keywords like “pizza”

Do I just need to think through the logic of how I build and structure the flows so I don’t share keywords?

And, unrelated, how can I store variables from responses and use them in replies? For example asking the user “where do you live?” and processing “I live in {location name}” so I can use {location name} as a variable for filtering and triggering flow steps?

Thanks again!

(Kellsey Shaw) #4

Hi Andrew,

I’ll break down the pizza bot for you because it should hopefully answer your questions and give you an insight to how it’s all working.

I have one flow to start the bot. I’ve used the Bot - New Conversation trigger but using the Bot - New Message would be fine. This is the only flow that the user can trigger.

This flow greets the user and starts the pizza order process off by using a Flow task at the end of the flow to start the second flow.

2nd Flow - This flow is triggered using the Flow trigger and this flow lets the user select the type of pizza. You’ll notice that the user can change their selection. It’s the Flow trigger that makes this possible because you aren’t relying on the user giving a keyword to trigger the flow. But if they don’t want to change their selection, a Flow task runs which triggers the 3rd Flow.

3rd Flow - This flow is again triggered using the Flow trigger and this one lets the user choose the base for the pizza. Again, the user can change their section (the flow is triggered again using a Flow task) but if they don’t a flow task is used to start the 4th Flow.

4th Flow - Triggered again using the Flow trigger. This flow lets them choose toppings. There’s a fair bit going on this one but the key tasks are the Attributes. I’m storing the user’s selections using attributes. And what’s really good about attributes is that they are shared across all flows so you can set or get them from any flow.

I just use the Flow task to re-start the flow each time the user wants to choose another topping and when they’re done I get the attribute where I’ve stored the selections and use it in a new message to confirm what they’ve selected.

I’ve given each flow a name that describes the section of the process that it handles and used that for the keyword. That way all my keywords are unique and I can easily remember what keyword I used.

Hopefully, this answers all your questions?

(Andrew Lee) #5

Thank you SO much!

That’s exactly the kind of answer I was after, so much great detail.

I’ll play around with the flow triggers and re-architect my keywords and logic and see how it works out.

The “Ask a question” and corresponding answer variable is also super handy for saving data.

Nice work team!