The Flow ability allows a bot designer to extend the bots product by using Microsoft Flow.
Your Flow can interact with the user via the bot by posting messages, cards and asking questions.
It is possible to add multiple Flow's to a single bot. Just make sure the keywords and targets are unique enough in order to determine which Flow to trigger.
Creating a Flow that can be triggered from a Flow ability
- Create a new Flow at https://flow.microsoft.com with a HTTP trigger
- The method should be POST
- Leave the request body schema for now, we will populate it later
- Create a new Flow Action to initialize the conversationSession variable
- Click 'Add dynamic content'
- Add the following expression: triggerOutputs()['headers']['x-conversation-session']
- Create a new Flow Action to initialize the API Key
- Leave the value blank for now
Add Flow ability to a bot
- Create a bot
- Add a Flow ability
- Save the ability to generate an API key.
- Open up the Flow ability again
- Flow Endpoint Field - This is the URL generated by the HTTP Trigger of your Flow. Copy it from Flow
- Display Success and Error Fields can be used to control how messages are displayed to a user when a Flow is trigger
- API Key Field - Copy this value into your Flow's API Key initialize variable action. This is used when sending messages back to the bot
- Targets and Keywords can be configured the same as any other ability
- Conversational Parameters - The values to fetch from the user to pass to the Flow. The Variable Names need to match the variables added to the Flow's HTTP Trigger
- To configure how the bot prompts the user for a variable, click on the parameter row and enter the prompt into the Parameter Prompt field
- Form Based Parameters - These work essentially the same way as Conversational Parameters, however they are displayed as a form, rather than prompting the user
- Like the Conversational Parameters, the Variable Names need to match the fields entered into the Flow's HTTP Trigger
Configure the Flow's Request Body Schema
- At the bottom of your Flow abilities settings, there is a field called 'JSON PAYLOAD' copy the contents of this field
- Paste it into your Flow HTTP request trigger
Post messages from Flow
- Add a HTTP Action to your flow
- The Method must be 'POST'
- The URI field should be the following expression
- x-conversation-session header is the conversationSession variable configured earlier
- x-api-key header is the apiKey variable configured earlier
- content-type header must be application/json
- The Body field must be a valid json object with a message field and an attachments field.
- The message field expects a string message and is the text send to the user from the bot.
- The attachments field expects an array of attachments. These attachments are added to the message sent to the user.
- An attachment can be an adaptive card, a video, a file, or an image
Letting the bot know you are finished
- In order to let the bot know you have finished performing any tasks it is important to call the done endpoint at the end of your flow.
Post Questions from Flow
To post questions from Flow to your bot, you will need to add a Webhook HTTP action to your Flow.