Skip to content

Steps to build the integration

Pranav Raj S edited this page Mar 14, 2020 · 6 revisions
  1. Create a website inbox, we will change this to Android inbox later
  2. SDK onLoad should call <host>/widgets.json?website_token=${website_token}, the token is the website inbox token created in step 1.

You will get a response as follows

{
  "web_widget": {
      "id": 1,
      "website_name": "Chatwoot",
      "website_url": "chatwoot.com",
      "account_id": 1,
      "created_at": "2019-10-29T07:29:25.773Z",
      "updated_at": "2020-03-10T04:59:01.479Z",
      "website_token": "",
      "widget_color": "#009CE0"
  },
  "token": "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VfaWQiOiJlZWNmNjV0wMDUwLTQzNmItYjg0ZS02MzQzMDMyNjdkNDIiLCJpbmJveF9pZCI6Mzd9.icFFkS9mW8L8heQQi7mccMULce7kf_QK5z9tX39IGzw",
  "contact": {
      "id": 26093,
      "name": "bold-grass-107",
      "email": null,
      "phone_number": null,
      "account_id": 1,
      "created_at": "2020-03-14T15:39:29.784Z",
      "updated_at": "2020-03-14T15:39:29.784Z",
      "pubsub_token": "f371PxyYAtHLgSsb2GtcDV",
      "additional_attributes": null
  }
}
  1. Save token in the local DB, next time you load the sdk, append it to the url as follows
<host>/widgets.json?website_token=${website_token}&cw_conversation=${token}

  1. After you receive the payload in step 2.
  • 4.1 To get the messages in the current conversation call.
/api/v1/widget/messages?website_token=${website_token}&cw_conversation=${token}
  • 4.2 To get the messages in the list of available agents.
/api/v1/widget/inbox_members?website_token=${website_token}
  • 4.3 To send a message use
URL: POST `/api/v1/widget/messages?website_token=${website_token}&cw_conversation=${token}`,

Parameters: 
{
  message: {
   content,
   timestamp: // datestring,
   referer_url: '' // pass empty string for now.
  }
}
Clone this wiki locally