Slack Intent Tracking

Intents are an optional, advanced feature.

With Intents, you can roll up similar messages your bot sends to quickly see the combined metrics.

Here is how we define an intent:

Intents can be sent for either inbound or outbound messages. Place the intent object at the root level of the JSON that you send for each inbound or outbound message.

Adding an Intent for an inbound message

Example: “What is the weather in San Francisco?”

{
  "token": "...",
  "team": {
    "id": "T0RKXFPTP",
    "name": "jessetest"
  },
  "bot": {
    "id": "U16R8L1JA"
  },
  "message": {
    "type": "message",
    "channel": "D16RSST6W",
    "user": "U0RKX8RDM",
    "text": "What is the weather in San Francisco?",
    "ts": "1517990867.000000",
    "team": "T0RKXFPTP"
  }
}

Define Intent

The message “What is the weather in San Francisco?” maps to the WEATHER_QUERY Intent with the “city” entity “San Francisco”

{
  "name": "WEATHER_QUERY",
  "inputs": [
    {
      "name": "city",
      "value": "San Francisco"
    }
  ]
}

Append the Intent JSON to the original message

{
  "token": "...",
  "team": {
    "id": "T0RKXFPTP",
    "name": "jessetest"
  },
  "bot": {
    "id": "U16R8L1JA"
  },
  "message": {
    "type": "message",
    "channel": "D16RSST6W",
    "user": "U0RKX8RDM",
    "text": "What is the weather in San Francisco?",
    "ts": "1517990867.000000",
    "team": "T0RKXFPTP"
  },
  <strong>"intent": {
    "name": "WEATHER_QUERY",
    "inputs": [
      {
        "name": "city",
        "value": "San Francisco"
      }
    ]
  }</strong>
}

Post the complete message to Dashbot

https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=incoming&apiKey=<strong>API_KEY_HERE</strong>

Make sure to set the ‘Content-Type’ header to ‘application/json’

Sample cURL

curl -X POST -H "Content-Type: application/json"
     -d '{"token":"...","team":{"id":"T0RKXFPTP","name":"jessetest"},"bot":{"id":"U16R8L1JA"},"message":{"type":"message","channel":"D16RSST6W","user":"U0RKX8RDM","text":"What is the weather in San Francisco?","ts":"1517990867.000000","team":"T0RKXFPTP"},"intent":{"name":"WEATHER_QUERY","inputs":[{"name":"city","value":"San Francisco"}]}}'
     'https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=incoming&apiKey=<strong>API_KEY_HERE</strong>'

Note
Notice that the Intent object is for each message in the array of messages (which is inside the entries array).

Adding an Intent for an outbound message

Example: “The weather is 68 degrees and sunny.”

{
  "token": "...",
  "team": {
    "id": "T0RKXFPTP",
    "name": "jessetest"
  },
  "bot": {
    "id": "U16R8L1JA"
  },
  "message": {
    "type": "message",
    "text": "The weather is 68 and sunny.",
    "channel": "D16RSST6W"
  }
}

Define Intent

The message “The weather is 68 degrees and sunny.” maps to the WEATHER_RESPONSE Intent with the “forecast” entity “68 and sunny”

{
  "name": "WEATHER_RESPONSE",
  "inputs": [
    {
      "name": "forecast",
      "value": "68 and sunny"
    }
  ]
}

Append the Intent JSON to the original message

{
  "token": "...",
  "team": {
    "id": "T0RKXFPTP",
    "name": "jessetest"
  },
  "bot": {
    "id": "U16R8L1JA"
  },
  "message": {
    "type": "message",
    "text": "The weather is 68 and sunny.",
    "channel": "D16RSST6W"
  },
  <strong>"intent": {
    "name": "WEATHER_RESPONSE",
    "inputs": [
      {
        "name": "forecast",
        "value": "68 and sunny"
      }
    ]
  }</strong>
}

Post the complete message to Dashbot

https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=outgoing&apiKey=<strong>API_KEY_HERE</strong>

Make sure to set the ‘Content-Type’ header to ‘application/json’

Sample cURL

curl -X POST -H "Content-Type: application/json"
     -d '{"token":"...","team":{"id":"T0RKXFPTP","name":"jessetest"},"bot":{"id":"U16R8L1JA"},"message":{"type":"message","text":"The weather is 68 and sunny.","channel":"D16RSST6W"},"intent":{"name":"WEATHER_RESPONSE","inputs":[{"name":"forecast","value":"68 and sunny"}]}}'
     'https://tracker.dashbot.io/track?platform=slack&v=11.1.0-rest&type=outgoing&apiKey=<strong>API_KEY_HERE</strong>'

Note
Notice that the Intent object is for each message in the array of messages (which is inside the entries array).