Send a message with your application
Send a message through API

Introduction:

This guide will introduce you to send message with your application in Twake.

Prerequisites:

  • You have already created a Twake application.
  • Your application is installed and saved in your company.

Steps:

1. Send message as a new Thread

  • Find the app's token according to 1. Log your Application
  • Find the identifiers to target a channel:
    • Company's id: $COMPANY_ID
    • Workspace's id: $WOKSPACE_ID
    • Channel's id: $CHANNEL_ID
  • Set the message you want to send:
    • Minimal:
      $MESSAGE = { "text": "Hello world !" }
    • To take full advantage of the messages capability in Twake see the MessageObject
  • Send POST request with :
    • Url: https://web.twake.app/api/messages/v1/companies/$COMPANY_ID/threads
    • Headers: { "Content-Type": "application/json", Authorization: "Bearer " + $APP_TOKEN }
    • Body: { resource: { participants: [ { type: "channel", id: $CHANNEL_ID, company_id: $COMPANY_ID, workspace_id: $WORKSPACE_ID, }, ], }, options: { $MESSAGE }, }
  • This POST request will return a ThreadObject

2. Send message as a Thread answer

  • Find the app's token according to 1. Log your Application
  • Find the identifiers to target a channel:
    • Company's id: $COMPANY_ID
    • Workspace's id: $WOKSPACE_ID
    • Channel's id: $CHANNEL_ID
    • Thread's id: $THREAD_Id
  • Set the message you want to send:
    • Minimal:
      $MESSAGE = { "text": "Hello world !" }
    • To take full advantage of the messages capability in Twake see the MessageObject
  • Send POST request with :
    • Url: https://web.twake.app/api/messages/v1/companies/$COMPANYID/threads/$THREAD_ID
    • Headers: { "Content-Type": "application/json", Authorization: "Bearer " + $APP_TOKEN }
    • Body: { resource: { $MESSAGE } }
  • This POST request will return a MessageObject

3. Applications can send customized messages

The MessageObject object have a property called "block" that allow your application to send messages which contains more than a simple string. For example in an application message you can display an iFrame, buttons, menu selector, etc... Combining all this options you can create everything you want up to the limit of your imagination. To understand how to create powerful message using the block property see blocks.