Back to Blog

Channel specific flows

Flow.ai is able to connect with multiple channels. Each channel has it’s own strenghts. The strenghts of a channel like Faebook Messenger or WhatsApp is that you will already receive some user data that you can use while this is not the case when using the Web Widget.

A common case where it is recommended to change your flows based on the channel of the user is within Customer Service. When your user reached out through the Web Widget, that person is still anonomous. Therefore you might want to ask for name, e-mail and phone. On the other hand, if a users contacts you through Facebook Messenger you will receive user data so that you can get back to him later.

Check the user’s channel

Let’s start by checking the channel of the user. Drag and drop an action onto you canvas and use the code below. The code below checks if the channel of the user is messenger or if it the web socket.

If the channel of the user is messenger, then we’ll trigger an event called ‘Channel-Messenger’. If the channel equals socket, then we’ll trigger an event called ‘Channel-Socket’.

async payload => {

  let channel = payload.channelName
  
  if(channel === 'messenger'){
    trigger('Channel-Messenger')
  }
  
  if(channel === 'socket'){
    trigger('Channel-Socket')
  }
}

Create channel specific flows

Make sure that you channel specific flows start with an event and make sure that the name of that event is equal to the name in your cloud code. In this case that is ‘Channel-Messenger’ and ‘Channel-Socket’.

Design your channel specific flows and depending on you channel, you can extract data of the user by using entities.

Other channels

Besides the example above that covers the “messenger” and “socket” channel you can also use the following channels.

channels = ["alexa","events-webhook","google","mavenir",
"rbm","rest","telegram","whatsapp"]
Get StartedContact us