This is a simple demo of interaction with slack, using WebHook. It uses both Incoming and Outgoing WebHooks. It shows the weather of a specific location, using OpenWeatherMap API
-
Setup ngRok -
- npm install ngRok
- Host your localhost application using ngRok - "ngrok http -host-header="localhost:58821" 58821"
-
Setup Outgoing Webhook -
-
Outgoing Webhook helps to call API from slack.
-
When slack encounters a specific trigger keyword, it calls the particular API.
-
It automatically sends a payload object with the following parameters -
a. token
b. team_id
c. team_domain
d. channel_id
e. channel_name
f. timestamp
g. user_id
h. user_name
i. text
j. trigger_word
-
-
Setup Incoming Webhook -
- Incoming Webhook helps slack, to receive a message, sent from the API
- It receives a payload object sent from the API
-
Additional Settings -
- Go to StringConstant.cs
- Set Slack Incoming Webhook Link
- Set API Key of openweathermap
- The API of openweathermap is already given in the StringConstant
And we are good to go!!
- Add the webhooks to your channel
- Set trigger word, for triggering the process
- <location_name>/<zip_code>/<area_id>