Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Go through Creating an App to set up your app via the developer dashboard.
  2. Install the app into your own Flock account. Make sure that you save the user token received in the app.install event. You will need it for the method calls that follow.
  3. To be able to send a message to a contact or a group, you will need to know their identifier first. The methods roster.listContacts and groups.list can help you do this. Typically, your configuration URL will use these methods to set up an interface wherein a user can select which contact or group he wants to send messages from your app to.Create a Message

  4.  object, setting the id of the receiving user or group in the to attribute. An example message is shown in the code sample below.Send this message using the chat.sendMessage method. You can use either HTTP GET:

    Code Block
    languagejstext
    titleA Simple Text Message
    {
        "to": "u:1e6429de-16b7-48b3-acc0-c2d7ec5ad195",
        "text": "A simple text message"
    }
  5. Send this message using the chat.sendMessage method.
  6. Method call using a GET request
    https://api.flock.co/v1/chat.sendMessage?to=u:513a9f4ae409&text=hello&token=632542db-1a23-4e06-8b39-01f8b0868d57

    or POST to call the method.

    Code Block
    languagetext
    titleMethod call using a POST request
    linenumberstrue
    POST /v1/chat.sendMessage HTTP/1.1
    Host: api.flock.co
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 70
    
    to=u:513a9f4ae409&text=hello&token=632542db-1a23-4e06-8b39-01f8b0868d57
  7. If you want to send attachments, take a look at the Sending Attachments page. Or if you want to create a bot, take a look at Bot.