Website Name Change
I have changed the name of this website from Mining Business Data to BotFlo. I am offering a 60% off discount on both my Dialogflow ES and Dialogflow CX courses till April 20th 2021 for people who can help me spread the word about my new website.
As you might know, Skype is one of the 1-click integrations available for Dialogflow.
But the real work begins after you add the 1-click integration from the console.
This article is focused on two main topics:
- How to render rich controls (such as a card) on the Skype bot
- How to get user’s responses to those rich controls (such as their button clicks) back into your Dialogflow context
Rendering a rich control on the Skype bot
This is based on the following thread:
There is an important thing to consider: do you need just a Hero card, or do you need a more advanced card type? Both are possible, but the Hero card is a bit more straightforward. Here is what the hero card looks like:
Send this JSON to render the card above:
You can also show more complex card types on your Skype bot, but you need to use the custom payload for that. For example, this is a receipt card:
Here is the corresponding JSON:
Get user’s selection into Dialogflow context
So sending rich controls over to Skype is straight forward (once you figure out the correct JSON to be used).
However, getting information about a user’s selection on a Skype card is more tricky. This is especially important if you need to get a response from the user and the context in your chatbot will be set based on user’s click (a very common use case).
Unfortunately, its not as if you can somehow propagate a context from Skype to your Dialogflow agent. But we can solve this problem by going back to the basics.
There are three things to remember:
1. The value underlying a button or list item rendered inside your Skype bot is a plain string which can contain arbitrary spaces
2. When user presses the button inside the Skype bot, the entire text value is sent back to Dialogflow
3. Since you are communicating with an external service (in this case Skype’s API) you cannot use the external service’s context because it doesn’t have one (that is, you cannot “store” variables in the context of your Skype bot like you do within Dialogflow, you need to pull the variables back into the context of your Dialogflow agent first)
So here is how you do it:
- When you send JSON to your Skype bot, the text value underlying the button should be a string of the form “order Sushi”, or “order Tenpura” etc. It should have both the action the button should take, and also the parameter associated with that particular button
When user clicks button, the whole text is sent back to Dialogflow
In your next intent, the user says should be defined using the template mode.
E.g. UserSays: order @productname
@productname is an entity with values such as Sushi, Tenpura etc.
- Dialogflow will now be able to map the incoming text response to the intent and will automatically extract the value “Tenpura” and place it into the context
You can now use the extracted value from the agent like you normally would – that is, since it is already in the context of your Dialogflow agent, you can use the context parameter in the next turn, or you can send it to your webhook and so on
So, the important insight here is that you are encoding the action you must take (e.g. order) as well as the parameter name (e.g. Tenpura) into the “value” field of list item and you should create the JSON accordingly when you send it to your Skype bot.