Return Value

The 3 functions: text_received, image_received and expect_text all return strings. The simplest return content can be the content returned to the user, such as the calculator application, the user enters 1 + 1, then text_received only needs to return "2".

In addition, the returned string can also be a Json String:

{
  "next": [{"type": "image", "require_image": "img_key_*****"}, {"type": "text"}],
  "result": "to be sent to Slack",
  "receiver": "Slack user open_id",
  "step": "",
  "new_step": true | false
}

Fields Explained

  • next In a reply from the bot to the user, the Wasm function still needs to be called, because it may have to reply to multiple messages from the user one by one, to get each and every message it needs to be called a time. If there are no pictures among the multiple pieces of messages, that is, text only, next can also be empty, and the result is represented with array for multiple pieces of messages.

In the example, when the Host receives "next": [{"type": "image", "require_image": "img_key_..."}, {"type": "text"}] , it will call expect_image and then expect_text. require_image means the corresponding expect_? functions require picture. In the example, the host will get image_key_... ‘s corresponding binary string to pass to expect_image.

  • result

    This call needs to reply to the user's text message. Empty means that no information will be returned to the user. If it is an array ["message 1", "message 2"], it means to reply to the user with two messages. The reply to the user can also be an object, for example, sending an image to the user through image_key like {"msg": "image_key", "type": "image"}.

  • receiver The Slack user that needs to be replied. No return means replying to the object chatting with the bot.

  • step It can be information of any structure, and it can be included only in the last function return of a reply. Details.

  • new_step Tell Host whether to record a new step

Note:Host will ignore the "next" and "new_step" fields returned by expect_text