Connecting our bot to Slack

Back in the Slack console, under the Event Subscriptions page, we will add the endpoint of our chatbot API to the Request URL field. In the following, you can see we are receiving a 500 error:

Adding a request URL resulting in an error

This happens because, when we subscribe to events, Slack will send a URL verification object to the request URL. Our code doesn't cater for this yet, so we need to add that as a feature. The object that Slack sends for verification looks like this:

{    "token":"GveYU40cwJ3NPGNM4MnVYHEe",    "challenge":"Bo0A0QRp5Z7lUILCWfIA284rCQ32cyAkfADRyVNQRopVb2HIutgv",    "type":"url_verification"}

Get Learn AWS Serverless Computing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.