Buttons

Buttons are useful for many situations, where you need to get a fast response from users. We can split the available buttons to three parts: Buttons in Adaptive cards, Inline-button as quick replies and Hints buttons.

Adaptive cards and hint buttons allow you to configure the endpoint to which the button payload will be sent.

And the inline-buttons are built for quick replies or to open url. They cannot send requests to any endpoint.

Inline-button as quick replies

Buttons or Quick Replies are built in nodes that allow you to get message recipient input by sending buttons in a message. When a quick reply is tapped, the value of the button is sent in the conversation or url is opened

Available buttons:

  • URL: Open a URL inside the client.

  • Postback: Allow the user to send a predefined message to the chat.

You can set postback as a special command for tekos in node to catch the message content and do specified actions. More about it you can find in the Tekos In node documentation.

How go get them working

You need to connect buttons node with tekos out node as it is the only option for them to get working. You cannot connect buttons node with the function node & http request as they are built specially for tekos dialogue platform.

Adaptive Cards buttons

We can also use built in buttons in the adaptive cards and specify in the tekos flow actions that they will trigger.

More about this you can find in the Adaptive Cards Action.Submit tutorial

Hints buttons

Hints buttons are really similar to quick replies but instead of opening a webpage or sending a message to the chat, they send a HTTP request to defined endpoint together with defined payload to identify the request. Also when a hint button is tapped it awaits for the HTTP response code and becomes unclickable.

Hints are object inside the hint array that is included in the msg.payload object

Here is an example code of function node.

msg.roomId = "!lpeAMqZBhqNNbcQkTq:m.tekos.co" // Room Id where message will be sent
msg.url = "https://"+env.get('BASE_URL')+'/_matrix/client/r0/rooms/' +msg.roomId+ '/send/m.room.message?access_token='+global.get('user_access_token')

msg.headers ={
 "Content-type": "application/json"
}

msg.payload = {
  "body": "",
  "msgtype": "m.text",
  "hints": [
    {
    "body": "Go further", //Value displayed in the chat
    "reply":"continue", //Value sent to the endpoint
    "type": "request_url_only",
    "request_url": env.get("FLOW_URL")+"/hint_button" //Endpoint adress
    },
    {
    "body": "I want to modify", //Value displayed in the chat
    "reply":"modify", //Value sent to the endpoint
    "type": "request_url_only",
    "request_url": env.get("FLOW_URL")+"/hint_button" //Endpoint adress
    }
  ]
};
return msg;

As you can see hint element include body, replay, type and request_url objects.

Body - It is the value displayed in the chat room. Replay - It is the payload sent to the endpoint Type - should always be “request_url_only” Resuest_url - It is the defined endpoint to which the replay payload will be sent.

Example payload after tapping the “Go Further” button, we can see an id which is the body in the function node and the “msg” containing the “replay” value. But we will also receive an “roomid” in which the button was pressed and the “senderid” of the person which taped the button.

Last updated